[ { "hash": "50967f090faed8e5864b5d736918ada737fb7a2e", "msg": "Added cblas.h.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2005-10-04T08:09:47+00:00", "author_timezone": 0, "committer_date": "2005-10-04T08:09:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d92e5504f1d6f6aee6615c674a93d6547f2927b3" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 1, "insertions": 579, "lines": 580, "files": 2, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/corelib/blasdot/_dotblas.c", "new_path": "scipy/corelib/blasdot/_dotblas.c", "filename": "_dotblas.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -5,7 +5,7 @@ static char module_doc[] =\n #include \"Python.h\"\n #include \"scipy/arrayobject.h\"\n #ifndef CBLAS_HEADER\n-#define CBLAS_HEADER \n+#define CBLAS_HEADER \"cblas.h\"\n #endif\n #include CBLAS_HEADER\n \n", "added_lines": 1, "deleted_lines": 1, "source_code": "static char module_doc[] =\n\"This module provides a BLAS optimized\\nmatrix multiply, inner product and dot for scipy arrays\";\n\n\n#include \"Python.h\"\n#include \"scipy/arrayobject.h\"\n#ifndef CBLAS_HEADER\n#define CBLAS_HEADER \"cblas.h\"\n#endif\n#include CBLAS_HEADER\n\n#include \n\nstatic void \nFLOAT_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n register int na = stridea / sizeof(float);\n register int nb = strideb / sizeof(float);\n\n *((float *)res) = cblas_sdot((int)n, (float *)a, na, (float *)b, nb);\n}\n\nstatic void \nDOUBLE_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n register int na = stridea / sizeof(double);\n register int nb = strideb / sizeof(double);\n\n *((double *)res) = cblas_ddot((int)n, (double *)a, na, (double *)b, nb);\n}\n\nstatic void \nCFLOAT_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n \n register int na = stridea / sizeof(cfloat);\n register int nb = strideb / sizeof(cfloat);\n\n cblas_cdotu_sub((int)n, (float *)a, na, (float *)b, nb, (float *)res);\n}\n\nstatic void \nCDOUBLE_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n register int na = stridea / sizeof(cdouble);\n register int nb = strideb / sizeof(cdouble);\n\n cblas_zdotu_sub((int)n, (double *)a, na, (double *)b, nb, (double *)res);\n}\n\n\nstatic PyArray_DotFunc *oldFunctions[PyArray_NTYPES];\nstatic Bool altered=FALSE;\n\nstatic char doc_alterdot[] = \"alterdot() changes all dot functions to use blas.\";\n\nstatic PyObject *\ndotblas_alterdot(PyObject *dummy, PyObject *args) \n{\n PyArray_Descr *descr;\n \n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n /* Replace the dot functions to the ones using blas */\n\n if (!altered) {\n\tdescr = PyArray_DescrFromType(PyArray_FLOAT);\n\toldFunctions[PyArray_FLOAT] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)FLOAT_dot;\n\t\n\tdescr = PyArray_DescrFromType(PyArray_DOUBLE);\n\toldFunctions[PyArray_DOUBLE] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)DOUBLE_dot;\n\t\n\tdescr = PyArray_DescrFromType(PyArray_CFLOAT);\n\toldFunctions[PyArray_CFLOAT] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)CFLOAT_dot;\n\t\n\tdescr = PyArray_DescrFromType(PyArray_CDOUBLE);\n\toldFunctions[PyArray_CDOUBLE] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)CDOUBLE_dot;\n\n\taltered = TRUE;\n }\n\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_restoredot[] = \"restoredot() restores dots to defaults.\";\n\nstatic PyObject *\ndotblas_restoredot(PyObject *dummy, PyObject *args) \n{\n PyArray_Descr *descr;\n\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n if (altered) {\n\tdescr = PyArray_DescrFromType(PyArray_FLOAT);\n\tdescr->dotfunc = oldFunctions[PyArray_FLOAT];\n\toldFunctions[PyArray_FLOAT] = NULL;\n\n\tdescr = PyArray_DescrFromType(PyArray_DOUBLE);\n\tdescr->dotfunc = oldFunctions[PyArray_DOUBLE];\n\toldFunctions[PyArray_DOUBLE] = NULL;\n\n\tdescr = PyArray_DescrFromType(PyArray_CFLOAT);\n\tdescr->dotfunc = oldFunctions[PyArray_CFLOAT];\n\toldFunctions[PyArray_CFLOAT] = NULL;\n\n\tdescr = PyArray_DescrFromType(PyArray_CDOUBLE);\n\tdescr->dotfunc = oldFunctions[PyArray_CDOUBLE];\n\toldFunctions[PyArray_CDOUBLE] = NULL;\n\t\n\taltered = FALSE;\n }\n\n Py_INCREF(Py_None);\n return Py_None;\n}\n \n\nstatic char doc_matrixproduct[] = \"matrixproduct(a,b)\\nReturns the dot product of a and b for arrays of floating point types.\\nLike the generic scipy equivalent the product sum is over\\nthe last dimension of a and the second-to-last dimension of b.\\nNB: The first argument is not conjugated.\";\n\n\nstatic PyObject *\ndotblas_matrixproduct(PyObject *dummy, PyObject *args) \n{\n PyObject *op1, *op2;\n PyArrayObject *ap1, *ap2, *ret;\n int j, l, lda, ldb;\n int typenum, nd;\n intp dimensions[MAX_DIMS];\n static const float oneF[2] = {1.0, 0.0};\n static const float zeroF[2] = {0.0, 0.0};\n static const double oneD[2] = {1.0, 0.0};\n static const double zeroD[2] = {0.0, 0.0};\n double prior1, prior2;\n PyTypeObject *subtype;\n PyArray_Typecode dtype = {PyArray_NOTYPE, 0, 0};\n\n\n if (!PyArg_ParseTuple(args, \"OO\", &op1, &op2)) return NULL;\n\t\n /* \n * \"Matrix product\" using the BLAS. \n * Only works for float double and complex types.\n */\n\n\n typenum = PyArray_ObjectType(op1, 0); \n typenum = PyArray_ObjectType(op2, typenum);\n\n /* This function doesn't handle other types */\n if ((typenum != PyArray_DOUBLE && typenum != PyArray_CDOUBLE &&\n\t typenum != PyArray_FLOAT && typenum != PyArray_CFLOAT)) {\n\treturn PyArray_MatrixProduct(op1, op2);\n }\n\n ret = NULL;\n dtype.type_num = typenum;\n ap1 = (PyArrayObject *)PyArray_FromAny(op1, &dtype, 0, 0, CARRAY_FLAGS);\n if (ap1 == NULL) return NULL;\n ap2 = (PyArrayObject *)PyArray_FromAny(op2, &dtype, 0, 0, CARRAY_FLAGS);\n if (ap2 == NULL) goto fail;\n\n if ((ap1->nd > 2) || (ap2->nd > 2)) { \n\t/* This function doesn't handle dimensions greater than 2 -- other\n\t than to ensure the dot function is altered\n\t*/\n\tif (!altered) {\n\t /* need to alter dot product */\n\t PyObject *tmp1, *tmp2;\n\t tmp1 = PyTuple_New(0);\n\t tmp2 = dotblas_alterdot(NULL, tmp1);\n\t Py_DECREF(tmp1); \n\t Py_DECREF(tmp2);\n\t}\n\tret = (PyArrayObject *)PyArray_MatrixProduct((PyObject *)ap1, \n\t\t\t\t\t\t (PyObject *)ap2);\n\tPy_DECREF(ap1); \n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n }\n\n if (ap1->nd == 0 || ap2->nd == 0) {\n\t/* One of ap1 or ap2 is a scalar */\n\tif (ap1->nd == 0) {\t\t/* Make ap2 the scalar */\n\t PyArrayObject *t = ap1;\n\t ap1 = ap2;\n\t ap2 = t;\n\t}\n\tfor (l = 1, j = 0; j < ap1->nd; j++) {\n\t dimensions[j] = ap1->dimensions[j];\n\t l *= dimensions[j];\n\t}\n\tnd = ap1->nd;\n }\n else { /* (ap1->nd <= 2 && ap2->nd <= 2) */\n\t/* Both ap1 and ap2 are vectors or matrices */\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[0] != l) {\n\t PyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t goto fail;\n\t}\n\tnd = ap1->nd+ap2->nd-2;\n \n\tif (nd == 1) \n\t dimensions[0] = (ap1->nd == 2) ? ap1->dimensions[0] : ap2->dimensions[1];\n\telse if (nd == 2) {\n\t dimensions[0] = ap1->dimensions[0];\n\t dimensions[1] = ap2->dimensions[1];\n\t}\n }\n\n /* Choose which subtype to return */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n \n ret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t (prior2 > prior1 ? ap2 : ap1)); \n if (ret == NULL) goto fail;\n memset(ret->data, '\\0', PyArray_SIZE(ret));\n\n if (ap2->nd == 0) {\n\t/* Multiplication by a scalar -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_daxpy(l, *((double *)ap2->data), (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t} \n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_saxpy(l, *((float *)ap2->data), (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zaxpy(l, (double *)ap2->data, (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_caxpy(l, (float *)ap2->data, (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 1) {\n\t/* Dot product between two vectors -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t double result = cblas_ddot(l, (double *)ap1->data, 1, \n\t\t\t\t (double *)ap2->data, 1);\n\t *((double *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t float result = cblas_sdot(l, (float *)ap1->data, 1, \n\t\t\t\t (float *)ap2->data, 1);\n\t *((float *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zdotu_sub(l, (double *)ap1->data, 1, \n\t\t\t (double *)ap2->data, 1, (double *)ret->data);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cdotu_sub(l, (float *)ap1->data, 1, \n\t\t\t (float *)ap2->data, 1, (float *)ret->data);\n\t fprintf(stderr, \"Here...\\n\");\n\t}\n }\n else if (ap1->nd == 2 && ap2->nd == 1) {\n\t/* Matrix vector multiplication -- Level 2 BLAS */\n\t/* lda must be MAX(M,1) */\n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (double *)ap1->data, lda, \n\t\t\t(double *)ap2->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (float *)ap1->data, lda, \n\t\t\t(float *)ap2->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneD, (double *)ap1->data, lda, \n\t\t\t(double *)ap2->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneF, (float *)ap1->data, lda, \n\t\t\t(float *)ap2->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 2) {\n\t/* Vector matrix multiplication -- Level 2 BLAS */\n\tlda = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneD, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneF, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else { /* (ap1->nd == 2 && ap2->nd == 2) */\n\t/* Matrix matrix multiplication -- Level 3 BLAS */ \n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tldb = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\t1.0, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\t0.0, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\t1.0, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\t0.0, (float *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\toneD, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\tzeroD, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\toneF, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\tzeroF, (float *)ret->data, ldb);\n\t}\n }\n\n Py_DECREF(ap1);\n Py_DECREF(ap2);\n return PyArray_Return(ret);\n\t\n fail:\n Py_XDECREF(ap1);\n Py_XDECREF(ap2);\n Py_XDECREF(ret);\n return NULL;\n}\n\n\nstatic char doc_innerproduct[] = \"innerproduct(a,b)\\nReturns the inner product of a and b for arrays of floating point types.\\nLike the generic Numeric equivalent the product sum is over\\nthe last dimension of a and b.\\nNB: The first argument is not conjugated.\";\n\nstatic PyObject *\ndotblas_innerproduct(PyObject *dummy, PyObject *args) \n{\n PyObject *op1, *op2;\n PyArrayObject *ap1, *ap2, *ret;\n int j, l, lda, ldb;\n int typenum, nd;\n intp dimensions[MAX_DIMS];\n static const float oneF[2] = {1.0, 0.0};\n static const float zeroF[2] = {0.0, 0.0};\n static const double oneD[2] = {1.0, 0.0};\n static const double zeroD[2] = {0.0, 0.0};\n PyTypeObject *subtype;\n double prior1, prior2;\n\n if (!PyArg_ParseTuple(args, \"OO\", &op1, &op2)) return NULL;\n\t\n /* \n * Inner product using the BLAS. The product sum is taken along the last\n * dimensions of the two arrays.\n * Only speeds things up for float double and complex types.\n */\n\n\n typenum = PyArray_ObjectType(op1, 0); \n typenum = PyArray_ObjectType(op2, typenum);\n\n /* This function doesn't handle other types */\n if ((typenum != PyArray_DOUBLE && typenum != PyArray_CDOUBLE &&\n\t typenum != PyArray_FLOAT && typenum != PyArray_CFLOAT)) {\n\treturn PyArray_InnerProduct(op1, op2);\n }\n\n ret = NULL;\n ap1 = (PyArrayObject *)PyArray_ContiguousFromObject(op1, typenum, 0, 0);\n if (ap1 == NULL) return NULL;\n ap2 = (PyArrayObject *)PyArray_ContiguousFromObject(op2, typenum, 0, 0);\n if (ap2 == NULL) goto fail;\n\n\n if ((ap1->nd > 2) || (ap2->nd > 2)) { \n\t/* This function doesn't handle dimensions greater than 2 -- other\n\t than to ensure the dot function is altered\n\t*/\n\tif (!altered) {\n\t /* need to alter dot product */\n\t PyObject *tmp1, *tmp2;\n\t tmp1 = PyTuple_New(0);\n\t tmp2 = dotblas_alterdot(NULL, tmp1);\n\t Py_DECREF(tmp1); \n\t Py_DECREF(tmp2);\n\t}\n\tret = (PyArrayObject *)PyArray_InnerProduct((PyObject *)ap1, \n\t\t\t\t\t\t (PyObject *)ap2);\n\tPy_DECREF(ap1); \n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n }\n\n if (ap1->nd == 0 || ap2->nd == 0) {\n\t/* One of ap1 or ap2 is a scalar */\n\tif (ap1->nd == 0) {\t\t/* Make ap2 the scalar */\n\t PyArrayObject *t = ap1;\n\t ap1 = ap2;\n\t ap2 = t;\n\t}\n\tfor (l = 1, j = 0; j < ap1->nd; j++) {\n\t dimensions[j] = ap1->dimensions[j];\n\t l *= dimensions[j];\n\t}\n\tnd = ap1->nd;\n }\n else { /* (ap1->nd <= 2 && ap2->nd <= 2) */\n\t/* Both ap1 and ap2 are vectors or matrices */\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t PyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t goto fail;\n\t}\n\tnd = ap1->nd+ap2->nd-2;\n \n\tif (nd == 1) \n\t dimensions[0] = (ap1->nd == 2) ? ap1->dimensions[0] : ap2->dimensions[0];\n\telse if (nd == 2) {\n\t dimensions[0] = ap1->dimensions[0];\n\t dimensions[1] = ap2->dimensions[0];\n\t}\n }\n\n /* Choose which subtype to return */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n \n ret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n \n if (ret == NULL) goto fail;\n memset(ret->data, 0, PyArray_SIZE(ret));\n\n if (ap2->nd == 0) {\n\t/* Multiplication by a scalar -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_daxpy(l, *((double *)ap2->data), (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t} \n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zaxpy(l, (double *)ap2->data, (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_saxpy(l, *((float *)ap2->data), (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_caxpy(l, (float *)ap2->data, (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 1) {\n\t/* Dot product between two vectors -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t double result = cblas_ddot(l, (double *)ap1->data, 1, \n\t\t\t\t (double *)ap2->data, 1);\n\t *((double *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zdotu_sub(l, (double *)ap1->data, 1, \n\t\t\t (double *)ap2->data, 1, (double *)ret->data);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t float result = cblas_sdot(l, (float *)ap1->data, 1, \n\t\t\t\t (float *)ap2->data, 1);\n\t *((float *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cdotu_sub(l, (float *)ap1->data, 1, \n\t\t\t (float *)ap2->data, 1, (float *)ret->data);\n\t}\n }\n else if (ap1->nd == 2 && ap2->nd == 1) {\n\t/* Matrix-vector multiplication -- Level 2 BLAS */\n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneD, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneF, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 2) {\n\t/* Vector matrix multiplication -- Level 2 BLAS */\n\tlda = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneD, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneF, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else { /* (ap1->nd == 2 && ap2->nd == 2) */ \n\t/* Matrix matrix multiplication -- Level 3 BLAS */ \n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tldb = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\t1.0, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\t0.0, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\t1.0, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\t0.0, (float *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\toneD, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\tzeroD, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\toneF, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\tzeroF, (float *)ret->data, ldb);\n\t}\n }\n Py_DECREF(ap1);\n Py_DECREF(ap2);\n return PyArray_Return(ret);\n\t\n fail:\n Py_XDECREF(ap1);\n Py_XDECREF(ap2);\n Py_XDECREF(ret);\n return NULL;\n}\n\n\nstatic char doc_vdot[] = \"vdot(a,b)\\nReturns the dot product of a and b for scalars and vectors\\nof floating point and complex types. The first argument, a, is conjugated.\";\n\n\nstatic PyObject *dotblas_vdot(PyObject *dummy, PyObject *args) {\n PyObject *op1, *op2;\n PyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;\n int l;\n int typenum;\n intp dimensions[MAX_DIMS];\n PyArray_Typecode type;\n\n if (!PyArg_ParseTuple(args, \"OO\", &op1, &op2)) return NULL;\n\t\n /* \n * Conjugating dot product using the BLAS for vectors.\n * Multiplies op1 and op2, each of which must be vector.\n */\n\n typenum = PyArray_ObjectType(op1, 0); \n typenum = PyArray_ObjectType(op2, typenum);\n \n type.type_num = typenum;\n \n ap1 = (PyArrayObject *)PyArray_FromAny(op1, &type, 0, 0, 0);\n if (ap1==NULL) goto fail;\n op1 = PyArray_Flatten(ap1, 0);\n if (op1==NULL) goto fail;\n Py_DECREF(ap1);\n ap1 = (PyArrayObject *)op1;\n \n ap2 = (PyArrayObject *)PyArray_FromAny(op2, &type, 0, 0, 0);\n if (ap2==NULL) goto fail;\n op2 = PyArray_Flatten(ap2, 0);\n if (op2 == NULL) goto fail;\n Py_DECREF(ap2);\n ap2 = (PyArrayObject *)op2;\n \n if (typenum != PyArray_FLOAT && typenum != PyArray_DOUBLE &&\n\ttypenum != PyArray_CFLOAT && typenum != PyArray_CDOUBLE) {\n\tif (!altered) {\n\t /* need to alter dot product */\n\t PyObject *tmp1, *tmp2;\n\t tmp1 = PyTuple_New(0);\n\t tmp2 = dotblas_alterdot(NULL, tmp1);\n\t Py_DECREF(tmp1); \n\t Py_DECREF(tmp2);\n\t}\n\tif (PyTypeNum_ISCOMPLEX(typenum)) {\n\t op1 = PyArray_Conjugate(ap1);\n\t if (op1==NULL) goto fail;\n\t Py_DECREF(ap1);\n\t ap1 = (PyArrayObject *)op1;\n\t}\t\n\tret = (PyArrayObject *)PyArray_InnerProduct((PyObject *)ap1, \n\t\t\t\t\t\t (PyObject *)ap2);\n\tPy_DECREF(ap1); \n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n }\n\n if (ap2->dimensions[0] != ap1->dimensions[ap1->nd-1]) {\n\tPyErr_SetString(PyExc_ValueError, \"vectors have different lengths\");\n\tgoto fail;\n }\n l = ap1->dimensions[ap1->nd-1];\n \n ret = (PyArrayObject *)PyArray_FromDims(0, dimensions, typenum);\n if (ret == NULL) goto fail;\n\n\n /* Dot product between two vectors -- Level 1 BLAS */\n if (typenum == PyArray_DOUBLE) {\n\t*((double *)ret->data) = cblas_ddot(l, (double *)ap1->data, 1, \n\t\t\t\t\t (double *)ap2->data, 1);\n }\n else if (typenum == PyArray_FLOAT) {\n\t*((float *)ret->data) = cblas_sdot(l, (float *)ap1->data, 1, \n\t\t\t\t\t (float *)ap2->data, 1);\n }\n else if (typenum == PyArray_CDOUBLE) {\n\tcblas_zdotc_sub(l, (double *)ap1->data, 1, \n\t\t\t(double *)ap2->data, 1, (double *)ret->data);\n }\n else if (typenum == PyArray_CFLOAT) {\n\tcblas_cdotc_sub(l, (float *)ap1->data, 1, \n\t\t\t(float *)ap2->data, 1, (float *)ret->data);\n }\n\n Py_DECREF(ap1);\n Py_DECREF(ap2);\n return PyArray_Return(ret);\n\t\n fail:\n Py_XDECREF(ap1);\n Py_XDECREF(ap2);\n Py_XDECREF(ret);\n return NULL;\n}\n\nstatic struct PyMethodDef dotblas_module_methods[] = {\n {\"dot\", (PyCFunction)dotblas_matrixproduct, 1, doc_matrixproduct},\n {\"inner\", (PyCFunction)dotblas_innerproduct, 1, doc_innerproduct},\n {\"vdot\", (PyCFunction)dotblas_vdot, 1, doc_vdot},\n {\"alterdot\", (PyCFunction)dotblas_alterdot, 1, doc_alterdot},\n {\"restoredot\", (PyCFunction)dotblas_restoredot, 1, doc_restoredot},\n {NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n/* Initialization function for the module */\nDL_EXPORT(void) init_dotblas(void) {\n int i;\n PyObject *m, *d, *s;\n \n /* Create the module and add the functions */\n m = Py_InitModule3(\"_dotblas\", dotblas_module_methods, module_doc);\n\n /* Import the array object */\n import_array();\n\n /* Initialise the array of dot functions */\n for (i = 0; i < PyArray_NTYPES; i++)\n\toldFunctions[i] = NULL;\n\n /* alterdot at load */\n d = PyTuple_New(0);\n s = dotblas_alterdot(NULL, d);\n Py_DECREF(d);\n Py_DECREF(s);\n \n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module _dotblas\");\n}\n", "source_code_before": "static char module_doc[] =\n\"This module provides a BLAS optimized\\nmatrix multiply, inner product and dot for scipy arrays\";\n\n\n#include \"Python.h\"\n#include \"scipy/arrayobject.h\"\n#ifndef CBLAS_HEADER\n#define CBLAS_HEADER \n#endif\n#include CBLAS_HEADER\n\n#include \n\nstatic void \nFLOAT_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n register int na = stridea / sizeof(float);\n register int nb = strideb / sizeof(float);\n\n *((float *)res) = cblas_sdot((int)n, (float *)a, na, (float *)b, nb);\n}\n\nstatic void \nDOUBLE_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n register int na = stridea / sizeof(double);\n register int nb = strideb / sizeof(double);\n\n *((double *)res) = cblas_ddot((int)n, (double *)a, na, (double *)b, nb);\n}\n\nstatic void \nCFLOAT_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n \n register int na = stridea / sizeof(cfloat);\n register int nb = strideb / sizeof(cfloat);\n\n cblas_cdotu_sub((int)n, (float *)a, na, (float *)b, nb, (float *)res);\n}\n\nstatic void \nCDOUBLE_dot(void *a, intp stridea, void *b, intp strideb, void *res, \n\t intp n, void *tmp)\n{\n register int na = stridea / sizeof(cdouble);\n register int nb = strideb / sizeof(cdouble);\n\n cblas_zdotu_sub((int)n, (double *)a, na, (double *)b, nb, (double *)res);\n}\n\n\nstatic PyArray_DotFunc *oldFunctions[PyArray_NTYPES];\nstatic Bool altered=FALSE;\n\nstatic char doc_alterdot[] = \"alterdot() changes all dot functions to use blas.\";\n\nstatic PyObject *\ndotblas_alterdot(PyObject *dummy, PyObject *args) \n{\n PyArray_Descr *descr;\n \n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n /* Replace the dot functions to the ones using blas */\n\n if (!altered) {\n\tdescr = PyArray_DescrFromType(PyArray_FLOAT);\n\toldFunctions[PyArray_FLOAT] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)FLOAT_dot;\n\t\n\tdescr = PyArray_DescrFromType(PyArray_DOUBLE);\n\toldFunctions[PyArray_DOUBLE] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)DOUBLE_dot;\n\t\n\tdescr = PyArray_DescrFromType(PyArray_CFLOAT);\n\toldFunctions[PyArray_CFLOAT] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)CFLOAT_dot;\n\t\n\tdescr = PyArray_DescrFromType(PyArray_CDOUBLE);\n\toldFunctions[PyArray_CDOUBLE] = descr->dotfunc;\n\tdescr->dotfunc = (PyArray_DotFunc *)CDOUBLE_dot;\n\n\taltered = TRUE;\n }\n\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_restoredot[] = \"restoredot() restores dots to defaults.\";\n\nstatic PyObject *\ndotblas_restoredot(PyObject *dummy, PyObject *args) \n{\n PyArray_Descr *descr;\n\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n if (altered) {\n\tdescr = PyArray_DescrFromType(PyArray_FLOAT);\n\tdescr->dotfunc = oldFunctions[PyArray_FLOAT];\n\toldFunctions[PyArray_FLOAT] = NULL;\n\n\tdescr = PyArray_DescrFromType(PyArray_DOUBLE);\n\tdescr->dotfunc = oldFunctions[PyArray_DOUBLE];\n\toldFunctions[PyArray_DOUBLE] = NULL;\n\n\tdescr = PyArray_DescrFromType(PyArray_CFLOAT);\n\tdescr->dotfunc = oldFunctions[PyArray_CFLOAT];\n\toldFunctions[PyArray_CFLOAT] = NULL;\n\n\tdescr = PyArray_DescrFromType(PyArray_CDOUBLE);\n\tdescr->dotfunc = oldFunctions[PyArray_CDOUBLE];\n\toldFunctions[PyArray_CDOUBLE] = NULL;\n\t\n\taltered = FALSE;\n }\n\n Py_INCREF(Py_None);\n return Py_None;\n}\n \n\nstatic char doc_matrixproduct[] = \"matrixproduct(a,b)\\nReturns the dot product of a and b for arrays of floating point types.\\nLike the generic scipy equivalent the product sum is over\\nthe last dimension of a and the second-to-last dimension of b.\\nNB: The first argument is not conjugated.\";\n\n\nstatic PyObject *\ndotblas_matrixproduct(PyObject *dummy, PyObject *args) \n{\n PyObject *op1, *op2;\n PyArrayObject *ap1, *ap2, *ret;\n int j, l, lda, ldb;\n int typenum, nd;\n intp dimensions[MAX_DIMS];\n static const float oneF[2] = {1.0, 0.0};\n static const float zeroF[2] = {0.0, 0.0};\n static const double oneD[2] = {1.0, 0.0};\n static const double zeroD[2] = {0.0, 0.0};\n double prior1, prior2;\n PyTypeObject *subtype;\n PyArray_Typecode dtype = {PyArray_NOTYPE, 0, 0};\n\n\n if (!PyArg_ParseTuple(args, \"OO\", &op1, &op2)) return NULL;\n\t\n /* \n * \"Matrix product\" using the BLAS. \n * Only works for float double and complex types.\n */\n\n\n typenum = PyArray_ObjectType(op1, 0); \n typenum = PyArray_ObjectType(op2, typenum);\n\n /* This function doesn't handle other types */\n if ((typenum != PyArray_DOUBLE && typenum != PyArray_CDOUBLE &&\n\t typenum != PyArray_FLOAT && typenum != PyArray_CFLOAT)) {\n\treturn PyArray_MatrixProduct(op1, op2);\n }\n\n ret = NULL;\n dtype.type_num = typenum;\n ap1 = (PyArrayObject *)PyArray_FromAny(op1, &dtype, 0, 0, CARRAY_FLAGS);\n if (ap1 == NULL) return NULL;\n ap2 = (PyArrayObject *)PyArray_FromAny(op2, &dtype, 0, 0, CARRAY_FLAGS);\n if (ap2 == NULL) goto fail;\n\n if ((ap1->nd > 2) || (ap2->nd > 2)) { \n\t/* This function doesn't handle dimensions greater than 2 -- other\n\t than to ensure the dot function is altered\n\t*/\n\tif (!altered) {\n\t /* need to alter dot product */\n\t PyObject *tmp1, *tmp2;\n\t tmp1 = PyTuple_New(0);\n\t tmp2 = dotblas_alterdot(NULL, tmp1);\n\t Py_DECREF(tmp1); \n\t Py_DECREF(tmp2);\n\t}\n\tret = (PyArrayObject *)PyArray_MatrixProduct((PyObject *)ap1, \n\t\t\t\t\t\t (PyObject *)ap2);\n\tPy_DECREF(ap1); \n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n }\n\n if (ap1->nd == 0 || ap2->nd == 0) {\n\t/* One of ap1 or ap2 is a scalar */\n\tif (ap1->nd == 0) {\t\t/* Make ap2 the scalar */\n\t PyArrayObject *t = ap1;\n\t ap1 = ap2;\n\t ap2 = t;\n\t}\n\tfor (l = 1, j = 0; j < ap1->nd; j++) {\n\t dimensions[j] = ap1->dimensions[j];\n\t l *= dimensions[j];\n\t}\n\tnd = ap1->nd;\n }\n else { /* (ap1->nd <= 2 && ap2->nd <= 2) */\n\t/* Both ap1 and ap2 are vectors or matrices */\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[0] != l) {\n\t PyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t goto fail;\n\t}\n\tnd = ap1->nd+ap2->nd-2;\n \n\tif (nd == 1) \n\t dimensions[0] = (ap1->nd == 2) ? ap1->dimensions[0] : ap2->dimensions[1];\n\telse if (nd == 2) {\n\t dimensions[0] = ap1->dimensions[0];\n\t dimensions[1] = ap2->dimensions[1];\n\t}\n }\n\n /* Choose which subtype to return */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n \n ret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t (prior2 > prior1 ? ap2 : ap1)); \n if (ret == NULL) goto fail;\n memset(ret->data, '\\0', PyArray_SIZE(ret));\n\n if (ap2->nd == 0) {\n\t/* Multiplication by a scalar -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_daxpy(l, *((double *)ap2->data), (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t} \n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_saxpy(l, *((float *)ap2->data), (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zaxpy(l, (double *)ap2->data, (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_caxpy(l, (float *)ap2->data, (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 1) {\n\t/* Dot product between two vectors -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t double result = cblas_ddot(l, (double *)ap1->data, 1, \n\t\t\t\t (double *)ap2->data, 1);\n\t *((double *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t float result = cblas_sdot(l, (float *)ap1->data, 1, \n\t\t\t\t (float *)ap2->data, 1);\n\t *((float *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zdotu_sub(l, (double *)ap1->data, 1, \n\t\t\t (double *)ap2->data, 1, (double *)ret->data);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cdotu_sub(l, (float *)ap1->data, 1, \n\t\t\t (float *)ap2->data, 1, (float *)ret->data);\n\t fprintf(stderr, \"Here...\\n\");\n\t}\n }\n else if (ap1->nd == 2 && ap2->nd == 1) {\n\t/* Matrix vector multiplication -- Level 2 BLAS */\n\t/* lda must be MAX(M,1) */\n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (double *)ap1->data, lda, \n\t\t\t(double *)ap2->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (float *)ap1->data, lda, \n\t\t\t(float *)ap2->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneD, (double *)ap1->data, lda, \n\t\t\t(double *)ap2->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneF, (float *)ap1->data, lda, \n\t\t\t(float *)ap2->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 2) {\n\t/* Vector matrix multiplication -- Level 2 BLAS */\n\tlda = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneD, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneF, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else { /* (ap1->nd == 2 && ap2->nd == 2) */\n\t/* Matrix matrix multiplication -- Level 3 BLAS */ \n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tldb = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\t1.0, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\t0.0, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\t1.0, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\t0.0, (float *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\toneD, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\tzeroD, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[1], ap2->dimensions[0],\n\t\t\toneF, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\tzeroF, (float *)ret->data, ldb);\n\t}\n }\n\n Py_DECREF(ap1);\n Py_DECREF(ap2);\n return PyArray_Return(ret);\n\t\n fail:\n Py_XDECREF(ap1);\n Py_XDECREF(ap2);\n Py_XDECREF(ret);\n return NULL;\n}\n\n\nstatic char doc_innerproduct[] = \"innerproduct(a,b)\\nReturns the inner product of a and b for arrays of floating point types.\\nLike the generic Numeric equivalent the product sum is over\\nthe last dimension of a and b.\\nNB: The first argument is not conjugated.\";\n\nstatic PyObject *\ndotblas_innerproduct(PyObject *dummy, PyObject *args) \n{\n PyObject *op1, *op2;\n PyArrayObject *ap1, *ap2, *ret;\n int j, l, lda, ldb;\n int typenum, nd;\n intp dimensions[MAX_DIMS];\n static const float oneF[2] = {1.0, 0.0};\n static const float zeroF[2] = {0.0, 0.0};\n static const double oneD[2] = {1.0, 0.0};\n static const double zeroD[2] = {0.0, 0.0};\n PyTypeObject *subtype;\n double prior1, prior2;\n\n if (!PyArg_ParseTuple(args, \"OO\", &op1, &op2)) return NULL;\n\t\n /* \n * Inner product using the BLAS. The product sum is taken along the last\n * dimensions of the two arrays.\n * Only speeds things up for float double and complex types.\n */\n\n\n typenum = PyArray_ObjectType(op1, 0); \n typenum = PyArray_ObjectType(op2, typenum);\n\n /* This function doesn't handle other types */\n if ((typenum != PyArray_DOUBLE && typenum != PyArray_CDOUBLE &&\n\t typenum != PyArray_FLOAT && typenum != PyArray_CFLOAT)) {\n\treturn PyArray_InnerProduct(op1, op2);\n }\n\n ret = NULL;\n ap1 = (PyArrayObject *)PyArray_ContiguousFromObject(op1, typenum, 0, 0);\n if (ap1 == NULL) return NULL;\n ap2 = (PyArrayObject *)PyArray_ContiguousFromObject(op2, typenum, 0, 0);\n if (ap2 == NULL) goto fail;\n\n\n if ((ap1->nd > 2) || (ap2->nd > 2)) { \n\t/* This function doesn't handle dimensions greater than 2 -- other\n\t than to ensure the dot function is altered\n\t*/\n\tif (!altered) {\n\t /* need to alter dot product */\n\t PyObject *tmp1, *tmp2;\n\t tmp1 = PyTuple_New(0);\n\t tmp2 = dotblas_alterdot(NULL, tmp1);\n\t Py_DECREF(tmp1); \n\t Py_DECREF(tmp2);\n\t}\n\tret = (PyArrayObject *)PyArray_InnerProduct((PyObject *)ap1, \n\t\t\t\t\t\t (PyObject *)ap2);\n\tPy_DECREF(ap1); \n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n }\n\n if (ap1->nd == 0 || ap2->nd == 0) {\n\t/* One of ap1 or ap2 is a scalar */\n\tif (ap1->nd == 0) {\t\t/* Make ap2 the scalar */\n\t PyArrayObject *t = ap1;\n\t ap1 = ap2;\n\t ap2 = t;\n\t}\n\tfor (l = 1, j = 0; j < ap1->nd; j++) {\n\t dimensions[j] = ap1->dimensions[j];\n\t l *= dimensions[j];\n\t}\n\tnd = ap1->nd;\n }\n else { /* (ap1->nd <= 2 && ap2->nd <= 2) */\n\t/* Both ap1 and ap2 are vectors or matrices */\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t PyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t goto fail;\n\t}\n\tnd = ap1->nd+ap2->nd-2;\n \n\tif (nd == 1) \n\t dimensions[0] = (ap1->nd == 2) ? ap1->dimensions[0] : ap2->dimensions[0];\n\telse if (nd == 2) {\n\t dimensions[0] = ap1->dimensions[0];\n\t dimensions[1] = ap2->dimensions[0];\n\t}\n }\n\n /* Choose which subtype to return */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n \n ret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n \n if (ret == NULL) goto fail;\n memset(ret->data, 0, PyArray_SIZE(ret));\n\n if (ap2->nd == 0) {\n\t/* Multiplication by a scalar -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_daxpy(l, *((double *)ap2->data), (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t} \n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zaxpy(l, (double *)ap2->data, (double *)ap1->data, 1,\n\t\t\t(double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_saxpy(l, *((float *)ap2->data), (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_caxpy(l, (float *)ap2->data, (float *)ap1->data, 1,\n\t\t\t(float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 1) {\n\t/* Dot product between two vectors -- Level 1 BLAS */\n\tif (typenum == PyArray_DOUBLE) {\n\t double result = cblas_ddot(l, (double *)ap1->data, 1, \n\t\t\t\t (double *)ap2->data, 1);\n\t *((double *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zdotu_sub(l, (double *)ap1->data, 1, \n\t\t\t (double *)ap2->data, 1, (double *)ret->data);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t float result = cblas_sdot(l, (float *)ap1->data, 1, \n\t\t\t\t (float *)ap2->data, 1);\n\t *((float *)ret->data) = result;\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cdotu_sub(l, (float *)ap1->data, 1, \n\t\t\t (float *)ap2->data, 1, (float *)ret->data);\n\t}\n }\n else if (ap1->nd == 2 && ap2->nd == 1) {\n\t/* Matrix-vector multiplication -- Level 2 BLAS */\n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneD, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\t1.0, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap1->dimensions[0], ap1->dimensions[1], \n\t\t\toneF, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else if (ap1->nd == 1 && ap2->nd == 2) {\n\t/* Vector matrix multiplication -- Level 2 BLAS */\n\tlda = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, 0.0, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneD, (double *)ap2->data, lda,\n\t\t\t(double *)ap1->data, 1, zeroD, (double *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\t1.0, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, 0.0, (float *)ret->data, 1);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemv(CblasRowMajor, \n\t\t\tCblasNoTrans, ap2->dimensions[0], ap2->dimensions[1], \n\t\t\toneF, (float *)ap2->data, lda,\n\t\t\t(float *)ap1->data, 1, zeroF, (float *)ret->data, 1);\n\t}\n }\n else { /* (ap1->nd == 2 && ap2->nd == 2) */ \n\t/* Matrix matrix multiplication -- Level 3 BLAS */ \n\tlda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1);\n\tldb = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1);\n\tif (typenum == PyArray_DOUBLE) {\n\t cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\t1.0, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\t0.0, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_FLOAT) {\n\t cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\t1.0, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\t0.0, (float *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CDOUBLE) {\n\t cblas_zgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\toneD, (double *)ap1->data, lda,\n\t\t\t(double *)ap2->data, ldb,\n\t\t\tzeroD, (double *)ret->data, ldb);\n\t}\n\telse if (typenum == PyArray_CFLOAT) {\n\t cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasTrans,\n\t\t\tap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],\n\t\t\toneF, (float *)ap1->data, lda,\n\t\t\t(float *)ap2->data, ldb,\n\t\t\tzeroF, (float *)ret->data, ldb);\n\t}\n }\n Py_DECREF(ap1);\n Py_DECREF(ap2);\n return PyArray_Return(ret);\n\t\n fail:\n Py_XDECREF(ap1);\n Py_XDECREF(ap2);\n Py_XDECREF(ret);\n return NULL;\n}\n\n\nstatic char doc_vdot[] = \"vdot(a,b)\\nReturns the dot product of a and b for scalars and vectors\\nof floating point and complex types. The first argument, a, is conjugated.\";\n\n\nstatic PyObject *dotblas_vdot(PyObject *dummy, PyObject *args) {\n PyObject *op1, *op2;\n PyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;\n int l;\n int typenum;\n intp dimensions[MAX_DIMS];\n PyArray_Typecode type;\n\n if (!PyArg_ParseTuple(args, \"OO\", &op1, &op2)) return NULL;\n\t\n /* \n * Conjugating dot product using the BLAS for vectors.\n * Multiplies op1 and op2, each of which must be vector.\n */\n\n typenum = PyArray_ObjectType(op1, 0); \n typenum = PyArray_ObjectType(op2, typenum);\n \n type.type_num = typenum;\n \n ap1 = (PyArrayObject *)PyArray_FromAny(op1, &type, 0, 0, 0);\n if (ap1==NULL) goto fail;\n op1 = PyArray_Flatten(ap1, 0);\n if (op1==NULL) goto fail;\n Py_DECREF(ap1);\n ap1 = (PyArrayObject *)op1;\n \n ap2 = (PyArrayObject *)PyArray_FromAny(op2, &type, 0, 0, 0);\n if (ap2==NULL) goto fail;\n op2 = PyArray_Flatten(ap2, 0);\n if (op2 == NULL) goto fail;\n Py_DECREF(ap2);\n ap2 = (PyArrayObject *)op2;\n \n if (typenum != PyArray_FLOAT && typenum != PyArray_DOUBLE &&\n\ttypenum != PyArray_CFLOAT && typenum != PyArray_CDOUBLE) {\n\tif (!altered) {\n\t /* need to alter dot product */\n\t PyObject *tmp1, *tmp2;\n\t tmp1 = PyTuple_New(0);\n\t tmp2 = dotblas_alterdot(NULL, tmp1);\n\t Py_DECREF(tmp1); \n\t Py_DECREF(tmp2);\n\t}\n\tif (PyTypeNum_ISCOMPLEX(typenum)) {\n\t op1 = PyArray_Conjugate(ap1);\n\t if (op1==NULL) goto fail;\n\t Py_DECREF(ap1);\n\t ap1 = (PyArrayObject *)op1;\n\t}\t\n\tret = (PyArrayObject *)PyArray_InnerProduct((PyObject *)ap1, \n\t\t\t\t\t\t (PyObject *)ap2);\n\tPy_DECREF(ap1); \n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n }\n\n if (ap2->dimensions[0] != ap1->dimensions[ap1->nd-1]) {\n\tPyErr_SetString(PyExc_ValueError, \"vectors have different lengths\");\n\tgoto fail;\n }\n l = ap1->dimensions[ap1->nd-1];\n \n ret = (PyArrayObject *)PyArray_FromDims(0, dimensions, typenum);\n if (ret == NULL) goto fail;\n\n\n /* Dot product between two vectors -- Level 1 BLAS */\n if (typenum == PyArray_DOUBLE) {\n\t*((double *)ret->data) = cblas_ddot(l, (double *)ap1->data, 1, \n\t\t\t\t\t (double *)ap2->data, 1);\n }\n else if (typenum == PyArray_FLOAT) {\n\t*((float *)ret->data) = cblas_sdot(l, (float *)ap1->data, 1, \n\t\t\t\t\t (float *)ap2->data, 1);\n }\n else if (typenum == PyArray_CDOUBLE) {\n\tcblas_zdotc_sub(l, (double *)ap1->data, 1, \n\t\t\t(double *)ap2->data, 1, (double *)ret->data);\n }\n else if (typenum == PyArray_CFLOAT) {\n\tcblas_cdotc_sub(l, (float *)ap1->data, 1, \n\t\t\t(float *)ap2->data, 1, (float *)ret->data);\n }\n\n Py_DECREF(ap1);\n Py_DECREF(ap2);\n return PyArray_Return(ret);\n\t\n fail:\n Py_XDECREF(ap1);\n Py_XDECREF(ap2);\n Py_XDECREF(ret);\n return NULL;\n}\n\nstatic struct PyMethodDef dotblas_module_methods[] = {\n {\"dot\", (PyCFunction)dotblas_matrixproduct, 1, doc_matrixproduct},\n {\"inner\", (PyCFunction)dotblas_innerproduct, 1, doc_innerproduct},\n {\"vdot\", (PyCFunction)dotblas_vdot, 1, doc_vdot},\n {\"alterdot\", (PyCFunction)dotblas_alterdot, 1, doc_alterdot},\n {\"restoredot\", (PyCFunction)dotblas_restoredot, 1, doc_restoredot},\n {NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n/* Initialization function for the module */\nDL_EXPORT(void) init_dotblas(void) {\n int i;\n PyObject *m, *d, *s;\n \n /* Create the module and add the functions */\n m = Py_InitModule3(\"_dotblas\", dotblas_module_methods, module_doc);\n\n /* Import the array object */\n import_array();\n\n /* Initialise the array of dot functions */\n for (i = 0; i < PyArray_NTYPES; i++)\n\toldFunctions[i] = NULL;\n\n /* alterdot at load */\n d = PyTuple_New(0);\n s = dotblas_alterdot(NULL, d);\n Py_DECREF(d);\n Py_DECREF(s);\n \n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module _dotblas\");\n}\n", "methods": [ { "name": "FLOAT_dot", "long_name": "FLOAT_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 84, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 15, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "DOUBLE_dot", "long_name": "DOUBLE_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 84, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 25, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "CFLOAT_dot", "long_name": "CFLOAT_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 81, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "CDOUBLE_dot", "long_name": "CDOUBLE_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 81, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dotblas_alterdot", "long_name": "dotblas_alterdot( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 22, "complexity": 3, "token_count": 152, "parameters": [ "dummy", "args" ], "start_line": 62, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "dotblas_restoredot", "long_name": "dotblas_restoredot( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 22, "complexity": 3, "token_count": 139, "parameters": [ "dummy", "args" ], "start_line": 97, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "dotblas_matrixproduct", "long_name": "dotblas_matrixproduct( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 209, "complexity": 53, "token_count": 2014, "parameters": [ "dummy", "args" ], "start_line": 132, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 243, "top_nesting_level": 0 }, { "name": "dotblas_innerproduct", "long_name": "dotblas_innerproduct( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 206, "complexity": 53, "token_count": 1988, "parameters": [ "dummy", "args" ], "start_line": 380, "end_line": 619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 240, "top_nesting_level": 0 }, { "name": "dotblas_vdot", "long_name": "dotblas_vdot( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 76, "complexity": 19, "token_count": 627, "parameters": [ "dummy", "args" ], "start_line": 625, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "init_dotblas", "long_name": "init_dotblas()", "filename": "_dotblas.c", "nloc": 14, "complexity": 3, "token_count": 90, "parameters": [], "start_line": 731, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 } ], "methods_before": [ { "name": "FLOAT_dot", "long_name": "FLOAT_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 84, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 15, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "DOUBLE_dot", "long_name": "DOUBLE_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 84, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 25, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "CFLOAT_dot", "long_name": "CFLOAT_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 81, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "CDOUBLE_dot", "long_name": "CDOUBLE_dot( * a , intp stridea , * b , intp strideb , * res , intp n , * tmp)", "filename": "_dotblas.c", "nloc": 7, "complexity": 1, "token_count": 81, "parameters": [ "a", "stridea", "b", "strideb", "res", "n", "tmp" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dotblas_alterdot", "long_name": "dotblas_alterdot( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 22, "complexity": 3, "token_count": 152, "parameters": [ "dummy", "args" ], "start_line": 62, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "dotblas_restoredot", "long_name": "dotblas_restoredot( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 22, "complexity": 3, "token_count": 139, "parameters": [ "dummy", "args" ], "start_line": 97, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "dotblas_matrixproduct", "long_name": "dotblas_matrixproduct( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 209, "complexity": 53, "token_count": 2014, "parameters": [ "dummy", "args" ], "start_line": 132, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 243, "top_nesting_level": 0 }, { "name": "dotblas_innerproduct", "long_name": "dotblas_innerproduct( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 206, "complexity": 53, "token_count": 1988, "parameters": [ "dummy", "args" ], "start_line": 380, "end_line": 619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 240, "top_nesting_level": 0 }, { "name": "dotblas_vdot", "long_name": "dotblas_vdot( PyObject * dummy , PyObject * args)", "filename": "_dotblas.c", "nloc": 76, "complexity": 19, "token_count": 627, "parameters": [ "dummy", "args" ], "start_line": 625, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "init_dotblas", "long_name": "init_dotblas()", "filename": "_dotblas.c", "nloc": 14, "complexity": 3, "token_count": 90, "parameters": [], "start_line": 731, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 606, "complexity": 138, "token_count": 5520, "diff_parsed": { "added": [ "#define CBLAS_HEADER \"cblas.h\"" ], "deleted": [ "#define CBLAS_HEADER " ] } }, { "old_path": null, "new_path": "scipy/corelib/blasdot/cblas.h", "filename": "cblas.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,578 @@\n+#ifndef CBLAS_H\n+#define CBLAS_H\n+#include \n+\n+/* Allow the use in C++ code. */\n+#ifdef __cplusplus\n+extern \"C\" \n+{\n+#endif\n+\n+/*\n+ * Enumerated and derived types\n+ */\n+#define CBLAS_INDEX size_t /* this may vary between platforms */\n+\n+enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};\n+enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113};\n+enum CBLAS_UPLO {CblasUpper=121, CblasLower=122};\n+enum CBLAS_DIAG {CblasNonUnit=131, CblasUnit=132};\n+enum CBLAS_SIDE {CblasLeft=141, CblasRight=142};\n+\n+/*\n+ * ===========================================================================\n+ * Prototypes for level 1 BLAS functions (complex are recast as routines)\n+ * ===========================================================================\n+ */\n+float cblas_sdsdot(const int N, const float alpha, const float *X,\n+ const int incX, const float *Y, const int incY);\n+double cblas_dsdot(const int N, const float *X, const int incX, const float *Y,\n+ const int incY);\n+float cblas_sdot(const int N, const float *X, const int incX,\n+ const float *Y, const int incY);\n+double cblas_ddot(const int N, const double *X, const int incX,\n+ const double *Y, const int incY);\n+\n+/*\n+ * Functions having prefixes Z and C only\n+ */\n+void cblas_cdotu_sub(const int N, const void *X, const int incX,\n+ const void *Y, const int incY, void *dotu);\n+void cblas_cdotc_sub(const int N, const void *X, const int incX,\n+ const void *Y, const int incY, void *dotc);\n+\n+void cblas_zdotu_sub(const int N, const void *X, const int incX,\n+ const void *Y, const int incY, void *dotu);\n+void cblas_zdotc_sub(const int N, const void *X, const int incX,\n+ const void *Y, const int incY, void *dotc);\n+\n+\n+/*\n+ * Functions having prefixes S D SC DZ\n+ */\n+float cblas_snrm2(const int N, const float *X, const int incX);\n+float cblas_sasum(const int N, const float *X, const int incX);\n+\n+double cblas_dnrm2(const int N, const double *X, const int incX);\n+double cblas_dasum(const int N, const double *X, const int incX);\n+\n+float cblas_scnrm2(const int N, const void *X, const int incX);\n+float cblas_scasum(const int N, const void *X, const int incX);\n+\n+double cblas_dznrm2(const int N, const void *X, const int incX);\n+double cblas_dzasum(const int N, const void *X, const int incX);\n+\n+\n+/*\n+ * Functions having standard 4 prefixes (S D C Z)\n+ */\n+CBLAS_INDEX cblas_isamax(const int N, const float *X, const int incX);\n+CBLAS_INDEX cblas_idamax(const int N, const double *X, const int incX);\n+CBLAS_INDEX cblas_icamax(const int N, const void *X, const int incX);\n+CBLAS_INDEX cblas_izamax(const int N, const void *X, const int incX);\n+\n+/*\n+ * ===========================================================================\n+ * Prototypes for level 1 BLAS routines\n+ * ===========================================================================\n+ */\n+\n+/* \n+ * Routines with standard 4 prefixes (s, d, c, z)\n+ */\n+void cblas_sswap(const int N, float *X, const int incX, \n+ float *Y, const int incY);\n+void cblas_scopy(const int N, const float *X, const int incX, \n+ float *Y, const int incY);\n+void cblas_saxpy(const int N, const float alpha, const float *X,\n+ const int incX, float *Y, const int incY);\n+\n+void cblas_dswap(const int N, double *X, const int incX, \n+ double *Y, const int incY);\n+void cblas_dcopy(const int N, const double *X, const int incX, \n+ double *Y, const int incY);\n+void cblas_daxpy(const int N, const double alpha, const double *X,\n+ const int incX, double *Y, const int incY);\n+\n+void cblas_cswap(const int N, void *X, const int incX, \n+ void *Y, const int incY);\n+void cblas_ccopy(const int N, const void *X, const int incX, \n+ void *Y, const int incY);\n+void cblas_caxpy(const int N, const void *alpha, const void *X,\n+ const int incX, void *Y, const int incY);\n+\n+void cblas_zswap(const int N, void *X, const int incX, \n+ void *Y, const int incY);\n+void cblas_zcopy(const int N, const void *X, const int incX, \n+ void *Y, const int incY);\n+void cblas_zaxpy(const int N, const void *alpha, const void *X,\n+ const int incX, void *Y, const int incY);\n+\n+\n+/* \n+ * Routines with S and D prefix only\n+ */\n+void cblas_srotg(float *a, float *b, float *c, float *s);\n+void cblas_srotmg(float *d1, float *d2, float *b1, const float b2, float *P);\n+void cblas_srot(const int N, float *X, const int incX,\n+ float *Y, const int incY, const float c, const float s);\n+void cblas_srotm(const int N, float *X, const int incX,\n+ float *Y, const int incY, const float *P);\n+\n+void cblas_drotg(double *a, double *b, double *c, double *s);\n+void cblas_drotmg(double *d1, double *d2, double *b1, const double b2, double *P);\n+void cblas_drot(const int N, double *X, const int incX,\n+ double *Y, const int incY, const double c, const double s);\n+void cblas_drotm(const int N, double *X, const int incX,\n+ double *Y, const int incY, const double *P);\n+\n+\n+/* \n+ * Routines with S D C Z CS and ZD prefixes\n+ */\n+void cblas_sscal(const int N, const float alpha, float *X, const int incX);\n+void cblas_dscal(const int N, const double alpha, double *X, const int incX);\n+void cblas_cscal(const int N, const void *alpha, void *X, const int incX);\n+void cblas_zscal(const int N, const void *alpha, void *X, const int incX);\n+void cblas_csscal(const int N, const float alpha, void *X, const int incX);\n+void cblas_zdscal(const int N, const double alpha, void *X, const int incX);\n+\n+/*\n+ * ===========================================================================\n+ * Prototypes for level 2 BLAS\n+ * ===========================================================================\n+ */\n+\n+/* \n+ * Routines with standard 4 prefixes (S, D, C, Z)\n+ */\n+void cblas_sgemv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const float alpha, const float *A, const int lda,\n+ const float *X, const int incX, const float beta,\n+ float *Y, const int incY);\n+void cblas_sgbmv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const int KL, const int KU, const float alpha,\n+ const float *A, const int lda, const float *X,\n+ const int incX, const float beta, float *Y, const int incY);\n+void cblas_strmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const float *A, const int lda, \n+ float *X, const int incX);\n+void cblas_stbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const float *A, const int lda, \n+ float *X, const int incX);\n+void cblas_stpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const float *Ap, float *X, const int incX);\n+void cblas_strsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const float *A, const int lda, float *X,\n+ const int incX);\n+void cblas_stbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const float *A, const int lda,\n+ float *X, const int incX);\n+void cblas_stpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const float *Ap, float *X, const int incX);\n+\n+void cblas_dgemv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const double alpha, const double *A, const int lda,\n+ const double *X, const int incX, const double beta,\n+ double *Y, const int incY);\n+void cblas_dgbmv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const int KL, const int KU, const double alpha,\n+ const double *A, const int lda, const double *X,\n+ const int incX, const double beta, double *Y, const int incY);\n+void cblas_dtrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const double *A, const int lda, \n+ double *X, const int incX);\n+void cblas_dtbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const double *A, const int lda, \n+ double *X, const int incX);\n+void cblas_dtpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const double *Ap, double *X, const int incX);\n+void cblas_dtrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const double *A, const int lda, double *X,\n+ const int incX);\n+void cblas_dtbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const double *A, const int lda,\n+ double *X, const int incX);\n+void cblas_dtpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const double *Ap, double *X, const int incX);\n+\n+void cblas_cgemv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ const void *X, const int incX, const void *beta,\n+ void *Y, const int incY);\n+void cblas_cgbmv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const int KL, const int KU, const void *alpha,\n+ const void *A, const int lda, const void *X,\n+ const int incX, const void *beta, void *Y, const int incY);\n+void cblas_ctrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *A, const int lda, \n+ void *X, const int incX);\n+void cblas_ctbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const void *A, const int lda, \n+ void *X, const int incX);\n+void cblas_ctpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *Ap, void *X, const int incX);\n+void cblas_ctrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *A, const int lda, void *X,\n+ const int incX);\n+void cblas_ctbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const void *A, const int lda,\n+ void *X, const int incX);\n+void cblas_ctpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *Ap, void *X, const int incX);\n+\n+void cblas_zgemv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ const void *X, const int incX, const void *beta,\n+ void *Y, const int incY);\n+void cblas_zgbmv(const enum CBLAS_ORDER order,\n+ const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n+ const int KL, const int KU, const void *alpha,\n+ const void *A, const int lda, const void *X,\n+ const int incX, const void *beta, void *Y, const int incY);\n+void cblas_ztrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *A, const int lda, \n+ void *X, const int incX);\n+void cblas_ztbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const void *A, const int lda, \n+ void *X, const int incX);\n+void cblas_ztpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *Ap, void *X, const int incX);\n+void cblas_ztrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *A, const int lda, void *X,\n+ const int incX);\n+void cblas_ztbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const int K, const void *A, const int lda,\n+ void *X, const int incX);\n+void cblas_ztpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n+ const int N, const void *Ap, void *X, const int incX);\n+\n+\n+/* \n+ * Routines with S and D prefixes only\n+ */\n+void cblas_ssymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const float *A,\n+ const int lda, const float *X, const int incX,\n+ const float beta, float *Y, const int incY);\n+void cblas_ssbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const int K, const float alpha, const float *A,\n+ const int lda, const float *X, const int incX,\n+ const float beta, float *Y, const int incY);\n+void cblas_sspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const float *Ap,\n+ const float *X, const int incX,\n+ const float beta, float *Y, const int incY);\n+void cblas_sger(const enum CBLAS_ORDER order, const int M, const int N,\n+ const float alpha, const float *X, const int incX,\n+ const float *Y, const int incY, float *A, const int lda);\n+void cblas_ssyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const float *X,\n+ const int incX, float *A, const int lda);\n+void cblas_sspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const float *X,\n+ const int incX, float *Ap);\n+void cblas_ssyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const float *X,\n+ const int incX, const float *Y, const int incY, float *A,\n+ const int lda);\n+void cblas_sspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const float *X,\n+ const int incX, const float *Y, const int incY, float *A);\n+\n+void cblas_dsymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const double *A,\n+ const int lda, const double *X, const int incX,\n+ const double beta, double *Y, const int incY);\n+void cblas_dsbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const int K, const double alpha, const double *A,\n+ const int lda, const double *X, const int incX,\n+ const double beta, double *Y, const int incY);\n+void cblas_dspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const double *Ap,\n+ const double *X, const int incX,\n+ const double beta, double *Y, const int incY);\n+void cblas_dger(const enum CBLAS_ORDER order, const int M, const int N,\n+ const double alpha, const double *X, const int incX,\n+ const double *Y, const int incY, double *A, const int lda);\n+void cblas_dsyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const double *X,\n+ const int incX, double *A, const int lda);\n+void cblas_dspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const double *X,\n+ const int incX, double *Ap);\n+void cblas_dsyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const double *X,\n+ const int incX, const double *Y, const int incY, double *A,\n+ const int lda);\n+void cblas_dspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const double *X,\n+ const int incX, const double *Y, const int incY, double *A);\n+\n+\n+/* \n+ * Routines with C and Z prefixes only\n+ */\n+void cblas_chemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const void *alpha, const void *A,\n+ const int lda, const void *X, const int incX,\n+ const void *beta, void *Y, const int incY);\n+void cblas_chbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const int K, const void *alpha, const void *A,\n+ const int lda, const void *X, const int incX,\n+ const void *beta, void *Y, const int incY);\n+void cblas_chpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const void *alpha, const void *Ap,\n+ const void *X, const int incX,\n+ const void *beta, void *Y, const int incY);\n+void cblas_cgeru(const enum CBLAS_ORDER order, const int M, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *A, const int lda);\n+void cblas_cgerc(const enum CBLAS_ORDER order, const int M, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *A, const int lda);\n+void cblas_cher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const void *X, const int incX,\n+ void *A, const int lda);\n+void cblas_chpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const float alpha, const void *X,\n+ const int incX, void *A);\n+void cblas_cher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *A, const int lda);\n+void cblas_chpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *Ap);\n+\n+void cblas_zhemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const void *alpha, const void *A,\n+ const int lda, const void *X, const int incX,\n+ const void *beta, void *Y, const int incY);\n+void cblas_zhbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const int K, const void *alpha, const void *A,\n+ const int lda, const void *X, const int incX,\n+ const void *beta, void *Y, const int incY);\n+void cblas_zhpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const void *alpha, const void *Ap,\n+ const void *X, const int incX,\n+ const void *beta, void *Y, const int incY);\n+void cblas_zgeru(const enum CBLAS_ORDER order, const int M, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *A, const int lda);\n+void cblas_zgerc(const enum CBLAS_ORDER order, const int M, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *A, const int lda);\n+void cblas_zher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const void *X, const int incX,\n+ void *A, const int lda);\n+void cblas_zhpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n+ const int N, const double alpha, const void *X,\n+ const int incX, void *A);\n+void cblas_zher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *A, const int lda);\n+void cblas_zhpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n+ const void *alpha, const void *X, const int incX,\n+ const void *Y, const int incY, void *Ap);\n+\n+/*\n+ * ===========================================================================\n+ * Prototypes for level 3 BLAS\n+ * ===========================================================================\n+ */\n+\n+/* \n+ * Routines with standard 4 prefixes (S, D, C, Z)\n+ */\n+void cblas_sgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n+ const int K, const float alpha, const float *A,\n+ const int lda, const float *B, const int ldb,\n+ const float beta, float *C, const int ldc);\n+void cblas_ssymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const int M, const int N,\n+ const float alpha, const float *A, const int lda,\n+ const float *B, const int ldb, const float beta,\n+ float *C, const int ldc);\n+void cblas_ssyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const float alpha, const float *A, const int lda,\n+ const float beta, float *C, const int ldc);\n+void cblas_ssyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const float alpha, const float *A, const int lda,\n+ const float *B, const int ldb, const float beta,\n+ float *C, const int ldc);\n+void cblas_strmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const float alpha, const float *A, const int lda,\n+ float *B, const int ldb);\n+void cblas_strsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const float alpha, const float *A, const int lda,\n+ float *B, const int ldb);\n+\n+void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n+ const int K, const double alpha, const double *A,\n+ const int lda, const double *B, const int ldb,\n+ const double beta, double *C, const int ldc);\n+void cblas_dsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const int M, const int N,\n+ const double alpha, const double *A, const int lda,\n+ const double *B, const int ldb, const double beta,\n+ double *C, const int ldc);\n+void cblas_dsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const double alpha, const double *A, const int lda,\n+ const double beta, double *C, const int ldc);\n+void cblas_dsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const double alpha, const double *A, const int lda,\n+ const double *B, const int ldb, const double beta,\n+ double *C, const int ldc);\n+void cblas_dtrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const double alpha, const double *A, const int lda,\n+ double *B, const int ldb);\n+void cblas_dtrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const double alpha, const double *A, const int lda,\n+ double *B, const int ldb);\n+\n+void cblas_cgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n+ const int K, const void *alpha, const void *A,\n+ const int lda, const void *B, const int ldb,\n+ const void *beta, void *C, const int ldc);\n+void cblas_csymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const void *beta,\n+ void *C, const int ldc);\n+void cblas_csyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const void *alpha, const void *A, const int lda,\n+ const void *beta, void *C, const int ldc);\n+void cblas_csyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const void *beta,\n+ void *C, const int ldc);\n+void cblas_ctrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ void *B, const int ldb);\n+void cblas_ctrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ void *B, const int ldb);\n+\n+void cblas_zgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n+ const int K, const void *alpha, const void *A,\n+ const int lda, const void *B, const int ldb,\n+ const void *beta, void *C, const int ldc);\n+void cblas_zsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const void *beta,\n+ void *C, const int ldc);\n+void cblas_zsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const void *alpha, const void *A, const int lda,\n+ const void *beta, void *C, const int ldc);\n+void cblas_zsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const void *beta,\n+ void *C, const int ldc);\n+void cblas_ztrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ void *B, const int ldb);\n+void cblas_ztrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n+ const enum CBLAS_DIAG Diag, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ void *B, const int ldb);\n+\n+\n+/* \n+ * Routines with prefixes C and Z only\n+ */\n+void cblas_chemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const void *beta,\n+ void *C, const int ldc);\n+void cblas_cherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const float alpha, const void *A, const int lda,\n+ const float beta, void *C, const int ldc);\n+void cblas_cher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const float beta,\n+ void *C, const int ldc);\n+\n+void cblas_zhemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n+ const enum CBLAS_UPLO Uplo, const int M, const int N,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const void *beta,\n+ void *C, const int ldc);\n+void cblas_zherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const double alpha, const void *A, const int lda,\n+ const double beta, void *C, const int ldc);\n+void cblas_zher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n+ const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n+ const void *alpha, const void *A, const int lda,\n+ const void *B, const int ldb, const double beta,\n+ void *C, const int ldc);\n+\n+void cblas_xerbla(int p, const char *rout, const char *form, ...);\n+\n+#ifdef __cplusplus\n+}\n+#endif \n+\n+#endif\n", "added_lines": 578, "deleted_lines": 0, "source_code": "#ifndef CBLAS_H\n#define CBLAS_H\n#include \n\n/* Allow the use in C++ code. */\n#ifdef __cplusplus\nextern \"C\" \n{\n#endif\n\n/*\n * Enumerated and derived types\n */\n#define CBLAS_INDEX size_t /* this may vary between platforms */\n\nenum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};\nenum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113};\nenum CBLAS_UPLO {CblasUpper=121, CblasLower=122};\nenum CBLAS_DIAG {CblasNonUnit=131, CblasUnit=132};\nenum CBLAS_SIDE {CblasLeft=141, CblasRight=142};\n\n/*\n * ===========================================================================\n * Prototypes for level 1 BLAS functions (complex are recast as routines)\n * ===========================================================================\n */\nfloat cblas_sdsdot(const int N, const float alpha, const float *X,\n const int incX, const float *Y, const int incY);\ndouble cblas_dsdot(const int N, const float *X, const int incX, const float *Y,\n const int incY);\nfloat cblas_sdot(const int N, const float *X, const int incX,\n const float *Y, const int incY);\ndouble cblas_ddot(const int N, const double *X, const int incX,\n const double *Y, const int incY);\n\n/*\n * Functions having prefixes Z and C only\n */\nvoid cblas_cdotu_sub(const int N, const void *X, const int incX,\n const void *Y, const int incY, void *dotu);\nvoid cblas_cdotc_sub(const int N, const void *X, const int incX,\n const void *Y, const int incY, void *dotc);\n\nvoid cblas_zdotu_sub(const int N, const void *X, const int incX,\n const void *Y, const int incY, void *dotu);\nvoid cblas_zdotc_sub(const int N, const void *X, const int incX,\n const void *Y, const int incY, void *dotc);\n\n\n/*\n * Functions having prefixes S D SC DZ\n */\nfloat cblas_snrm2(const int N, const float *X, const int incX);\nfloat cblas_sasum(const int N, const float *X, const int incX);\n\ndouble cblas_dnrm2(const int N, const double *X, const int incX);\ndouble cblas_dasum(const int N, const double *X, const int incX);\n\nfloat cblas_scnrm2(const int N, const void *X, const int incX);\nfloat cblas_scasum(const int N, const void *X, const int incX);\n\ndouble cblas_dznrm2(const int N, const void *X, const int incX);\ndouble cblas_dzasum(const int N, const void *X, const int incX);\n\n\n/*\n * Functions having standard 4 prefixes (S D C Z)\n */\nCBLAS_INDEX cblas_isamax(const int N, const float *X, const int incX);\nCBLAS_INDEX cblas_idamax(const int N, const double *X, const int incX);\nCBLAS_INDEX cblas_icamax(const int N, const void *X, const int incX);\nCBLAS_INDEX cblas_izamax(const int N, const void *X, const int incX);\n\n/*\n * ===========================================================================\n * Prototypes for level 1 BLAS routines\n * ===========================================================================\n */\n\n/* \n * Routines with standard 4 prefixes (s, d, c, z)\n */\nvoid cblas_sswap(const int N, float *X, const int incX, \n float *Y, const int incY);\nvoid cblas_scopy(const int N, const float *X, const int incX, \n float *Y, const int incY);\nvoid cblas_saxpy(const int N, const float alpha, const float *X,\n const int incX, float *Y, const int incY);\n\nvoid cblas_dswap(const int N, double *X, const int incX, \n double *Y, const int incY);\nvoid cblas_dcopy(const int N, const double *X, const int incX, \n double *Y, const int incY);\nvoid cblas_daxpy(const int N, const double alpha, const double *X,\n const int incX, double *Y, const int incY);\n\nvoid cblas_cswap(const int N, void *X, const int incX, \n void *Y, const int incY);\nvoid cblas_ccopy(const int N, const void *X, const int incX, \n void *Y, const int incY);\nvoid cblas_caxpy(const int N, const void *alpha, const void *X,\n const int incX, void *Y, const int incY);\n\nvoid cblas_zswap(const int N, void *X, const int incX, \n void *Y, const int incY);\nvoid cblas_zcopy(const int N, const void *X, const int incX, \n void *Y, const int incY);\nvoid cblas_zaxpy(const int N, const void *alpha, const void *X,\n const int incX, void *Y, const int incY);\n\n\n/* \n * Routines with S and D prefix only\n */\nvoid cblas_srotg(float *a, float *b, float *c, float *s);\nvoid cblas_srotmg(float *d1, float *d2, float *b1, const float b2, float *P);\nvoid cblas_srot(const int N, float *X, const int incX,\n float *Y, const int incY, const float c, const float s);\nvoid cblas_srotm(const int N, float *X, const int incX,\n float *Y, const int incY, const float *P);\n\nvoid cblas_drotg(double *a, double *b, double *c, double *s);\nvoid cblas_drotmg(double *d1, double *d2, double *b1, const double b2, double *P);\nvoid cblas_drot(const int N, double *X, const int incX,\n double *Y, const int incY, const double c, const double s);\nvoid cblas_drotm(const int N, double *X, const int incX,\n double *Y, const int incY, const double *P);\n\n\n/* \n * Routines with S D C Z CS and ZD prefixes\n */\nvoid cblas_sscal(const int N, const float alpha, float *X, const int incX);\nvoid cblas_dscal(const int N, const double alpha, double *X, const int incX);\nvoid cblas_cscal(const int N, const void *alpha, void *X, const int incX);\nvoid cblas_zscal(const int N, const void *alpha, void *X, const int incX);\nvoid cblas_csscal(const int N, const float alpha, void *X, const int incX);\nvoid cblas_zdscal(const int N, const double alpha, void *X, const int incX);\n\n/*\n * ===========================================================================\n * Prototypes for level 2 BLAS\n * ===========================================================================\n */\n\n/* \n * Routines with standard 4 prefixes (S, D, C, Z)\n */\nvoid cblas_sgemv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const float alpha, const float *A, const int lda,\n const float *X, const int incX, const float beta,\n float *Y, const int incY);\nvoid cblas_sgbmv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const int KL, const int KU, const float alpha,\n const float *A, const int lda, const float *X,\n const int incX, const float beta, float *Y, const int incY);\nvoid cblas_strmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const float *A, const int lda, \n float *X, const int incX);\nvoid cblas_stbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const float *A, const int lda, \n float *X, const int incX);\nvoid cblas_stpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const float *Ap, float *X, const int incX);\nvoid cblas_strsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const float *A, const int lda, float *X,\n const int incX);\nvoid cblas_stbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const float *A, const int lda,\n float *X, const int incX);\nvoid cblas_stpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const float *Ap, float *X, const int incX);\n\nvoid cblas_dgemv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const double alpha, const double *A, const int lda,\n const double *X, const int incX, const double beta,\n double *Y, const int incY);\nvoid cblas_dgbmv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const int KL, const int KU, const double alpha,\n const double *A, const int lda, const double *X,\n const int incX, const double beta, double *Y, const int incY);\nvoid cblas_dtrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const double *A, const int lda, \n double *X, const int incX);\nvoid cblas_dtbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const double *A, const int lda, \n double *X, const int incX);\nvoid cblas_dtpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const double *Ap, double *X, const int incX);\nvoid cblas_dtrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const double *A, const int lda, double *X,\n const int incX);\nvoid cblas_dtbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const double *A, const int lda,\n double *X, const int incX);\nvoid cblas_dtpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const double *Ap, double *X, const int incX);\n\nvoid cblas_cgemv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n const void *X, const int incX, const void *beta,\n void *Y, const int incY);\nvoid cblas_cgbmv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const int KL, const int KU, const void *alpha,\n const void *A, const int lda, const void *X,\n const int incX, const void *beta, void *Y, const int incY);\nvoid cblas_ctrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *A, const int lda, \n void *X, const int incX);\nvoid cblas_ctbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const void *A, const int lda, \n void *X, const int incX);\nvoid cblas_ctpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *Ap, void *X, const int incX);\nvoid cblas_ctrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *A, const int lda, void *X,\n const int incX);\nvoid cblas_ctbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const void *A, const int lda,\n void *X, const int incX);\nvoid cblas_ctpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *Ap, void *X, const int incX);\n\nvoid cblas_zgemv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n const void *X, const int incX, const void *beta,\n void *Y, const int incY);\nvoid cblas_zgbmv(const enum CBLAS_ORDER order,\n const enum CBLAS_TRANSPOSE TransA, const int M, const int N,\n const int KL, const int KU, const void *alpha,\n const void *A, const int lda, const void *X,\n const int incX, const void *beta, void *Y, const int incY);\nvoid cblas_ztrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *A, const int lda, \n void *X, const int incX);\nvoid cblas_ztbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const void *A, const int lda, \n void *X, const int incX);\nvoid cblas_ztpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *Ap, void *X, const int incX);\nvoid cblas_ztrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *A, const int lda, void *X,\n const int incX);\nvoid cblas_ztbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const int K, const void *A, const int lda,\n void *X, const int incX);\nvoid cblas_ztpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,\n const int N, const void *Ap, void *X, const int incX);\n\n\n/* \n * Routines with S and D prefixes only\n */\nvoid cblas_ssymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const float *A,\n const int lda, const float *X, const int incX,\n const float beta, float *Y, const int incY);\nvoid cblas_ssbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const int K, const float alpha, const float *A,\n const int lda, const float *X, const int incX,\n const float beta, float *Y, const int incY);\nvoid cblas_sspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const float *Ap,\n const float *X, const int incX,\n const float beta, float *Y, const int incY);\nvoid cblas_sger(const enum CBLAS_ORDER order, const int M, const int N,\n const float alpha, const float *X, const int incX,\n const float *Y, const int incY, float *A, const int lda);\nvoid cblas_ssyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const float *X,\n const int incX, float *A, const int lda);\nvoid cblas_sspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const float *X,\n const int incX, float *Ap);\nvoid cblas_ssyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const float *X,\n const int incX, const float *Y, const int incY, float *A,\n const int lda);\nvoid cblas_sspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const float *X,\n const int incX, const float *Y, const int incY, float *A);\n\nvoid cblas_dsymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const double *A,\n const int lda, const double *X, const int incX,\n const double beta, double *Y, const int incY);\nvoid cblas_dsbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const int K, const double alpha, const double *A,\n const int lda, const double *X, const int incX,\n const double beta, double *Y, const int incY);\nvoid cblas_dspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const double *Ap,\n const double *X, const int incX,\n const double beta, double *Y, const int incY);\nvoid cblas_dger(const enum CBLAS_ORDER order, const int M, const int N,\n const double alpha, const double *X, const int incX,\n const double *Y, const int incY, double *A, const int lda);\nvoid cblas_dsyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const double *X,\n const int incX, double *A, const int lda);\nvoid cblas_dspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const double *X,\n const int incX, double *Ap);\nvoid cblas_dsyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const double *X,\n const int incX, const double *Y, const int incY, double *A,\n const int lda);\nvoid cblas_dspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const double *X,\n const int incX, const double *Y, const int incY, double *A);\n\n\n/* \n * Routines with C and Z prefixes only\n */\nvoid cblas_chemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const void *alpha, const void *A,\n const int lda, const void *X, const int incX,\n const void *beta, void *Y, const int incY);\nvoid cblas_chbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const int K, const void *alpha, const void *A,\n const int lda, const void *X, const int incX,\n const void *beta, void *Y, const int incY);\nvoid cblas_chpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const void *alpha, const void *Ap,\n const void *X, const int incX,\n const void *beta, void *Y, const int incY);\nvoid cblas_cgeru(const enum CBLAS_ORDER order, const int M, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *A, const int lda);\nvoid cblas_cgerc(const enum CBLAS_ORDER order, const int M, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *A, const int lda);\nvoid cblas_cher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const void *X, const int incX,\n void *A, const int lda);\nvoid cblas_chpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const float alpha, const void *X,\n const int incX, void *A);\nvoid cblas_cher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *A, const int lda);\nvoid cblas_chpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *Ap);\n\nvoid cblas_zhemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const void *alpha, const void *A,\n const int lda, const void *X, const int incX,\n const void *beta, void *Y, const int incY);\nvoid cblas_zhbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const int K, const void *alpha, const void *A,\n const int lda, const void *X, const int incX,\n const void *beta, void *Y, const int incY);\nvoid cblas_zhpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const void *alpha, const void *Ap,\n const void *X, const int incX,\n const void *beta, void *Y, const int incY);\nvoid cblas_zgeru(const enum CBLAS_ORDER order, const int M, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *A, const int lda);\nvoid cblas_zgerc(const enum CBLAS_ORDER order, const int M, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *A, const int lda);\nvoid cblas_zher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const void *X, const int incX,\n void *A, const int lda);\nvoid cblas_zhpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,\n const int N, const double alpha, const void *X,\n const int incX, void *A);\nvoid cblas_zher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *A, const int lda);\nvoid cblas_zhpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,\n const void *alpha, const void *X, const int incX,\n const void *Y, const int incY, void *Ap);\n\n/*\n * ===========================================================================\n * Prototypes for level 3 BLAS\n * ===========================================================================\n */\n\n/* \n * Routines with standard 4 prefixes (S, D, C, Z)\n */\nvoid cblas_sgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n const int K, const float alpha, const float *A,\n const int lda, const float *B, const int ldb,\n const float beta, float *C, const int ldc);\nvoid cblas_ssymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const int M, const int N,\n const float alpha, const float *A, const int lda,\n const float *B, const int ldb, const float beta,\n float *C, const int ldc);\nvoid cblas_ssyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const float alpha, const float *A, const int lda,\n const float beta, float *C, const int ldc);\nvoid cblas_ssyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const float alpha, const float *A, const int lda,\n const float *B, const int ldb, const float beta,\n float *C, const int ldc);\nvoid cblas_strmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const float alpha, const float *A, const int lda,\n float *B, const int ldb);\nvoid cblas_strsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const float alpha, const float *A, const int lda,\n float *B, const int ldb);\n\nvoid cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n const int K, const double alpha, const double *A,\n const int lda, const double *B, const int ldb,\n const double beta, double *C, const int ldc);\nvoid cblas_dsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const int M, const int N,\n const double alpha, const double *A, const int lda,\n const double *B, const int ldb, const double beta,\n double *C, const int ldc);\nvoid cblas_dsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const double alpha, const double *A, const int lda,\n const double beta, double *C, const int ldc);\nvoid cblas_dsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const double alpha, const double *A, const int lda,\n const double *B, const int ldb, const double beta,\n double *C, const int ldc);\nvoid cblas_dtrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const double alpha, const double *A, const int lda,\n double *B, const int ldb);\nvoid cblas_dtrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const double alpha, const double *A, const int lda,\n double *B, const int ldb);\n\nvoid cblas_cgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n const int K, const void *alpha, const void *A,\n const int lda, const void *B, const int ldb,\n const void *beta, void *C, const int ldc);\nvoid cblas_csymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const void *beta,\n void *C, const int ldc);\nvoid cblas_csyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const void *alpha, const void *A, const int lda,\n const void *beta, void *C, const int ldc);\nvoid cblas_csyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const void *beta,\n void *C, const int ldc);\nvoid cblas_ctrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n void *B, const int ldb);\nvoid cblas_ctrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n void *B, const int ldb);\n\nvoid cblas_zgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_TRANSPOSE TransB, const int M, const int N,\n const int K, const void *alpha, const void *A,\n const int lda, const void *B, const int ldb,\n const void *beta, void *C, const int ldc);\nvoid cblas_zsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const void *beta,\n void *C, const int ldc);\nvoid cblas_zsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const void *alpha, const void *A, const int lda,\n const void *beta, void *C, const int ldc);\nvoid cblas_zsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const void *beta,\n void *C, const int ldc);\nvoid cblas_ztrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n void *B, const int ldb);\nvoid cblas_ztrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,\n const enum CBLAS_DIAG Diag, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n void *B, const int ldb);\n\n\n/* \n * Routines with prefixes C and Z only\n */\nvoid cblas_chemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const void *beta,\n void *C, const int ldc);\nvoid cblas_cherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const float alpha, const void *A, const int lda,\n const float beta, void *C, const int ldc);\nvoid cblas_cher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const float beta,\n void *C, const int ldc);\n\nvoid cblas_zhemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,\n const enum CBLAS_UPLO Uplo, const int M, const int N,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const void *beta,\n void *C, const int ldc);\nvoid cblas_zherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const double alpha, const void *A, const int lda,\n const double beta, void *C, const int ldc);\nvoid cblas_zher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,\n const enum CBLAS_TRANSPOSE Trans, const int N, const int K,\n const void *alpha, const void *A, const int lda,\n const void *B, const int ldb, const double beta,\n void *C, const int ldc);\n\nvoid cblas_xerbla(int p, const char *rout, const char *form, ...);\n\n#ifdef __cplusplus\n}\n#endif \n\n#endif\n", "source_code_before": null, "methods": [], "methods_before": [], "changed_methods": [], "nloc": 468, "complexity": 0, "token_count": 6119, "diff_parsed": { "added": [ "#ifndef CBLAS_H", "#define CBLAS_H", "#include ", "", "/* Allow the use in C++ code. */", "#ifdef __cplusplus", "extern \"C\"", "{", "#endif", "", "/*", " * Enumerated and derived types", " */", "#define CBLAS_INDEX size_t /* this may vary between platforms */", "", "enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};", "enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113};", "enum CBLAS_UPLO {CblasUpper=121, CblasLower=122};", "enum CBLAS_DIAG {CblasNonUnit=131, CblasUnit=132};", "enum CBLAS_SIDE {CblasLeft=141, CblasRight=142};", "", "/*", " * ===========================================================================", " * Prototypes for level 1 BLAS functions (complex are recast as routines)", " * ===========================================================================", " */", "float cblas_sdsdot(const int N, const float alpha, const float *X,", " const int incX, const float *Y, const int incY);", "double cblas_dsdot(const int N, const float *X, const int incX, const float *Y,", " const int incY);", "float cblas_sdot(const int N, const float *X, const int incX,", " const float *Y, const int incY);", "double cblas_ddot(const int N, const double *X, const int incX,", " const double *Y, const int incY);", "", "/*", " * Functions having prefixes Z and C only", " */", "void cblas_cdotu_sub(const int N, const void *X, const int incX,", " const void *Y, const int incY, void *dotu);", "void cblas_cdotc_sub(const int N, const void *X, const int incX,", " const void *Y, const int incY, void *dotc);", "", "void cblas_zdotu_sub(const int N, const void *X, const int incX,", " const void *Y, const int incY, void *dotu);", "void cblas_zdotc_sub(const int N, const void *X, const int incX,", " const void *Y, const int incY, void *dotc);", "", "", "/*", " * Functions having prefixes S D SC DZ", " */", "float cblas_snrm2(const int N, const float *X, const int incX);", "float cblas_sasum(const int N, const float *X, const int incX);", "", "double cblas_dnrm2(const int N, const double *X, const int incX);", "double cblas_dasum(const int N, const double *X, const int incX);", "", "float cblas_scnrm2(const int N, const void *X, const int incX);", "float cblas_scasum(const int N, const void *X, const int incX);", "", "double cblas_dznrm2(const int N, const void *X, const int incX);", "double cblas_dzasum(const int N, const void *X, const int incX);", "", "", "/*", " * Functions having standard 4 prefixes (S D C Z)", " */", "CBLAS_INDEX cblas_isamax(const int N, const float *X, const int incX);", "CBLAS_INDEX cblas_idamax(const int N, const double *X, const int incX);", "CBLAS_INDEX cblas_icamax(const int N, const void *X, const int incX);", "CBLAS_INDEX cblas_izamax(const int N, const void *X, const int incX);", "", "/*", " * ===========================================================================", " * Prototypes for level 1 BLAS routines", " * ===========================================================================", " */", "", "/*", " * Routines with standard 4 prefixes (s, d, c, z)", " */", "void cblas_sswap(const int N, float *X, const int incX,", " float *Y, const int incY);", "void cblas_scopy(const int N, const float *X, const int incX,", " float *Y, const int incY);", "void cblas_saxpy(const int N, const float alpha, const float *X,", " const int incX, float *Y, const int incY);", "", "void cblas_dswap(const int N, double *X, const int incX,", " double *Y, const int incY);", "void cblas_dcopy(const int N, const double *X, const int incX,", " double *Y, const int incY);", "void cblas_daxpy(const int N, const double alpha, const double *X,", " const int incX, double *Y, const int incY);", "", "void cblas_cswap(const int N, void *X, const int incX,", " void *Y, const int incY);", "void cblas_ccopy(const int N, const void *X, const int incX,", " void *Y, const int incY);", "void cblas_caxpy(const int N, const void *alpha, const void *X,", " const int incX, void *Y, const int incY);", "", "void cblas_zswap(const int N, void *X, const int incX,", " void *Y, const int incY);", "void cblas_zcopy(const int N, const void *X, const int incX,", " void *Y, const int incY);", "void cblas_zaxpy(const int N, const void *alpha, const void *X,", " const int incX, void *Y, const int incY);", "", "", "/*", " * Routines with S and D prefix only", " */", "void cblas_srotg(float *a, float *b, float *c, float *s);", "void cblas_srotmg(float *d1, float *d2, float *b1, const float b2, float *P);", "void cblas_srot(const int N, float *X, const int incX,", " float *Y, const int incY, const float c, const float s);", "void cblas_srotm(const int N, float *X, const int incX,", " float *Y, const int incY, const float *P);", "", "void cblas_drotg(double *a, double *b, double *c, double *s);", "void cblas_drotmg(double *d1, double *d2, double *b1, const double b2, double *P);", "void cblas_drot(const int N, double *X, const int incX,", " double *Y, const int incY, const double c, const double s);", "void cblas_drotm(const int N, double *X, const int incX,", " double *Y, const int incY, const double *P);", "", "", "/*", " * Routines with S D C Z CS and ZD prefixes", " */", "void cblas_sscal(const int N, const float alpha, float *X, const int incX);", "void cblas_dscal(const int N, const double alpha, double *X, const int incX);", "void cblas_cscal(const int N, const void *alpha, void *X, const int incX);", "void cblas_zscal(const int N, const void *alpha, void *X, const int incX);", "void cblas_csscal(const int N, const float alpha, void *X, const int incX);", "void cblas_zdscal(const int N, const double alpha, void *X, const int incX);", "", "/*", " * ===========================================================================", " * Prototypes for level 2 BLAS", " * ===========================================================================", " */", "", "/*", " * Routines with standard 4 prefixes (S, D, C, Z)", " */", "void cblas_sgemv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const float alpha, const float *A, const int lda,", " const float *X, const int incX, const float beta,", " float *Y, const int incY);", "void cblas_sgbmv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const int KL, const int KU, const float alpha,", " const float *A, const int lda, const float *X,", " const int incX, const float beta, float *Y, const int incY);", "void cblas_strmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const float *A, const int lda,", " float *X, const int incX);", "void cblas_stbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const float *A, const int lda,", " float *X, const int incX);", "void cblas_stpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const float *Ap, float *X, const int incX);", "void cblas_strsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const float *A, const int lda, float *X,", " const int incX);", "void cblas_stbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const float *A, const int lda,", " float *X, const int incX);", "void cblas_stpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const float *Ap, float *X, const int incX);", "", "void cblas_dgemv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const double alpha, const double *A, const int lda,", " const double *X, const int incX, const double beta,", " double *Y, const int incY);", "void cblas_dgbmv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const int KL, const int KU, const double alpha,", " const double *A, const int lda, const double *X,", " const int incX, const double beta, double *Y, const int incY);", "void cblas_dtrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const double *A, const int lda,", " double *X, const int incX);", "void cblas_dtbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const double *A, const int lda,", " double *X, const int incX);", "void cblas_dtpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const double *Ap, double *X, const int incX);", "void cblas_dtrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const double *A, const int lda, double *X,", " const int incX);", "void cblas_dtbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const double *A, const int lda,", " double *X, const int incX);", "void cblas_dtpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const double *Ap, double *X, const int incX);", "", "void cblas_cgemv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " const void *X, const int incX, const void *beta,", " void *Y, const int incY);", "void cblas_cgbmv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const int KL, const int KU, const void *alpha,", " const void *A, const int lda, const void *X,", " const int incX, const void *beta, void *Y, const int incY);", "void cblas_ctrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *A, const int lda,", " void *X, const int incX);", "void cblas_ctbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const void *A, const int lda,", " void *X, const int incX);", "void cblas_ctpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *Ap, void *X, const int incX);", "void cblas_ctrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *A, const int lda, void *X,", " const int incX);", "void cblas_ctbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const void *A, const int lda,", " void *X, const int incX);", "void cblas_ctpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *Ap, void *X, const int incX);", "", "void cblas_zgemv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " const void *X, const int incX, const void *beta,", " void *Y, const int incY);", "void cblas_zgbmv(const enum CBLAS_ORDER order,", " const enum CBLAS_TRANSPOSE TransA, const int M, const int N,", " const int KL, const int KU, const void *alpha,", " const void *A, const int lda, const void *X,", " const int incX, const void *beta, void *Y, const int incY);", "void cblas_ztrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *A, const int lda,", " void *X, const int incX);", "void cblas_ztbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const void *A, const int lda,", " void *X, const int incX);", "void cblas_ztpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *Ap, void *X, const int incX);", "void cblas_ztrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *A, const int lda, void *X,", " const int incX);", "void cblas_ztbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const int K, const void *A, const int lda,", " void *X, const int incX);", "void cblas_ztpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,", " const int N, const void *Ap, void *X, const int incX);", "", "", "/*", " * Routines with S and D prefixes only", " */", "void cblas_ssymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const float *A,", " const int lda, const float *X, const int incX,", " const float beta, float *Y, const int incY);", "void cblas_ssbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const int K, const float alpha, const float *A,", " const int lda, const float *X, const int incX,", " const float beta, float *Y, const int incY);", "void cblas_sspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const float *Ap,", " const float *X, const int incX,", " const float beta, float *Y, const int incY);", "void cblas_sger(const enum CBLAS_ORDER order, const int M, const int N,", " const float alpha, const float *X, const int incX,", " const float *Y, const int incY, float *A, const int lda);", "void cblas_ssyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const float *X,", " const int incX, float *A, const int lda);", "void cblas_sspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const float *X,", " const int incX, float *Ap);", "void cblas_ssyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const float *X,", " const int incX, const float *Y, const int incY, float *A,", " const int lda);", "void cblas_sspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const float *X,", " const int incX, const float *Y, const int incY, float *A);", "", "void cblas_dsymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const double *A,", " const int lda, const double *X, const int incX,", " const double beta, double *Y, const int incY);", "void cblas_dsbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const int K, const double alpha, const double *A,", " const int lda, const double *X, const int incX,", " const double beta, double *Y, const int incY);", "void cblas_dspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const double *Ap,", " const double *X, const int incX,", " const double beta, double *Y, const int incY);", "void cblas_dger(const enum CBLAS_ORDER order, const int M, const int N,", " const double alpha, const double *X, const int incX,", " const double *Y, const int incY, double *A, const int lda);", "void cblas_dsyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const double *X,", " const int incX, double *A, const int lda);", "void cblas_dspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const double *X,", " const int incX, double *Ap);", "void cblas_dsyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const double *X,", " const int incX, const double *Y, const int incY, double *A,", " const int lda);", "void cblas_dspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const double *X,", " const int incX, const double *Y, const int incY, double *A);", "", "", "/*", " * Routines with C and Z prefixes only", " */", "void cblas_chemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const void *alpha, const void *A,", " const int lda, const void *X, const int incX,", " const void *beta, void *Y, const int incY);", "void cblas_chbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const int K, const void *alpha, const void *A,", " const int lda, const void *X, const int incX,", " const void *beta, void *Y, const int incY);", "void cblas_chpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const void *alpha, const void *Ap,", " const void *X, const int incX,", " const void *beta, void *Y, const int incY);", "void cblas_cgeru(const enum CBLAS_ORDER order, const int M, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *A, const int lda);", "void cblas_cgerc(const enum CBLAS_ORDER order, const int M, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *A, const int lda);", "void cblas_cher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const void *X, const int incX,", " void *A, const int lda);", "void cblas_chpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const float alpha, const void *X,", " const int incX, void *A);", "void cblas_cher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *A, const int lda);", "void cblas_chpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *Ap);", "", "void cblas_zhemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const void *alpha, const void *A,", " const int lda, const void *X, const int incX,", " const void *beta, void *Y, const int incY);", "void cblas_zhbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const int K, const void *alpha, const void *A,", " const int lda, const void *X, const int incX,", " const void *beta, void *Y, const int incY);", "void cblas_zhpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const void *alpha, const void *Ap,", " const void *X, const int incX,", " const void *beta, void *Y, const int incY);", "void cblas_zgeru(const enum CBLAS_ORDER order, const int M, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *A, const int lda);", "void cblas_zgerc(const enum CBLAS_ORDER order, const int M, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *A, const int lda);", "void cblas_zher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const void *X, const int incX,", " void *A, const int lda);", "void cblas_zhpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,", " const int N, const double alpha, const void *X,", " const int incX, void *A);", "void cblas_zher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *A, const int lda);", "void cblas_zhpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,", " const void *alpha, const void *X, const int incX,", " const void *Y, const int incY, void *Ap);", "", "/*", " * ===========================================================================", " * Prototypes for level 3 BLAS", " * ===========================================================================", " */", "", "/*", " * Routines with standard 4 prefixes (S, D, C, Z)", " */", "void cblas_sgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_TRANSPOSE TransB, const int M, const int N,", " const int K, const float alpha, const float *A,", " const int lda, const float *B, const int ldb,", " const float beta, float *C, const int ldc);", "void cblas_ssymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const int M, const int N,", " const float alpha, const float *A, const int lda,", " const float *B, const int ldb, const float beta,", " float *C, const int ldc);", "void cblas_ssyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const float alpha, const float *A, const int lda,", " const float beta, float *C, const int ldc);", "void cblas_ssyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const float alpha, const float *A, const int lda,", " const float *B, const int ldb, const float beta,", " float *C, const int ldc);", "void cblas_strmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const float alpha, const float *A, const int lda,", " float *B, const int ldb);", "void cblas_strsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const float alpha, const float *A, const int lda,", " float *B, const int ldb);", "", "void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_TRANSPOSE TransB, const int M, const int N,", " const int K, const double alpha, const double *A,", " const int lda, const double *B, const int ldb,", " const double beta, double *C, const int ldc);", "void cblas_dsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const int M, const int N,", " const double alpha, const double *A, const int lda,", " const double *B, const int ldb, const double beta,", " double *C, const int ldc);", "void cblas_dsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const double alpha, const double *A, const int lda,", " const double beta, double *C, const int ldc);", "void cblas_dsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const double alpha, const double *A, const int lda,", " const double *B, const int ldb, const double beta,", " double *C, const int ldc);", "void cblas_dtrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const double alpha, const double *A, const int lda,", " double *B, const int ldb);", "void cblas_dtrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const double alpha, const double *A, const int lda,", " double *B, const int ldb);", "", "void cblas_cgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_TRANSPOSE TransB, const int M, const int N,", " const int K, const void *alpha, const void *A,", " const int lda, const void *B, const int ldb,", " const void *beta, void *C, const int ldc);", "void cblas_csymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const void *beta,", " void *C, const int ldc);", "void cblas_csyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const void *alpha, const void *A, const int lda,", " const void *beta, void *C, const int ldc);", "void cblas_csyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const void *beta,", " void *C, const int ldc);", "void cblas_ctrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " void *B, const int ldb);", "void cblas_ctrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " void *B, const int ldb);", "", "void cblas_zgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_TRANSPOSE TransB, const int M, const int N,", " const int K, const void *alpha, const void *A,", " const int lda, const void *B, const int ldb,", " const void *beta, void *C, const int ldc);", "void cblas_zsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const void *beta,", " void *C, const int ldc);", "void cblas_zsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const void *alpha, const void *A, const int lda,", " const void *beta, void *C, const int ldc);", "void cblas_zsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const void *beta,", " void *C, const int ldc);", "void cblas_ztrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " void *B, const int ldb);", "void cblas_ztrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,", " const enum CBLAS_DIAG Diag, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " void *B, const int ldb);", "", "", "/*", " * Routines with prefixes C and Z only", " */", "void cblas_chemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const void *beta,", " void *C, const int ldc);", "void cblas_cherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const float alpha, const void *A, const int lda,", " const float beta, void *C, const int ldc);", "void cblas_cher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const float beta,", " void *C, const int ldc);", "", "void cblas_zhemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,", " const enum CBLAS_UPLO Uplo, const int M, const int N,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const void *beta,", " void *C, const int ldc);", "void cblas_zherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const double alpha, const void *A, const int lda,", " const double beta, void *C, const int ldc);", "void cblas_zher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,", " const enum CBLAS_TRANSPOSE Trans, const int N, const int K,", " const void *alpha, const void *A, const int lda,", " const void *B, const int ldb, const double beta,", " void *C, const int ldc);", "", "void cblas_xerbla(int p, const char *rout, const char *form, ...);", "", "#ifdef __cplusplus", "}", "#endif", "", "#endif" ], "deleted": [] } } ] }, { "hash": "d32f2d2362144efb664ee557637b466c8d950546", "msg": "Added extra_info kw to add_extension method. Cleaned corelib setup.py.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2005-10-04T08:37:12+00:00", "author_timezone": 0, "committer_date": "2005-10-04T08:37:12+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "50967f090faed8e5864b5d736918ada737fb7a2e" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 23, "insertions": 49, "lines": 72, "files": 2, "dmm_unit_size": 0.5882352941176471, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.47058823529411764, "modified_files": [ { "old_path": "scipy/corelib/setup.py", "new_path": "scipy/corelib/setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -12,12 +12,18 @@ def configuration(parent_package='',top_path=None):\n \n # Configure blasdot\n blas_info = get_info('blas_opt')\n- #blas_info = 0\n- if blas_info or 'sdist' in sys.argv:\n- config.add_extension('_dotblas',\n- sources=[join('blasdot','_dotblas.c')],\n- **blas_info\n- )\n+ #blas_info = {}\n+ def get_dotblas_sources(ext, build_dir):\n+ if blas_info:\n+ return ext.depends\n+ return None # no extension module will be built\n+\n+ config.add_extension('_dotblas',\n+ sources = [get_dotblas_sources],\n+ depends=[join('blasdot','_dotblas.c')],\n+ include_dirs = ['blasdot'],\n+ extra_info = blas_info\n+ )\n \n # Configure fftpack_lite\n config.add_extension('fftpack_lite',\n@@ -25,6 +31,7 @@ def configuration(parent_package='',top_path=None):\n ['fftpack_litemodule.c', 'fftpack.c']]\n )\n \n+ # Configure mtrand\n config.add_extension('mtrand',\n sources=[join('mtrand', x) for x in \n ['mtrand.c', 'randomkit.c', 'initarray.c',\n@@ -35,22 +42,22 @@ def configuration(parent_package='',top_path=None):\n \n # Configure lapack_lite\n lapack_info = get_info('lapack_opt')\n- #lapack_info = 0\n- if not lapack_info or 'sdist' in sys.argv:\n- # use C-sources provided\n- print \"### Warning: Using unoptimized lapack ###\"\n- config.add_extension('lapack_lite',\n- sources=[join('lapack_lite', x) for x in \\\n- ['lapack_litemodule.c',\n- 'zlapack_lite.c', 'dlapack_lite.c',\n- 'blas_lite.c', 'dlamch.c',\n- 'f2c_lite.c']]\n- )\n- else:\n- config.add_extension('lapack_lite',\n- sources=[join('lapack_lite',\n- 'lapack_litemodule.c')],\n- **lapack_info)\n+ def get_lapack_lite_sources(ext, build_dir):\n+ if not lapack_info:\n+ print \"### Warning: Using unoptimized lapack ###\"\n+ return ext.depends\n+ else:\n+ return ext.depends[:1]\n+\n+ config.add_extension('lapack_lite',\n+ sources = [get_lapack_lite_sources],\n+ depends=[join('lapack_lite', x) for x in \\\n+ ['lapack_litemodule.c',\n+ 'zlapack_lite.c', 'dlapack_lite.c',\n+ 'blas_lite.c', 'dlamch.c',\n+ 'f2c_lite.c']],\n+ extra_info = lapack_info\n+ )\n \n return config.todict()\n \n", "added_lines": 29, "deleted_lines": 22, "source_code": "#!/usr/bin/env python\nimport os\nfrom os.path import join\nfrom scipy.distutils.core import setup\nfrom scipy.distutils.misc_util import Configuration, allpath\nfrom scipy.distutils.system_info import get_info\nimport sys\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('lib',parent_package,top_path)\n local_dir = config.local_path\n\n # Configure blasdot\n blas_info = get_info('blas_opt')\n #blas_info = {}\n def get_dotblas_sources(ext, build_dir):\n if blas_info:\n return ext.depends\n return None # no extension module will be built\n\n config.add_extension('_dotblas',\n sources = [get_dotblas_sources],\n depends=[join('blasdot','_dotblas.c')],\n include_dirs = ['blasdot'],\n extra_info = blas_info\n )\n\n # Configure fftpack_lite\n config.add_extension('fftpack_lite',\n sources=[join('fftpack_lite', x) for x in \\\n ['fftpack_litemodule.c', 'fftpack.c']]\n )\n\n # Configure mtrand\n config.add_extension('mtrand',\n sources=[join('mtrand', x) for x in \n ['mtrand.c', 'randomkit.c', 'initarray.c',\n 'distributions.c', 'gamma.c', 'polevl.c', \n 'isnan.c', 'const.c']],\n libraries=['m'],\n )\n\n # Configure lapack_lite\n lapack_info = get_info('lapack_opt')\n def get_lapack_lite_sources(ext, build_dir):\n if not lapack_info:\n print \"### Warning: Using unoptimized lapack ###\"\n return ext.depends\n else:\n return ext.depends[:1]\n\n config.add_extension('lapack_lite',\n sources = [get_lapack_lite_sources],\n depends=[join('lapack_lite', x) for x in \\\n ['lapack_litemodule.c',\n 'zlapack_lite.c', 'dlapack_lite.c',\n 'blas_lite.c', 'dlamch.c',\n 'f2c_lite.c']],\n extra_info = lapack_info\n )\n \n return config.todict()\n\nif __name__ == '__main__':\n setup(**configuration(top_path=''))\n", "source_code_before": "#!/usr/bin/env python\nimport os\nfrom os.path import join\nfrom scipy.distutils.core import setup\nfrom scipy.distutils.misc_util import Configuration, allpath\nfrom scipy.distutils.system_info import get_info\nimport sys\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('lib',parent_package,top_path)\n local_dir = config.local_path\n\n # Configure blasdot\n blas_info = get_info('blas_opt')\n #blas_info = 0\n if blas_info or 'sdist' in sys.argv:\n config.add_extension('_dotblas',\n sources=[join('blasdot','_dotblas.c')],\n **blas_info\n )\n\n # Configure fftpack_lite\n config.add_extension('fftpack_lite',\n sources=[join('fftpack_lite', x) for x in \\\n ['fftpack_litemodule.c', 'fftpack.c']]\n )\n\n config.add_extension('mtrand',\n sources=[join('mtrand', x) for x in \n ['mtrand.c', 'randomkit.c', 'initarray.c',\n 'distributions.c', 'gamma.c', 'polevl.c', \n 'isnan.c', 'const.c']],\n libraries=['m'],\n )\n\n # Configure lapack_lite\n lapack_info = get_info('lapack_opt')\n #lapack_info = 0\n if not lapack_info or 'sdist' in sys.argv:\n # use C-sources provided\n print \"### Warning: Using unoptimized lapack ###\"\n config.add_extension('lapack_lite',\n sources=[join('lapack_lite', x) for x in \\\n ['lapack_litemodule.c',\n 'zlapack_lite.c', 'dlapack_lite.c',\n 'blas_lite.c', 'dlamch.c',\n 'f2c_lite.c']]\n )\n else:\n config.add_extension('lapack_lite',\n sources=[join('lapack_lite',\n 'lapack_litemodule.c')],\n **lapack_info)\n \n return config.todict()\n\nif __name__ == '__main__':\n setup(**configuration(top_path=''))\n", "methods": [ { "name": "configuration.get_dotblas_sources", "long_name": "configuration.get_dotblas_sources( ext , build_dir )", "filename": "setup.py", "nloc": 4, "complexity": 2, "token_count": 16, "parameters": [ "ext", "build_dir" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configuration.get_lapack_lite_sources", "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", "filename": "setup.py", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [ "ext", "build_dir" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 34, "complexity": 4, "token_count": 195, "parameters": [ "parent_package", "top_path" ], "start_line": 9, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 36, "complexity": 8, "token_count": 211, "parameters": [ "parent_package", "top_path" ], "start_line": 9, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 34, "complexity": 4, "token_count": 195, "parameters": [ "parent_package", "top_path" ], "start_line": 9, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 0 }, { "name": "configuration.get_lapack_lite_sources", "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", "filename": "setup.py", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [ "ext", "build_dir" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configuration.get_dotblas_sources", "long_name": "configuration.get_dotblas_sources( ext , build_dir )", "filename": "setup.py", "nloc": 4, "complexity": 2, "token_count": 16, "parameters": [ "ext", "build_dir" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "nloc": 50, "complexity": 8, "token_count": 288, "diff_parsed": { "added": [ " #blas_info = {}", " def get_dotblas_sources(ext, build_dir):", " if blas_info:", " return ext.depends", " return None # no extension module will be built", "", " config.add_extension('_dotblas',", " sources = [get_dotblas_sources],", " depends=[join('blasdot','_dotblas.c')],", " include_dirs = ['blasdot'],", " extra_info = blas_info", " )", " # Configure mtrand", " def get_lapack_lite_sources(ext, build_dir):", " if not lapack_info:", " print \"### Warning: Using unoptimized lapack ###\"", " return ext.depends", " else:", " return ext.depends[:1]", "", " config.add_extension('lapack_lite',", " sources = [get_lapack_lite_sources],", " depends=[join('lapack_lite', x) for x in \\", " ['lapack_litemodule.c',", " 'zlapack_lite.c', 'dlapack_lite.c',", " 'blas_lite.c', 'dlamch.c',", " 'f2c_lite.c']],", " extra_info = lapack_info", " )" ], "deleted": [ " #blas_info = 0", " if blas_info or 'sdist' in sys.argv:", " config.add_extension('_dotblas',", " sources=[join('blasdot','_dotblas.c')],", " **blas_info", " )", " #lapack_info = 0", " if not lapack_info or 'sdist' in sys.argv:", " # use C-sources provided", " print \"### Warning: Using unoptimized lapack ###\"", " config.add_extension('lapack_lite',", " sources=[join('lapack_lite', x) for x in \\", " ['lapack_litemodule.c',", " 'zlapack_lite.c', 'dlapack_lite.c',", " 'blas_lite.c', 'dlamch.c',", " 'f2c_lite.c']]", " )", " else:", " config.add_extension('lapack_lite',", " sources=[join('lapack_lite',", " 'lapack_litemodule.c')],", " **lapack_info)" ] } }, { "old_path": "scipy/distutils/misc_util.py", "new_path": "scipy/distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -524,14 +524,33 @@ def paths(self,*paths):\n \n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n+\n+ Keywords:\n+ include_dirs, define_macros, undef_macros,\n+ library_dirs, libraries, runtime_library_dirs,\n+ extra_objects, extra_compile_args, extra_link_args,\n+ export_symbols, swig_opts, depends, language,\n+ f2py_options, module_dirs\n+ extra_info - dict or list of dict of keywords to be\n+ appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n \n+ if ext_args.has_key('extra_info'):\n+ extra_info = ext_args['extra_info']\n+ del ext_args['extra_info']\n+ if type(extra_info) is type({}):\n+ extra_info = [extra_info]\n+ for info in extra_info:\n+ assert type(info) is type({}),`info`\n+ dict_append(ext_args,**info)\n+\n for k in ext_args.keys():\n v = ext_args[k]\n- if k in ['sources','depends']:\n+ if k in ['sources','depends','include_dirs','library_dirs',\n+ 'module_dirs','extra_objects']:\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n \n", "added_lines": 20, "deleted_lines": 1, "source_code": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport types\nimport glob\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" Return path of the module.\n\n Returned path is relative to parent_path when given,\n otherwise it is absolute path.\n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n __import__(mod_name)\n mod = sys.modules[mod_name]\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d or '.'\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if type(item) is not types.StringType:\n return False\n return True\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob.glob(os.path.join(dir,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if type(directory) is not type(''):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef _gsf_visit_func(filenames,dirname,names):\n if os.path.basename(dirname) in ['CVS','.svn','build']:\n names[:] = []\n return\n for name in names:\n if name[-1] in \"~#\":\n continue\n fullname = os.path.join(dirname,name)\n ext = os.path.splitext(fullname)[1]\n if ext and ext in ['.pyc','.o']:\n continue\n if os.path.isfile(fullname):\n filenames.append(fullname)\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(lambda s:type(s) is types.StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(lambda s:type(s) is types.StringType,scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(lambda s:type(s) is types.StringType,sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = build_info.get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if type(data) is types.StringType:\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n s = s()\n if s is None:\n continue\n if is_local_src_dir(s):\n os.path.walk(s,_gsf_visit_func,filenames)\n elif type(s) is type('') and os.path.isfile(s):\n filenames.append(s)\n else:\n raise TypeError,`s`\n return filenames\n\ndef dot_join(*args):\n return '.'.join(filter(None,args))\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration:\n\n _list_keys = ['packages','ext_modules','data_files','include_dirs',\n 'libraries','headers','scripts']\n _dict_keys = ['package_dir']\n\n scipy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(1)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n \n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(os.path.join(self.local_path,package_path)):\n package_path = os.path.join(self.local_path,package_path)\n self.top_path = top_path\n\n self.list_keys = copy.copy(self._list_keys)\n self.dict_keys = copy.copy(self._dict_keys)\n\n for n in self.list_keys:\n setattr(self,n,copy.copy(attrs.get(n,[])))\n\n for n in self.dict_keys:\n setattr(self,n,copy.copy(attrs.get(n,{})))\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if type(a) is types.ListType:\n self.list_keys.append(n)\n elif type(a) is types.DictType:\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(os.path.join(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path \n return\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def __dict__(self):\n return self.todict()\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution \n return dist\n\n def get_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Return subpackage configuration.\n \"\"\"\n if subpackage_name is None:\n assert subpackage_path is not None\n subpackage_name = os.path.basename(subpackage_path)\n assert '.' not in subpackage_name,`subpackage_name`\n if subpackage_path is None:\n subpackage_path = os.path.join(self.local_path,subpackage_name)\n else:\n subpackage_path = self._fix_paths([subpackage_path])[0]\n\n setup_py = os.path.join(subpackage_path,'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n setup_py = os.path.join(subpackage_path,'setup.py')\n if not os.path.isfile(setup_py):\n print 'Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py),subpackage_name)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n info = (open(setup_py),setup_py,('.py','U',1))\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),*info)\n\n if not hasattr(setup_module,'configuration'):\n print 'Assuming default configuration '\\\n '(%s does not define configuration())' % (setup_module)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n args = (self.name,)\n if setup_module.configuration.func_code.co_argcount>1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n\n finally:\n del sys.path[0]\n\n return config\n\n def add_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n config = self.get_subpackage(subpackage_name,subpackage_path)\n\n if not config:\n print 'No configuration returned, assuming unavailable.'\n else:\n\n if isinstance(config,Configuration):\n print 'Appending %s configuration to %s' % (config.name,self.name)\n self.dict_append(**config.todict())\n else:\n print 'Appending %s configuration to %s' % (config.get('name'),self.name)\n self.dict_append(**config)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a subpackage', subpackage_name\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Add files under data_path to data_files list.\n \"\"\"\n for path in self.paths(data_path):\n filenames = []\n os.path.walk(path, _gsf_visit_func,filenames)\n if not os.path.isabs(path):\n self.add_data_files((path,filenames))\n else:\n self.add_data_files(*filenames)\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir suffix defaults\n to package dir.\n If path is not absolute then it's datadir suffix is\n package dir + dirname of the path.\n \"\"\"\n data_dict = {}\n for p in files:\n if type(p) is type(''):\n d = os.path.join(*(self.name.split('.')))\n file_list = self.paths(p)\n if not os.path.isabs(p):\n d = appendpath(d,os.path.dirname(p))\n elif type(p) is type(()):\n assert len(p)==2,`p`\n d = p[0]\n if type(p[1]) is type(''):\n file_list = self.paths(p[1])\n else:\n file_list = self.paths(*p[1])\n else:\n # function\n d = os.path.join(*(self.name.split('.')))\n file_list = [p]\n if not data_dict.has_key(d):\n data_dict[d] = file_list[:]\n else:\n data_dict[d].extend(file_list)\n\n dist = self.get_distribution()\n if dist is not None:\n dist.data_files.extend(data_dict.items())\n else:\n self.data_files.extend(data_dict.items())\n\n return \n \n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self._fix_paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if type(path) is type(''):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n assert type(path) in [type(()),type([])] and len(path)==2,`path`\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def _fix_paths(self,paths):\n new_paths = []\n for n in paths:\n if isinstance(n,str):\n if '*' in n or '?' in n:\n p = glob.glob(n)\n p2 = glob.glob(os.path.join(self.local_path,n))\n if p2:\n new_paths.extend(p2)\n elif p:\n new_paths.extend(p)\n else:\n new_paths.append(n)\n else:\n n2 = os.path.join(self.local_path,n)\n if os.path.exists(n2):\n new_paths.append(n2)\n else:\n new_paths.append(n)\n else:\n new_paths.append(n)\n return new_paths\n\n def paths(self,*paths):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n return self._fix_paths(paths)\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if type(extra_info) is type({}):\n extra_info = [extra_info]\n for info in extra_info:\n assert type(info) is type({}),`info`\n dict_append(ext_args,**info)\n\n for k in ext_args.keys():\n v = ext_args[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(os.path.join(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from scipy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add an extension', name\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n \n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name + '__OF__' + self.name\n build_info['sources'] = sources\n\n for k in build_info.keys():\n v = build_info[k]\n if k in ['sources','depends']:\n new_v = self._fix_paths(v)\n build_info[k] = new_v\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a library', name\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self._fix_paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n print 'Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?'))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %r\\n' % (k,a)\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if type(extlib) is type(()):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from scipy.distutils.core import Extension\n assert isinstance(extlib,Extension),`extlib`\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = os.path.join(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = os.path.join(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n print msg\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = os.path.join(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n print 'Creating %s (version=%r)' % (target,version)\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n \n import atexit\n def rm_file(f=target):\n try: os.remove(f); print 'removed',f\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(generate_svn_version_py)\n return\n\ndef get_cmd(cmdname,_cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError,\\\n 'setup distribution instance not initialized'\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_scipy_include_dirs():\n include_dirs = Configuration.scipy_include_dirs[:]\n if not include_dirs:\n import scipy.base as base\n include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))\n #from distutils.sysconfig import get_python_inc\n #prefix = []\n #for name in scipy.__file__.split(os.sep):\n # if name=='lib':\n # break\n # prefix.append(name)\n #include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n return include_dirs\n\n#########################\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n if os.path.join(absprefix[:len(d)],absprefix[len(d):])!=absprefix \\\n or os.path.join(path[:len(d)],path[len(d):])!=path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(os.path.join(prefix, subpath))\n\ndef generate_config_py(extension, build_dir):\n \"\"\" Generate /config.py file containing system_info\n information used during building the package.\n\n Usage:\\\n ext = Extension(dot_join(config['name'],'config'),\n sources=[generate_config_py])\n config['ext_modules'].append(ext)\n \"\"\"\n from scipy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n target = os.path.join(*([build_dir]+extension.name.split('.'))) + '.py'\n mkpath(os.path.dirname(target))\n f = open(target,'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k,i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k,i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n\ndef generate_svn_version_py(extension, build_dir):\n \"\"\" Generate __svn_version__.py file containing SVN\n revision number of a module.\n \n To use, add the following codelet to setup\n configuration(..) function\n\n ext = Extension(dot_join(config['name'],'__svn_version__'),\n sources=[generate_svn_version_py])\n ext.local_path = local_path\n config['ext_modules'].append(ext)\n\n \"\"\"\n from distutils import dep_util\n local_path = extension.local_path\n target = os.path.join(build_dir, '__svn_version__.py')\n entries = os.path.join(local_path,'.svn','entries')\n if os.path.isfile(entries):\n if not dep_util.newer(entries, target):\n return target\n elif os.path.isfile(target):\n return target\n\n revision = get_svn_revision(local_path)\n f = open(target,'w')\n f.write('revision=%s\\n' % (revision))\n f.close()\n return target\n", "source_code_before": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport types\nimport glob\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" Return path of the module.\n\n Returned path is relative to parent_path when given,\n otherwise it is absolute path.\n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n __import__(mod_name)\n mod = sys.modules[mod_name]\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d or '.'\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if type(item) is not types.StringType:\n return False\n return True\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob.glob(os.path.join(dir,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if type(directory) is not type(''):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef _gsf_visit_func(filenames,dirname,names):\n if os.path.basename(dirname) in ['CVS','.svn','build']:\n names[:] = []\n return\n for name in names:\n if name[-1] in \"~#\":\n continue\n fullname = os.path.join(dirname,name)\n ext = os.path.splitext(fullname)[1]\n if ext and ext in ['.pyc','.o']:\n continue\n if os.path.isfile(fullname):\n filenames.append(fullname)\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(lambda s:type(s) is types.StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(lambda s:type(s) is types.StringType,scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(lambda s:type(s) is types.StringType,sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = build_info.get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if type(data) is types.StringType:\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n s = s()\n if s is None:\n continue\n if is_local_src_dir(s):\n os.path.walk(s,_gsf_visit_func,filenames)\n elif type(s) is type('') and os.path.isfile(s):\n filenames.append(s)\n else:\n raise TypeError,`s`\n return filenames\n\ndef dot_join(*args):\n return '.'.join(filter(None,args))\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration:\n\n _list_keys = ['packages','ext_modules','data_files','include_dirs',\n 'libraries','headers','scripts']\n _dict_keys = ['package_dir']\n\n scipy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(1)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n \n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(os.path.join(self.local_path,package_path)):\n package_path = os.path.join(self.local_path,package_path)\n self.top_path = top_path\n\n self.list_keys = copy.copy(self._list_keys)\n self.dict_keys = copy.copy(self._dict_keys)\n\n for n in self.list_keys:\n setattr(self,n,copy.copy(attrs.get(n,[])))\n\n for n in self.dict_keys:\n setattr(self,n,copy.copy(attrs.get(n,{})))\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if type(a) is types.ListType:\n self.list_keys.append(n)\n elif type(a) is types.DictType:\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(os.path.join(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path \n return\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def __dict__(self):\n return self.todict()\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution \n return dist\n\n def get_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Return subpackage configuration.\n \"\"\"\n if subpackage_name is None:\n assert subpackage_path is not None\n subpackage_name = os.path.basename(subpackage_path)\n assert '.' not in subpackage_name,`subpackage_name`\n if subpackage_path is None:\n subpackage_path = os.path.join(self.local_path,subpackage_name)\n else:\n subpackage_path = self._fix_paths([subpackage_path])[0]\n\n setup_py = os.path.join(subpackage_path,'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n setup_py = os.path.join(subpackage_path,'setup.py')\n if not os.path.isfile(setup_py):\n print 'Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py),subpackage_name)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n info = (open(setup_py),setup_py,('.py','U',1))\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),*info)\n\n if not hasattr(setup_module,'configuration'):\n print 'Assuming default configuration '\\\n '(%s does not define configuration())' % (setup_module)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n args = (self.name,)\n if setup_module.configuration.func_code.co_argcount>1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n\n finally:\n del sys.path[0]\n\n return config\n\n def add_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n config = self.get_subpackage(subpackage_name,subpackage_path)\n\n if not config:\n print 'No configuration returned, assuming unavailable.'\n else:\n\n if isinstance(config,Configuration):\n print 'Appending %s configuration to %s' % (config.name,self.name)\n self.dict_append(**config.todict())\n else:\n print 'Appending %s configuration to %s' % (config.get('name'),self.name)\n self.dict_append(**config)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a subpackage', subpackage_name\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Add files under data_path to data_files list.\n \"\"\"\n for path in self.paths(data_path):\n filenames = []\n os.path.walk(path, _gsf_visit_func,filenames)\n if not os.path.isabs(path):\n self.add_data_files((path,filenames))\n else:\n self.add_data_files(*filenames)\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir suffix defaults\n to package dir.\n If path is not absolute then it's datadir suffix is\n package dir + dirname of the path.\n \"\"\"\n data_dict = {}\n for p in files:\n if type(p) is type(''):\n d = os.path.join(*(self.name.split('.')))\n file_list = self.paths(p)\n if not os.path.isabs(p):\n d = appendpath(d,os.path.dirname(p))\n elif type(p) is type(()):\n assert len(p)==2,`p`\n d = p[0]\n if type(p[1]) is type(''):\n file_list = self.paths(p[1])\n else:\n file_list = self.paths(*p[1])\n else:\n # function\n d = os.path.join(*(self.name.split('.')))\n file_list = [p]\n if not data_dict.has_key(d):\n data_dict[d] = file_list[:]\n else:\n data_dict[d].extend(file_list)\n\n dist = self.get_distribution()\n if dist is not None:\n dist.data_files.extend(data_dict.items())\n else:\n self.data_files.extend(data_dict.items())\n\n return \n \n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self._fix_paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if type(path) is type(''):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n assert type(path) in [type(()),type([])] and len(path)==2,`path`\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def _fix_paths(self,paths):\n new_paths = []\n for n in paths:\n if isinstance(n,str):\n if '*' in n or '?' in n:\n p = glob.glob(n)\n p2 = glob.glob(os.path.join(self.local_path,n))\n if p2:\n new_paths.extend(p2)\n elif p:\n new_paths.extend(p)\n else:\n new_paths.append(n)\n else:\n n2 = os.path.join(self.local_path,n)\n if os.path.exists(n2):\n new_paths.append(n2)\n else:\n new_paths.append(n)\n else:\n new_paths.append(n)\n return new_paths\n\n def paths(self,*paths):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n return self._fix_paths(paths)\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n for k in ext_args.keys():\n v = ext_args[k]\n if k in ['sources','depends']:\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(os.path.join(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from scipy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add an extension', name\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n \n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name + '__OF__' + self.name\n build_info['sources'] = sources\n\n for k in build_info.keys():\n v = build_info[k]\n if k in ['sources','depends']:\n new_v = self._fix_paths(v)\n build_info[k] = new_v\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a library', name\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self._fix_paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n print 'Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?'))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %r\\n' % (k,a)\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if type(extlib) is type(()):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from scipy.distutils.core import Extension\n assert isinstance(extlib,Extension),`extlib`\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = os.path.join(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = os.path.join(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n print msg\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = os.path.join(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n print 'Creating %s (version=%r)' % (target,version)\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n \n import atexit\n def rm_file(f=target):\n try: os.remove(f); print 'removed',f\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(generate_svn_version_py)\n return\n\ndef get_cmd(cmdname,_cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError,\\\n 'setup distribution instance not initialized'\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_scipy_include_dirs():\n include_dirs = Configuration.scipy_include_dirs[:]\n if not include_dirs:\n import scipy.base as base\n include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))\n #from distutils.sysconfig import get_python_inc\n #prefix = []\n #for name in scipy.__file__.split(os.sep):\n # if name=='lib':\n # break\n # prefix.append(name)\n #include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n return include_dirs\n\n#########################\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n if os.path.join(absprefix[:len(d)],absprefix[len(d):])!=absprefix \\\n or os.path.join(path[:len(d)],path[len(d):])!=path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(os.path.join(prefix, subpath))\n\ndef generate_config_py(extension, build_dir):\n \"\"\" Generate /config.py file containing system_info\n information used during building the package.\n\n Usage:\\\n ext = Extension(dot_join(config['name'],'config'),\n sources=[generate_config_py])\n config['ext_modules'].append(ext)\n \"\"\"\n from scipy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n target = os.path.join(*([build_dir]+extension.name.split('.'))) + '.py'\n mkpath(os.path.dirname(target))\n f = open(target,'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k,i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k,i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n\ndef generate_svn_version_py(extension, build_dir):\n \"\"\" Generate __svn_version__.py file containing SVN\n revision number of a module.\n \n To use, add the following codelet to setup\n configuration(..) function\n\n ext = Extension(dot_join(config['name'],'__svn_version__'),\n sources=[generate_svn_version_py])\n ext.local_path = local_path\n config['ext_modules'].append(ext)\n\n \"\"\"\n from distutils import dep_util\n local_path = extension.local_path\n target = os.path.join(build_dir, '__svn_version__.py')\n entries = os.path.join(local_path,'.svn','entries')\n if os.path.isfile(entries):\n if not dep_util.newer(entries, target):\n return target\n elif os.path.isfile(target):\n return target\n\n revision = get_svn_revision(local_path)\n f = open(target,'w')\n f.write('revision=%s\\n' % (revision))\n f.close()\n return target\n", "methods": [ { "name": "allpath", "long_name": "allpath( name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "name" ], "start_line": 9, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 129, "parameters": [ "mod_name", "parent_path" ], "start_line": 14, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 38, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "cyg2win32", "long_name": "cyg2win32( path )", "filename": "misc_util.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "path" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_get_f90_modules", "long_name": "_get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "all_strings", "long_name": "all_strings( lst )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [ "lst" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 117, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 124, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 131, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_get_headers", "long_name": "_get_headers( directory_list )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "directory_list" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_get_directories", "long_name": "_get_directories( list_of_sources )", "filename": "misc_util.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 162, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_dependencies", "long_name": "get_dependencies( sources )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "sources" ], "start_line": 171, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "misc_util.py", "nloc": 12, "complexity": 6, "token_count": 112, "parameters": [ "directory" ], "start_line": 175, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "_gsf_visit_func", "long_name": "_gsf_visit_func( filenames , dirname , names )", "filename": "misc_util.py", "nloc": 13, "complexity": 7, "token_count": 103, "parameters": [ "filenames", "dirname", "names" ], "start_line": 190, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_ext_source_files", "long_name": "get_ext_source_files( ext )", "filename": "misc_util.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "ext" ], "start_line": 204, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "get_script_files", "long_name": "get_script_files( scripts )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "scripts" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_lib_source_files", "long_name": "get_lib_source_files( lib )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 108, "parameters": [ "lib" ], "start_line": 221, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_data_files", "long_name": "get_data_files( data )", "filename": "misc_util.py", "nloc": 17, "complexity": 8, "token_count": 105, "parameters": [ "data" ], "start_line": 235, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "args" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 256, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , ** attrs )", "filename": "misc_util.py", "nloc": 40, "complexity": 11, "token_count": 335, "parameters": [ "self", "package_name", "parent_name", "top_path", "package_path", "attrs" ], "start_line": 275, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 1 }, { "name": "todict", "long_name": "todict( self )", "filename": "misc_util.py", "nloc": 9, "complexity": 4, "token_count": 57, "parameters": [ "self" ], "start_line": 325, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__dict__", "long_name": "__dict__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_distribution", "long_name": "get_distribution( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 341, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_subpackage", "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 38, "complexity": 8, "token_count": 333, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 346, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "add_subpackage", "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 392, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "add_data_dir", "long_name": "add_data_dir( self , data_path )", "filename": "misc_util.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "data_path" ], "start_line": 413, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "add_data_files", "long_name": "add_data_files( self , * files )", "filename": "misc_util.py", "nloc": 28, "complexity": 8, "token_count": 247, "parameters": [ "self", "files" ], "start_line": 425, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "add_include_dirs", "long_name": "add_include_dirs( self , * paths )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "paths" ], "start_line": 465, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "add_headers", "long_name": "add_headers( self , * files )", "filename": "misc_util.py", "nloc": 14, "complexity": 7, "token_count": 143, "parameters": [ "self", "files" ], "start_line": 476, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_fix_paths", "long_name": "_fix_paths( self , paths )", "filename": "misc_util.py", "nloc": 22, "complexity": 8, "token_count": 136, "parameters": [ "self", "paths" ], "start_line": 497, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "paths", "long_name": "paths( self , * paths )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "paths" ], "start_line": 520, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 45, "complexity": 14, "token_count": 365, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 588, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , name , sources , ** build_info )", "filename": "misc_util.py", "nloc": 14, "complexity": 4, "token_count": 104, "parameters": [ "self", "name", "sources", "build_info" ], "start_line": 590, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "add_scripts", "long_name": "add_scripts( self , * files )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "files" ], "start_line": 616, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "dict_append", "long_name": "dict_append( self , ** dict )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 138, "parameters": [ "self", "dict" ], "start_line": 627, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 643, "end_line": 652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_config_cmd", "long_name": "get_config_cmd( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 2, "token_count": 63, "parameters": [ "self" ], "start_line": 654, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_build_temp_dir", "long_name": "get_build_temp_dir( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 665, "end_line": 668, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "have_f77c", "long_name": "have_f77c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 670, "end_line": 681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "have_f90c", "long_name": "have_f90c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 683, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "append_to", "long_name": "append_to( self , extlib )", "filename": "misc_util.py", "nloc": 12, "complexity": 2, "token_count": 83, "parameters": [ "self", "extlib" ], "start_line": 696, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_get_svn_revision", "long_name": "_get_svn_revision( self , path )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 77, "parameters": [ "self", "path" ], "start_line": 711, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "misc_util.py", "nloc": 38, "complexity": 11, "token_count": 257, "parameters": [ "self" ], "start_line": 724, "end_line": 770, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target )", "filename": "misc_util.py", "nloc": 3, "complexity": 2, "token_count": 24, "parameters": [ "f" ], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 3 }, { "name": "make_svn_version_py.generate_svn_version_py", "long_name": "make_svn_version_py.generate_svn_version_py( )", "filename": "misc_util.py", "nloc": 13, "complexity": 2, "token_count": 81, "parameters": [], "start_line": 783, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 2 }, { "name": "make_svn_version_py", "long_name": "make_svn_version_py( self )", "filename": "misc_util.py", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 772, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_cmd", "long_name": "get_cmd( cmdname , _cache = { } )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 65, "parameters": [ "cmdname", "_cache" ], "start_line": 804, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "get_scipy_include_dirs", "long_name": "get_scipy_include_dirs( )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [], "start_line": 816, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 832, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "misc_util.py", "nloc": 13, "complexity": 5, "token_count": 157, "parameters": [ "prefix", "path" ], "start_line": 839, "end_line": 852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "generate_config_py", "long_name": "generate_config_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 28, "complexity": 2, "token_count": 145, "parameters": [ "extension", "build_dir" ], "start_line": 854, "end_line": 890, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "generate_svn_version_py", "long_name": "generate_svn_version_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 109, "parameters": [ "extension", "build_dir" ], "start_line": 892, "end_line": 919, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "methods_before": [ { "name": "allpath", "long_name": "allpath( name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "name" ], "start_line": 9, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 129, "parameters": [ "mod_name", "parent_path" ], "start_line": 14, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 38, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "cyg2win32", "long_name": "cyg2win32( path )", "filename": "misc_util.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "path" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_get_f90_modules", "long_name": "_get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "all_strings", "long_name": "all_strings( lst )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [ "lst" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 117, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 124, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 131, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_get_headers", "long_name": "_get_headers( directory_list )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "directory_list" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_get_directories", "long_name": "_get_directories( list_of_sources )", "filename": "misc_util.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 162, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_dependencies", "long_name": "get_dependencies( sources )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "sources" ], "start_line": 171, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "misc_util.py", "nloc": 12, "complexity": 6, "token_count": 112, "parameters": [ "directory" ], "start_line": 175, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "_gsf_visit_func", "long_name": "_gsf_visit_func( filenames , dirname , names )", "filename": "misc_util.py", "nloc": 13, "complexity": 7, "token_count": 103, "parameters": [ "filenames", "dirname", "names" ], "start_line": 190, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_ext_source_files", "long_name": "get_ext_source_files( ext )", "filename": "misc_util.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "ext" ], "start_line": 204, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "get_script_files", "long_name": "get_script_files( scripts )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "scripts" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_lib_source_files", "long_name": "get_lib_source_files( lib )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 108, "parameters": [ "lib" ], "start_line": 221, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_data_files", "long_name": "get_data_files( data )", "filename": "misc_util.py", "nloc": 17, "complexity": 8, "token_count": 105, "parameters": [ "data" ], "start_line": 235, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "args" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 256, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , ** attrs )", "filename": "misc_util.py", "nloc": 40, "complexity": 11, "token_count": 335, "parameters": [ "self", "package_name", "parent_name", "top_path", "package_path", "attrs" ], "start_line": 275, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 1 }, { "name": "todict", "long_name": "todict( self )", "filename": "misc_util.py", "nloc": 9, "complexity": 4, "token_count": 57, "parameters": [ "self" ], "start_line": 325, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__dict__", "long_name": "__dict__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_distribution", "long_name": "get_distribution( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 341, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_subpackage", "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 38, "complexity": 8, "token_count": 333, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 346, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "add_subpackage", "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 392, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "add_data_dir", "long_name": "add_data_dir( self , data_path )", "filename": "misc_util.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "data_path" ], "start_line": 413, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "add_data_files", "long_name": "add_data_files( self , * files )", "filename": "misc_util.py", "nloc": 28, "complexity": 8, "token_count": 247, "parameters": [ "self", "files" ], "start_line": 425, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "add_include_dirs", "long_name": "add_include_dirs( self , * paths )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "paths" ], "start_line": 465, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "add_headers", "long_name": "add_headers( self , * files )", "filename": "misc_util.py", "nloc": 14, "complexity": 7, "token_count": 143, "parameters": [ "self", "files" ], "start_line": 476, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_fix_paths", "long_name": "_fix_paths( self , paths )", "filename": "misc_util.py", "nloc": 22, "complexity": 8, "token_count": 136, "parameters": [ "self", "paths" ], "start_line": 497, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "paths", "long_name": "paths( self , * paths )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "paths" ], "start_line": 520, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 36, "complexity": 11, "token_count": 294, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , name , sources , ** build_info )", "filename": "misc_util.py", "nloc": 14, "complexity": 4, "token_count": 104, "parameters": [ "self", "name", "sources", "build_info" ], "start_line": 571, "end_line": 595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "add_scripts", "long_name": "add_scripts( self , * files )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "files" ], "start_line": 597, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "dict_append", "long_name": "dict_append( self , ** dict )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 138, "parameters": [ "self", "dict" ], "start_line": 608, "end_line": 622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 624, "end_line": 633, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_config_cmd", "long_name": "get_config_cmd( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 2, "token_count": 63, "parameters": [ "self" ], "start_line": 635, "end_line": 644, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_build_temp_dir", "long_name": "get_build_temp_dir( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 646, "end_line": 649, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "have_f77c", "long_name": "have_f77c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 651, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "have_f90c", "long_name": "have_f90c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 664, "end_line": 675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "append_to", "long_name": "append_to( self , extlib )", "filename": "misc_util.py", "nloc": 12, "complexity": 2, "token_count": 83, "parameters": [ "self", "extlib" ], "start_line": 677, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_get_svn_revision", "long_name": "_get_svn_revision( self , path )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 77, "parameters": [ "self", "path" ], "start_line": 692, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "misc_util.py", "nloc": 38, "complexity": 11, "token_count": 257, "parameters": [ "self" ], "start_line": 705, "end_line": 751, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target )", "filename": "misc_util.py", "nloc": 3, "complexity": 2, "token_count": 24, "parameters": [ "f" ], "start_line": 775, "end_line": 777, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 3 }, { "name": "make_svn_version_py.generate_svn_version_py", "long_name": "make_svn_version_py.generate_svn_version_py( )", "filename": "misc_util.py", "nloc": 13, "complexity": 2, "token_count": 81, "parameters": [], "start_line": 764, "end_line": 780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 2 }, { "name": "make_svn_version_py", "long_name": "make_svn_version_py( self )", "filename": "misc_util.py", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 753, "end_line": 783, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_cmd", "long_name": "get_cmd( cmdname , _cache = { } )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 65, "parameters": [ "cmdname", "_cache" ], "start_line": 785, "end_line": 795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "get_scipy_include_dirs", "long_name": "get_scipy_include_dirs( )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [], "start_line": 797, "end_line": 809, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 813, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "misc_util.py", "nloc": 13, "complexity": 5, "token_count": 157, "parameters": [ "prefix", "path" ], "start_line": 820, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "generate_config_py", "long_name": "generate_config_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 28, "complexity": 2, "token_count": 145, "parameters": [ "extension", "build_dir" ], "start_line": 835, "end_line": 871, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "generate_svn_version_py", "long_name": "generate_svn_version_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 109, "parameters": [ "extension", "build_dir" ], "start_line": 873, "end_line": 900, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 45, "complexity": 14, "token_count": 365, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 588, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 } ], "nloc": 681, "complexity": 215, "token_count": 5035, "diff_parsed": { "added": [ "", " Keywords:", " include_dirs, define_macros, undef_macros,", " library_dirs, libraries, runtime_library_dirs,", " extra_objects, extra_compile_args, extra_link_args,", " export_symbols, swig_opts, depends, language,", " f2py_options, module_dirs", " extra_info - dict or list of dict of keywords to be", " appended to keywords.", " if ext_args.has_key('extra_info'):", " extra_info = ext_args['extra_info']", " del ext_args['extra_info']", " if type(extra_info) is type({}):", " extra_info = [extra_info]", " for info in extra_info:", " assert type(info) is type({}),`info`", " dict_append(ext_args,**info)", "", " if k in ['sources','depends','include_dirs','library_dirs',", " 'module_dirs','extra_objects']:" ], "deleted": [ " if k in ['sources','depends']:" ] } } ] }, { "hash": "4219df8d953ab55793f7a70aa8a93cc721fbd958", "msg": "r82@Blasphemy: kern | 2005-10-04 03:25:34 -0700\n defined(darwin) -> defined(__APPLE__); a similar change should happen in numarray, too", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-04T10:26:08+00:00", "author_timezone": 0, "committer_date": "2005-10-04T10:26:08+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d32f2d2362144efb664ee557637b466c8d950546" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/base/include/scipy/ufuncobject.h", "new_path": "scipy/base/include/scipy/ufuncobject.h", "filename": "ufuncobject.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -231,9 +231,9 @@ typedef struct {\n \t(void) fpsetsticky(0);\t\t\t\t\t\t\\\n \t}\n \t\n-#elif defined(linux) || defined(darwin) || defined(__CYGWIN__) || defined(__MINGW32__) \n+#elif defined(linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) \n \n-#if defined(__GLIBC__) || defined(darwin) || defined(__MINGW32__)\n+#if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__)\n #include \n #elif defined(__CYGWIN__)\n #include \n", "added_lines": 2, "deleted_lines": 2, "source_code": "#ifndef Py_UFUNCOBJECT_H\n#define Py_UFUNCOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define MAX_ARGS 40\n\ntypedef void (*PyUFuncGenericFunction) (char **, intp *, intp *, void *);\n\ntypedef struct {\n\tPyObject_HEAD\n\tint nin, nout, nargs;\n\tint identity;\n\tPyUFuncGenericFunction *functions;\n\tvoid **data;\n\tint ntypes;\n\tint check_return;\n\tchar *name, *types;\n\tchar *doc;\n void *ptr;\n PyObject *obj;\n\tPyObject *userloops;\n} PyUFuncObject;\n\n#include \"arrayobject.h\"\n\n#define UFUNC_ERR_IGNORE 0\n#define UFUNC_ERR_WARN 1\n#define UFUNC_ERR_RAISE 2\n#define UFUNC_ERR_CALL 3\n\n\t/* Python side integer mask */\n\n#define UFUNC_MASK_DIVIDEBYZERO 0x03\n#define UFUNC_MASK_OVERFLOW 0x0c\n#define UFUNC_MASK_UNDERFLOW 0x30\n#define UFUNC_MASK_INVALID 0xc0\n\n#define UFUNC_SHIFT_DIVIDEBYZERO 0\n#define UFUNC_SHIFT_OVERFLOW 2\n#define UFUNC_SHIFT_UNDERFLOW 4\n#define UFUNC_SHIFT_INVALID 6 \n\n\n/* platform-dependent code translates floating point\n status to an integer sum of these values\n*/\n#define UFUNC_FPE_DIVIDEBYZERO 1\n#define UFUNC_FPE_OVERFLOW 2\n#define UFUNC_FPE_UNDERFLOW 4\n#define UFUNC_FPE_INVALID 8\n\t\n#define UFUNC_ERR_DEFAULT 0 /* Default error mode */\n\n\t/* Only internal -- not exported, yet*/\ntypedef struct {\n\t/* Multi-iterator portion --- needs to be present in this order \n\t to work with PyArray_Broadcast */\n\tPyObject_HEAD\n\tint numiter;\n\tintp size; \n\tintp index; \n\tint nd;\n\tintp dimensions[MAX_DIMS];\t\n\tPyArrayIterObject *iters[MAX_ARGS];\n /* End of Multi-iterator portion */\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\t\n\t/* The error handling */\n\tint errormask; /* Integer showing desired error handling */\n\tPyObject *errobj; /* currently a tuple with \n\t\t\t\t (string, func or None)\n\t\t\t */\n\n\t/* Specific function and data to use */\n\tPyUFuncGenericFunction function;\n\tvoid *funcdata;\n\n\t/* Loop method */\n\tint meth;\n\t\n\t/* Whether or not to swap */\n\tint swap[MAX_ARGS];\n\n\t/* Buffers for the loop */\n\tvoid *buffer[MAX_ARGS];\n\tint bufsize;\n\tint bufcnt;\n\tvoid *dptr[MAX_ARGS];\n\n\t/* For casting */\n\tvoid *castbuf[MAX_ARGS];\n\tPyArray_VectorUnaryFunc *cast[MAX_ARGS];\n\n\t/* usually points to buffer but when a cast is to be\n\t done it switches for that argument to castbuf.\n\t*/\n\tvoid *bufptr[MAX_ARGS]; \n\n\t/* Steps filled in from iters or sizeof(item)\n\t depending on loop method. \n\t*/\n\tintp steps[MAX_ARGS];\n\n\t\n} PyUFuncLoopObject;\n\n/* Could make this more clever someday */\n#define UFUNC_MAXIDENTITY 32\n\ntypedef struct {\n PyObject_HEAD\n PyArrayIterObject *it;\n PyArrayObject *ret;\n\tPyArrayIterObject *rit; /* Needed for Accumulate */\n int outsize;\n\tintp index;\n\tintp size;\n char idptr[UFUNC_MAXIDENTITY];\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\n\t/* The error handling */\n\tint errormask;\n\tPyObject *errobj;\n \n PyUFuncGenericFunction function;\n void *funcdata; \n int meth;\n int swap;\n \n void *buffer;\n int bufsize;\n\n void *castbuf;\n PyArray_VectorUnaryFunc *cast;\n\n void *bufptr[3];\n intp steps[3];\n\n intp N;\n int instrides;\n int insize;\n char *inptr;\n\n\t/* For copying small arrays */\n\tPyObject *decref;\n \n} PyUFuncReduceObject;\n\n#define PyUFunc_Unbounded 120\n#define PyUFunc_One 1\n#define PyUFunc_Zero 0\n#define PyUFunc_None -1\n\n\ntypedef struct {\n int nin;\n int nout;\n PyObject *callable; \n} PyUFunc_PyFuncData;\n\n\n\n\n#include \"__ufunc_api.h\"\n\n#define UFUNC_ERRMASK_NAME \"_UFUNC_ERRMASK\"\n#define UFUNC_ERRFUNC_NAME \"_UFUNC_ERRFUNC\"\n#define UFUNC_BUFSIZE_NAME \"_UFUNC_BUFSIZE\"\n\n#define UFUNC_CHECK_ERROR() \\\n\tif (PyErr_Occurred() || (loop->errormask &&\t\t\t\\\n\t PyUFunc_checkfperr(loop->errormask,\t\t\t\t\\\n\t\t\t loop->errobj)))\t\t\t\t\\\n\t\tgoto fail\n\n/* This code checks the IEEE status flags in a platform-dependent way */\n/* Adapted from Numarray */\n\n/* OSF/Alpha (Tru64) ---------------------------------------------*/\n#if defined(__osf__) && defined(__alpha)\n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\\\n\tunsigned long fpstatus;\t\t \\\n\t\t\t\t\t\t\\\n\tfpstatus = ieee_get_fp_control();\t\t\t\t\\\n\t/* clear status bits as well as disable exception mode if on */ \\\n\tieee_set_fp_control( 0 );\t\t\t\t\t\\\n\tret = ((IEEE_STATUS_DZE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((IEEE_STATUS_OVF & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_UNF & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \\\n\t}\n\t\n/* MS Windows -----------------------------------------------------*/\n#elif defined(_MSC_VER) \n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t \\\n\tint fpstatus = (int) _clear87();\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\tret = ((SW_ZERODIVIDE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((SW_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((SW_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((SW_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t}\n\t\n\n/* Solaris --------------------------------------------------------*/\n/* --------ignoring SunOS ieee_flags approach, someone else can\n** deal with that! */\n#elif defined(sun)\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\t\t\\\n\tint fpstatus;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n\tfpstatus = (int) fpgetsticky();\t\t\t\t\t\\\n\tret = ((FP_X_DZ & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((FP_X_OFL & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_X_UFL & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((FP_X_INV & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) fpsetsticky(0);\t\t\t\t\t\t\\\n\t}\n\t\n#elif defined(linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) \n\n#if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__)\n#include \n#elif defined(__CYGWIN__)\n#include \n#endif\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tint fpstatus = (int) fetestexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\\\n\t\t\t\t\t FE_UNDERFLOW | FE_INVALID);\t\\\n\tret = ((FE_DIVBYZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FE_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FE_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FE_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) feclearexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\t\\\n\t\t\t FE_UNDERFLOW | FE_INVALID);\t\t\\\n}\n\n#define generate_divbyzero_error() feraiseexcept(FE_DIVBYZERO)\n#define generate_overflow_error() feraiseexcept(FE_OVERFLOW)\n\t\n#elif defined(AIX)\n\n#include \n#include \n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tfpflag_t fpstatus; \\\n \\\n\tfpstatus = fp_read_flag();\n\tret = ((FP_DIV_BY_ZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FP_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FP_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\n\tfp_clr_flag( FP_DIV_BY_ZERO | FP_OVERFLOW | FP_UNDERFLOW | FP_INVALID); \\\n}\n\n#else\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n printf(\"floating point flags not supported on this platform\\n\"); \\\n ret = 0;\t\t\t\t\t\t\t \\\n }\n\n#endif\n\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* !Py_UFUNCOBJECT_H */\n", "source_code_before": "#ifndef Py_UFUNCOBJECT_H\n#define Py_UFUNCOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define MAX_ARGS 40\n\ntypedef void (*PyUFuncGenericFunction) (char **, intp *, intp *, void *);\n\ntypedef struct {\n\tPyObject_HEAD\n\tint nin, nout, nargs;\n\tint identity;\n\tPyUFuncGenericFunction *functions;\n\tvoid **data;\n\tint ntypes;\n\tint check_return;\n\tchar *name, *types;\n\tchar *doc;\n void *ptr;\n PyObject *obj;\n\tPyObject *userloops;\n} PyUFuncObject;\n\n#include \"arrayobject.h\"\n\n#define UFUNC_ERR_IGNORE 0\n#define UFUNC_ERR_WARN 1\n#define UFUNC_ERR_RAISE 2\n#define UFUNC_ERR_CALL 3\n\n\t/* Python side integer mask */\n\n#define UFUNC_MASK_DIVIDEBYZERO 0x03\n#define UFUNC_MASK_OVERFLOW 0x0c\n#define UFUNC_MASK_UNDERFLOW 0x30\n#define UFUNC_MASK_INVALID 0xc0\n\n#define UFUNC_SHIFT_DIVIDEBYZERO 0\n#define UFUNC_SHIFT_OVERFLOW 2\n#define UFUNC_SHIFT_UNDERFLOW 4\n#define UFUNC_SHIFT_INVALID 6 \n\n\n/* platform-dependent code translates floating point\n status to an integer sum of these values\n*/\n#define UFUNC_FPE_DIVIDEBYZERO 1\n#define UFUNC_FPE_OVERFLOW 2\n#define UFUNC_FPE_UNDERFLOW 4\n#define UFUNC_FPE_INVALID 8\n\t\n#define UFUNC_ERR_DEFAULT 0 /* Default error mode */\n\n\t/* Only internal -- not exported, yet*/\ntypedef struct {\n\t/* Multi-iterator portion --- needs to be present in this order \n\t to work with PyArray_Broadcast */\n\tPyObject_HEAD\n\tint numiter;\n\tintp size; \n\tintp index; \n\tint nd;\n\tintp dimensions[MAX_DIMS];\t\n\tPyArrayIterObject *iters[MAX_ARGS];\n /* End of Multi-iterator portion */\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\t\n\t/* The error handling */\n\tint errormask; /* Integer showing desired error handling */\n\tPyObject *errobj; /* currently a tuple with \n\t\t\t\t (string, func or None)\n\t\t\t */\n\n\t/* Specific function and data to use */\n\tPyUFuncGenericFunction function;\n\tvoid *funcdata;\n\n\t/* Loop method */\n\tint meth;\n\t\n\t/* Whether or not to swap */\n\tint swap[MAX_ARGS];\n\n\t/* Buffers for the loop */\n\tvoid *buffer[MAX_ARGS];\n\tint bufsize;\n\tint bufcnt;\n\tvoid *dptr[MAX_ARGS];\n\n\t/* For casting */\n\tvoid *castbuf[MAX_ARGS];\n\tPyArray_VectorUnaryFunc *cast[MAX_ARGS];\n\n\t/* usually points to buffer but when a cast is to be\n\t done it switches for that argument to castbuf.\n\t*/\n\tvoid *bufptr[MAX_ARGS]; \n\n\t/* Steps filled in from iters or sizeof(item)\n\t depending on loop method. \n\t*/\n\tintp steps[MAX_ARGS];\n\n\t\n} PyUFuncLoopObject;\n\n/* Could make this more clever someday */\n#define UFUNC_MAXIDENTITY 32\n\ntypedef struct {\n PyObject_HEAD\n PyArrayIterObject *it;\n PyArrayObject *ret;\n\tPyArrayIterObject *rit; /* Needed for Accumulate */\n int outsize;\n\tintp index;\n\tintp size;\n char idptr[UFUNC_MAXIDENTITY];\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\n\t/* The error handling */\n\tint errormask;\n\tPyObject *errobj;\n \n PyUFuncGenericFunction function;\n void *funcdata; \n int meth;\n int swap;\n \n void *buffer;\n int bufsize;\n\n void *castbuf;\n PyArray_VectorUnaryFunc *cast;\n\n void *bufptr[3];\n intp steps[3];\n\n intp N;\n int instrides;\n int insize;\n char *inptr;\n\n\t/* For copying small arrays */\n\tPyObject *decref;\n \n} PyUFuncReduceObject;\n\n#define PyUFunc_Unbounded 120\n#define PyUFunc_One 1\n#define PyUFunc_Zero 0\n#define PyUFunc_None -1\n\n\ntypedef struct {\n int nin;\n int nout;\n PyObject *callable; \n} PyUFunc_PyFuncData;\n\n\n\n\n#include \"__ufunc_api.h\"\n\n#define UFUNC_ERRMASK_NAME \"_UFUNC_ERRMASK\"\n#define UFUNC_ERRFUNC_NAME \"_UFUNC_ERRFUNC\"\n#define UFUNC_BUFSIZE_NAME \"_UFUNC_BUFSIZE\"\n\n#define UFUNC_CHECK_ERROR() \\\n\tif (PyErr_Occurred() || (loop->errormask &&\t\t\t\\\n\t PyUFunc_checkfperr(loop->errormask,\t\t\t\t\\\n\t\t\t loop->errobj)))\t\t\t\t\\\n\t\tgoto fail\n\n/* This code checks the IEEE status flags in a platform-dependent way */\n/* Adapted from Numarray */\n\n/* OSF/Alpha (Tru64) ---------------------------------------------*/\n#if defined(__osf__) && defined(__alpha)\n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\\\n\tunsigned long fpstatus;\t\t \\\n\t\t\t\t\t\t\\\n\tfpstatus = ieee_get_fp_control();\t\t\t\t\\\n\t/* clear status bits as well as disable exception mode if on */ \\\n\tieee_set_fp_control( 0 );\t\t\t\t\t\\\n\tret = ((IEEE_STATUS_DZE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((IEEE_STATUS_OVF & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_UNF & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \\\n\t}\n\t\n/* MS Windows -----------------------------------------------------*/\n#elif defined(_MSC_VER) \n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t \\\n\tint fpstatus = (int) _clear87();\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\tret = ((SW_ZERODIVIDE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((SW_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((SW_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((SW_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t}\n\t\n\n/* Solaris --------------------------------------------------------*/\n/* --------ignoring SunOS ieee_flags approach, someone else can\n** deal with that! */\n#elif defined(sun)\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\t\t\\\n\tint fpstatus;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n\tfpstatus = (int) fpgetsticky();\t\t\t\t\t\\\n\tret = ((FP_X_DZ & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((FP_X_OFL & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_X_UFL & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((FP_X_INV & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) fpsetsticky(0);\t\t\t\t\t\t\\\n\t}\n\t\n#elif defined(linux) || defined(darwin) || defined(__CYGWIN__) || defined(__MINGW32__) \n\n#if defined(__GLIBC__) || defined(darwin) || defined(__MINGW32__)\n#include \n#elif defined(__CYGWIN__)\n#include \n#endif\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tint fpstatus = (int) fetestexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\\\n\t\t\t\t\t FE_UNDERFLOW | FE_INVALID);\t\\\n\tret = ((FE_DIVBYZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FE_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FE_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FE_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) feclearexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\t\\\n\t\t\t FE_UNDERFLOW | FE_INVALID);\t\t\\\n}\n\n#define generate_divbyzero_error() feraiseexcept(FE_DIVBYZERO)\n#define generate_overflow_error() feraiseexcept(FE_OVERFLOW)\n\t\n#elif defined(AIX)\n\n#include \n#include \n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tfpflag_t fpstatus; \\\n \\\n\tfpstatus = fp_read_flag();\n\tret = ((FP_DIV_BY_ZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FP_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FP_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\n\tfp_clr_flag( FP_DIV_BY_ZERO | FP_OVERFLOW | FP_UNDERFLOW | FP_INVALID); \\\n}\n\n#else\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n printf(\"floating point flags not supported on this platform\\n\"); \\\n ret = 0;\t\t\t\t\t\t\t \\\n }\n\n#endif\n\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* !Py_UFUNCOBJECT_H */\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 89, "complexity": 0, "token_count": 387, "diff_parsed": { "added": [ "#elif defined(linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__)", "#if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__)" ], "deleted": [ "#elif defined(linux) || defined(darwin) || defined(__CYGWIN__) || defined(__MINGW32__)", "#if defined(__GLIBC__) || defined(darwin) || defined(__MINGW32__)" ] } } ] }, { "hash": "ea0617129070f31f1d7e4eabb428a03f1cdb20cf", "msg": "r84@Blasphemy: kern | 2005-10-04 03:55:47 -0700\n methodize take() and shape() calls", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-04T13:06:37+00:00", "author_timezone": 0, "committer_date": "2005-10-04T13:06:37+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4219df8d953ab55793f7a70aa8a93cc721fbd958" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/base/shape_base.py", "new_path": "scipy/base/shape_base.py", "filename": "shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -26,7 +26,7 @@ def apply_along_axis(func1d,axis,arr,*args):\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n- outshape = take(shape(arr),indlist)\n+ outshape = asarray(arr.shape()).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i)],*args)\n # if res is a number, then we have a smaller output array\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape()).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i)],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i)] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[tuple(i)] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "source_code_before": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = take(shape(arr),indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i)],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i)] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[tuple(i)] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 406, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "methods_before": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 402, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 406, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 } ], "nloc": 196, "complexity": 57, "token_count": 1448, "diff_parsed": { "added": [ " outshape = asarray(arr.shape()).take(indlist)" ], "deleted": [ " outshape = take(shape(arr),indlist)" ] } } ] }, { "hash": "b4a71a6b8025fd4822a49166e051fc16563fc54d", "msg": "r85@Blasphemy: kern | 2005-10-04 03:56:27 -0700\n Ahem", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-04T13:06:44+00:00", "author_timezone": 0, "committer_date": "2005-10-04T13:06:44+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ea0617129070f31f1d7e4eabb428a03f1cdb20cf" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/base/shape_base.py", "new_path": "scipy/base/shape_base.py", "filename": "shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -26,7 +26,7 @@ def apply_along_axis(func1d,axis,arr,*args):\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n- outshape = asarray(arr.shape()).take(indlist)\n+ outshape = asarray(arr.shape).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i)],*args)\n # if res is a number, then we have a smaller output array\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i)],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i)] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[tuple(i)] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "source_code_before": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape()).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i)],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i)] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[tuple(i)] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 404, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "methods_before": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 406, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 404, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 } ], "nloc": 196, "complexity": 57, "token_count": 1446, "diff_parsed": { "added": [ " outshape = asarray(arr.shape).take(indlist)" ], "deleted": [ " outshape = asarray(arr.shape()).take(indlist)" ] } } ] }, { "hash": "77ec6f047995d7a473523feb4fc2a93b537d51c3", "msg": "Fixed object put bug..", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-05T07:07:39+00:00", "author_timezone": 0, "committer_date": "2005-10-05T07:07:39+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b4a71a6b8025fd4822a49166e051fc16563fc54d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 9, "insertions": 16, "lines": 25, "files": 5, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "MANIFEST.in", "new_path": "MANIFEST.in", "filename": "MANIFEST.in", "extension": "in", "change_type": "MODIFY", "diff": "@@ -8,6 +8,7 @@ include MANIFEST.in\n #recursive-include scipy/f2py2e/tests/mixed *.f *.f90\n ##recursive-include scipy/f2py2e/doc *.py *.txt *.tex *.html Makefile\n #recursive-include scipy/f2py2e/docs *.txt *.html *.dat *.f *.f90 *.pyf setup_example.py f2py_style.css\n+include scipy/corelib/blasdot/cblas.h\n recursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi\n prune scipy/base/include/scipy\n-recursive-include scipy/base/include/scipy *object.h\n\\ No newline at end of file\n+recursive-include scipy/base/include/scipy *object.h\n", "added_lines": 2, "deleted_lines": 1, "source_code": "recursive-include . *.txt\ninclude MANIFEST.in\n#include scipy/f2py2e/f2py.1\n#recursive-include scipy/f2py2e *.cfg\n#recursive-include scipy/f2py2e *.py\n#recursive-include scipy/f2py2e/src fortranobject.c fortranobject.h\n#recursive-include scipy/f2py2e/tests *.py\n#recursive-include scipy/f2py2e/tests/mixed *.f *.f90\n##recursive-include scipy/f2py2e/doc *.py *.txt *.tex *.html Makefile\n#recursive-include scipy/f2py2e/docs *.txt *.html *.dat *.f *.f90 *.pyf setup_example.py f2py_style.css\ninclude scipy/corelib/blasdot/cblas.h\nrecursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi\nprune scipy/base/include/scipy\nrecursive-include scipy/base/include/scipy *object.h\n", "source_code_before": "recursive-include . *.txt\ninclude MANIFEST.in\n#include scipy/f2py2e/f2py.1\n#recursive-include scipy/f2py2e *.cfg\n#recursive-include scipy/f2py2e *.py\n#recursive-include scipy/f2py2e/src fortranobject.c fortranobject.h\n#recursive-include scipy/f2py2e/tests *.py\n#recursive-include scipy/f2py2e/tests/mixed *.f *.f90\n##recursive-include scipy/f2py2e/doc *.py *.txt *.tex *.html Makefile\n#recursive-include scipy/f2py2e/docs *.txt *.html *.dat *.f *.f90 *.pyf setup_example.py f2py_style.css\nrecursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi\nprune scipy/base/include/scipy\nrecursive-include scipy/base/include/scipy *object.h", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "include scipy/corelib/blasdot/cblas.h", "recursive-include scipy/base/include/scipy *object.h" ], "deleted": [ "recursive-include scipy/base/include/scipy *object.h" ] } }, { "old_path": "scipy/base/src/arrayobject.c", "new_path": "scipy/base/src/arrayobject.c", "filename": "arrayobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -3220,8 +3220,11 @@ PyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n \t\tself->flags |= OWN_DATA;\n \n \t\t/* It is bad to have unitialized OBJECT pointers */\n-\t\tif (type_num == PyArray_OBJECT) {\n-\t\t\tmemset(data, '\\0', sd);\n+\t\t/* We shouldn't need to check for the OBJECT Letter\n+\t\t but perhaps it's best. */\n+\t\tif (type_num == PyArray_OBJECT || \\\n+\t\t type_num == PyArray_OBJECTLTR) {\n+\t\t\tmemset(data, 0, sd);\n \t\t}\n \t}\n \telse {\n@@ -4582,7 +4585,7 @@ Assign_Array(PyArrayObject *self, PyObject *v)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n- r = PySequence_SetItem((PyObject*)self,l,e);\n+\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n@@ -4667,6 +4670,7 @@ Array_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth,\n \t\t\t\t type, NULL, NULL,\n \t\t\t\t itemsize, \n \t\t\t\t typecode->fortran, NULL);\n+\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n", "added_lines": 7, "deleted_lines": 3, "source_code": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic int\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t}\n\t\t/* Other wise base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError,\n \"Cannot copy-back to a read-\"\\\n \"only array.\");\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "source_code_before": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic int\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t}\n\t\t/* Other wise base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\tif (type_num == PyArray_OBJECT) {\n\t\t\tmemset(data, '\\0', sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n r = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError,\n \"Cannot copy-back to a read-\"\\\n \"only array.\");\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "methods": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1192, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1204, "end_line": 1228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1231, "end_line": 1234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1238, "end_line": 1268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1272, "end_line": 1280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1286, "end_line": 1336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1343, "end_line": 1388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1392, "end_line": 1487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1490, "end_line": 1524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1529, "end_line": 1579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1582, "end_line": 1641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 10, "token_count": 307, "parameters": [ "self", "op" ], "start_line": 1662, "end_line": 1720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1733, "end_line": 1785, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1793, "end_line": 1796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1815, "end_line": 1827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1830, "end_line": 1845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1849, "end_line": 1858, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1861, "end_line": 1872, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1940, "end_line": 1973, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1979, "end_line": 2018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2021, "end_line": 2040, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2044, "end_line": 2063, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2067, "end_line": 2078, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2081, "end_line": 2092, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2095, "end_line": 2107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2110, "end_line": 2113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2116, "end_line": 2119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2122, "end_line": 2125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2128, "end_line": 2131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2134, "end_line": 2137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2140, "end_line": 2143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2146, "end_line": 2149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2152, "end_line": 2155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2158, "end_line": 2161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2164, "end_line": 2167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2170, "end_line": 2173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2176, "end_line": 2179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2182, "end_line": 2185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2188, "end_line": 2191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2194, "end_line": 2197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2200, "end_line": 2203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2206, "end_line": 2209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2212, "end_line": 2215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2218, "end_line": 2221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2224, "end_line": 2227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2230, "end_line": 2233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2236, "end_line": 2239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2242, "end_line": 2245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2248, "end_line": 2251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2254, "end_line": 2257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2260, "end_line": 2263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2266, "end_line": 2269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2272, "end_line": 2276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2279, "end_line": 2283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2287, "end_line": 2305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2308, "end_line": 2323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2327, "end_line": 2353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2356, "end_line": 2381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2384, "end_line": 2406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2409, "end_line": 2431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2434, "end_line": 2456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2459, "end_line": 2463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2524, "end_line": 2562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2566, "end_line": 2587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2590, "end_line": 2595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2616, "end_line": 2663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2666, "end_line": 2702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2708, "end_line": 2725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2728, "end_line": 2740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2743, "end_line": 2755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2759, "end_line": 2836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2839, "end_line": 2868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2874, "end_line": 2890, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2895, "end_line": 2918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2924, "end_line": 2940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2944, "end_line": 2960, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2964, "end_line": 2980, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2983, "end_line": 3016, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3020, "end_line": 3042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3049, "end_line": 3064, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3084, "end_line": 3108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3112, "end_line": 3256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3261, "end_line": 3366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3370, "end_line": 3387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3391, "end_line": 3506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3513, "end_line": 3516, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3519, "end_line": 3529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3602, "end_line": 3605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3609, "end_line": 3643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3647, "end_line": 3650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3653, "end_line": 3686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3690, "end_line": 3697, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3700, "end_line": 3708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3712, "end_line": 3726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3729, "end_line": 3773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3777, "end_line": 3780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3783, "end_line": 3790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3794, "end_line": 3801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3804, "end_line": 3824, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3827, "end_line": 3849, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3852, "end_line": 3855, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3859, "end_line": 3862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3874, "end_line": 3932, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3937, "end_line": 3947, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3951, "end_line": 3976, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3980, "end_line": 4012, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4015, "end_line": 4048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4051, "end_line": 4088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4091, "end_line": 4094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4097, "end_line": 4149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4325, "end_line": 4350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4353, "end_line": 4375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4382, "end_line": 4408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4411, "end_line": 4431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 118, "complexity": 27, "token_count": 637, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4434, "end_line": 4567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4570, "end_line": 4593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4597, "end_line": 4620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4624, "end_line": 4681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4685, "end_line": 4692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4698, "end_line": 4788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4794, "end_line": 4805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4808, "end_line": 4843, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4850, "end_line": 4896, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 67, "complexity": 23, "token_count": 437, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4899, "end_line": 4979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 4983, "end_line": 5088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5091, "end_line": 5185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5188, "end_line": 5209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5213, "end_line": 5275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5278, "end_line": 5283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5286, "end_line": 5292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5346, "end_line": 5376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5386, "end_line": 5402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5408, "end_line": 5413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5416, "end_line": 5422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5425, "end_line": 5431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5437, "end_line": 5508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5511, "end_line": 5535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5545, "end_line": 5582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5587, "end_line": 5597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5600, "end_line": 5605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5608, "end_line": 5613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5617, "end_line": 5620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5624, "end_line": 5672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5675, "end_line": 5727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5731, "end_line": 5850, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5854, "end_line": 5886, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5889, "end_line": 5930, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5934, "end_line": 6056, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6069, "end_line": 6110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6115, "end_line": 6119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6184, "end_line": 6245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6253, "end_line": 6268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6274, "end_line": 6343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6347, "end_line": 6383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6389, "end_line": 6433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6451, "end_line": 6587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6593, "end_line": 6662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6665, "end_line": 6798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6804, "end_line": 6834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6840, "end_line": 6851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6854, "end_line": 6863, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6866, "end_line": 6884, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1192, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1204, "end_line": 1228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1231, "end_line": 1234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1238, "end_line": 1268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1272, "end_line": 1280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1286, "end_line": 1336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1343, "end_line": 1388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1392, "end_line": 1487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1490, "end_line": 1524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1529, "end_line": 1579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1582, "end_line": 1641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 10, "token_count": 307, "parameters": [ "self", "op" ], "start_line": 1662, "end_line": 1720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1733, "end_line": 1785, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1793, "end_line": 1796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1815, "end_line": 1827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1830, "end_line": 1845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1849, "end_line": 1858, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1861, "end_line": 1872, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1940, "end_line": 1973, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1979, "end_line": 2018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2021, "end_line": 2040, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2044, "end_line": 2063, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2067, "end_line": 2078, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2081, "end_line": 2092, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2095, "end_line": 2107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2110, "end_line": 2113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2116, "end_line": 2119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2122, "end_line": 2125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2128, "end_line": 2131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2134, "end_line": 2137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2140, "end_line": 2143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2146, "end_line": 2149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2152, "end_line": 2155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2158, "end_line": 2161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2164, "end_line": 2167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2170, "end_line": 2173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2176, "end_line": 2179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2182, "end_line": 2185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2188, "end_line": 2191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2194, "end_line": 2197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2200, "end_line": 2203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2206, "end_line": 2209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2212, "end_line": 2215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2218, "end_line": 2221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2224, "end_line": 2227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2230, "end_line": 2233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2236, "end_line": 2239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2242, "end_line": 2245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2248, "end_line": 2251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2254, "end_line": 2257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2260, "end_line": 2263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2266, "end_line": 2269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2272, "end_line": 2276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2279, "end_line": 2283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2287, "end_line": 2305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2308, "end_line": 2323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2327, "end_line": 2353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2356, "end_line": 2381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2384, "end_line": 2406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2409, "end_line": 2431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2434, "end_line": 2456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2459, "end_line": 2463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2524, "end_line": 2562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2566, "end_line": 2587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2590, "end_line": 2595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2616, "end_line": 2663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2666, "end_line": 2702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2708, "end_line": 2725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2728, "end_line": 2740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2743, "end_line": 2755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2759, "end_line": 2836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2839, "end_line": 2868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2874, "end_line": 2890, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2895, "end_line": 2918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2924, "end_line": 2940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2944, "end_line": 2960, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2964, "end_line": 2980, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2983, "end_line": 3016, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3020, "end_line": 3042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3049, "end_line": 3064, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3084, "end_line": 3108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 27, "token_count": 671, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3112, "end_line": 3253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 142, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3258, "end_line": 3363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3367, "end_line": 3384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3388, "end_line": 3503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3510, "end_line": 3513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3516, "end_line": 3526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3599, "end_line": 3602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3606, "end_line": 3640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3644, "end_line": 3647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3650, "end_line": 3683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3687, "end_line": 3694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3697, "end_line": 3705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3709, "end_line": 3723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3726, "end_line": 3770, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3774, "end_line": 3777, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3780, "end_line": 3787, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3791, "end_line": 3798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3801, "end_line": 3821, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3824, "end_line": 3846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3849, "end_line": 3852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3856, "end_line": 3859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3871, "end_line": 3929, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3934, "end_line": 3944, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3948, "end_line": 3973, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3977, "end_line": 4009, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4012, "end_line": 4045, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4048, "end_line": 4085, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4088, "end_line": 4091, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4094, "end_line": 4146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4322, "end_line": 4347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4350, "end_line": 4372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4379, "end_line": 4405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4408, "end_line": 4428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 118, "complexity": 27, "token_count": 637, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4431, "end_line": 4564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4567, "end_line": 4590, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4594, "end_line": 4617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4621, "end_line": 4677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4681, "end_line": 4688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4694, "end_line": 4784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4790, "end_line": 4801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4804, "end_line": 4839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4846, "end_line": 4892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 67, "complexity": 23, "token_count": 437, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4895, "end_line": 4975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 4979, "end_line": 5084, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5087, "end_line": 5181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5184, "end_line": 5205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5209, "end_line": 5271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5274, "end_line": 5279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5282, "end_line": 5288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5342, "end_line": 5372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5382, "end_line": 5398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5404, "end_line": 5409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5412, "end_line": 5418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5421, "end_line": 5427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5433, "end_line": 5504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5507, "end_line": 5531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5541, "end_line": 5578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5583, "end_line": 5593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5596, "end_line": 5601, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5604, "end_line": 5609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5613, "end_line": 5616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5620, "end_line": 5668, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5671, "end_line": 5723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5727, "end_line": 5846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5850, "end_line": 5882, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5885, "end_line": 5926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5930, "end_line": 6052, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6065, "end_line": 6106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6111, "end_line": 6115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6180, "end_line": 6241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6249, "end_line": 6264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6270, "end_line": 6339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6343, "end_line": 6379, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6385, "end_line": 6429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6447, "end_line": 6583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6589, "end_line": 6658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6661, "end_line": 6794, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6800, "end_line": 6830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6836, "end_line": 6847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6850, "end_line": 6859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6862, "end_line": 6880, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4570, "end_line": 4593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3112, "end_line": 3256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4624, "end_line": 4681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 } ], "nloc": 5442, "complexity": 1191, "token_count": 32497, "diff_parsed": { "added": [ "\t\t/* We shouldn't need to check for the OBJECT Letter", "\t\t but perhaps it's best. */", "\t\tif (type_num == PyArray_OBJECT || \\", "\t\t type_num == PyArray_OBJECTLTR) {", "\t\t\tmemset(data, 0, sd);", "\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);", "" ], "deleted": [ "\t\tif (type_num == PyArray_OBJECT) {", "\t\t\tmemset(data, '\\0', sd);", " r = PySequence_SetItem((PyObject*)self,l,e);" ] } }, { "old_path": "scipy/base/src/arraytypes.inc.src", "new_path": "scipy/base/src/arraytypes.inc.src", "filename": "arraytypes.inc.src", "extension": "src", "change_type": "MODIFY", "diff": "@@ -1571,6 +1571,7 @@ PyArray_DescrFromType(int type) {\n \t\treturn userdescrs[type-PyArray_USERDEF];\n \t} \n \telse {\n+\t\tfprintf(stderr, \"Getting Descr from character code...\\n\");\n \t\tswitch(type) {\n case PyArray_INTPLTR: return descrs[PyArray_INTP];\n \t\tcase PyArray_DOUBLELTR: return descrs[PyArray_DOUBLE];\n", "added_lines": 1, "deleted_lines": 0, "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n\n\n#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n#incr= ip++*196,ip+=2*42#\n*/\n\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;idescr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n\n\n#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n#incr= ip++*196,ip+=2*42#\n*/\n\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;idescr->type, 0, 0);\n+ values = (PyArrayObject *)\\\n+\t\tPyArray_ContiguousFromObject(values0, self->descr->type_num, \n+\t\t\t\t\t 0, 0);\n if (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\n if (nv > 0) { /* nv == 0 for a null array */\n for(i=0; idata + chunk * (i % nv);\n- tmp = ((long *)(indices->data))[i];\n+ tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"Index out of range for array\");\n", "added_lines": 4, "deleted_lines": 3, "source_code": "\n/*\n Python Multiarray Module -- A useful collection of functions for creating and\n using ndarrays\n\n Original file \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n Modified for scipy_core in 2005 \n\n Travis E. Oliphant\n Assistant Professor at\n Brigham Young University\n \n*/\n\n/* $Id: multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp $ */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n/*#include \n#include \n*/\n\n#define _MULTIARRAYMODULE\n#include \"scipy/arrayobject.h\"\n\n#define PyAO PyArrayObject\n\nstatic PyObject *typeDict=NULL; /* Must be explicitly loaded */\n\n/* Including this file is the only way I know how to declare functions\n static in each file, and store the pointers from functions in both\n arrayobject.c and multiarraymodule.c for the C-API \n\n Declarying an external pointer-containing variable in arrayobject.c\n and trying to copy it to PyArray_API, did not work.\n\n Think about two modules with a common api that import each other...\n\n This file would just be the module calls. \n*/\n\n#include \"arrayobject.c\"\n\n\n/* An Error object -- rarely used? */\nstatic PyObject *MultiArrayError;\n\nstatic intp \nPyArray_MultiplyList(intp *l1, int n) \n{\n\tregister intp s=1;\n\tregister int i=0;\n while (i++ < n) s *= (*l1++);\n return s;\n}\n\n\nstatic int \nPyArray_AxisConverter(PyObject *obj, int *axis)\n{\n\tif (obj == Py_None) {\n\t\t*axis = MAX_DIMS;\n\t}\n\telse {\n\t\t*axis = (int) PyInt_AsLong(obj);\n\t\tif (PyErr_Occurred()) {\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\nstatic int \nPyArray_CompareLists(intp *l1, intp *l2, int n) \n{\n int i;\n for(i=0;itype_num;\n\t}\n\n\tnew = PyArray_New(self->ob_type,\n\t\t\t self->nd, self->dimensions,\n\t\t\t self->descr->type_num,\n\t\t\t self->strides,\n\t\t\t self->data,\n\t\t\t self->itemsize,\n\t\t\t self->flags, self);\n\n\tif (new==NULL) return NULL;\n\t\n Py_INCREF(self);\n PyArray_BASE(new) = (PyObject *)self;\n if ((type_num != PyArray_NOTYPE) && \\\n (type_num != self->descr->type_num)) {\n if (!PyTypeNum_ISFLEXIBLE(type_num)) {\n v = PyArray_TypeObjectFromType(type_num);\n }\n else {\n PyArray_Descr *descr;\n int itemsize = type->itemsize;\n descr = PyArray_DescrFromType(type_num);\n if (type_num == PyArray_UNICODE) \n itemsize /= sizeof(Py_UNICODE);\n /* construct a string representation */\n v = PyString_FromFormat(\"%c%d\", descr->type, \n itemsize);\n }\n if (v == NULL) goto fail;\n /* set attribute new.dtype = newtype */\n if (PyObject_SetAttrString(new, \"dtype\", v) < 0) goto fail;\n Py_DECREF(v);\n }\n\treturn new;\t\n\n fail:\n Py_XDECREF(v);\n Py_XDECREF(new);\n return NULL;\n}\n\nstatic PyObject *\nPyArray_Ravel(PyArrayObject *a, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n if (a->nd == 1) {\n Py_INCREF(a);\n return (PyObject *)a;\n }\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) \n\t\treturn PyArray_Newshape(a, &newdim);\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tsize = PyArray_SIZE(a);\n\tret = PyArray_New(a->ob_type,\n\t\t\t 1, &size,\n\t\t\t a->descr->type_num,\n\t\t\t NULL,\n NULL,\n\t\t\t a->itemsize,\n\t\t\t 0, a);\n\n\tif (ret== NULL) return NULL;\n\tif (fortran) {\n\t\tnew = PyArray_Transpose(a, NULL);\n\t\tif (new == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tPy_INCREF(a);\n\t\tnew = (PyObject *)a;\n\t}\n\tif (PyArray_CopyInto((PyArrayObject *)ret, (PyArrayObject *)new) < 0) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn NULL;\n\t}\n\tPy_DECREF(new);\n\treturn ret;\n}\n\n\n/* For back-ward compatability *\n\n/ * Not recommended */\n\nstatic PyObject *\nPyArray_Reshape(PyArrayObject *self, PyObject *shape) \n{\n PyObject *ret;\n PyArray_Dims newdims;\n\n if (!PyArray_IntpConverter(shape, &newdims)) return NULL;\n ret = PyArray_Newshape(self, &newdims);\n PyDimMem_FREE(newdims.ptr);\n return ret;\n}\n\n/* Returns a new array \n with the a new shape from the data\n in the old array\n*/\n\nstatic PyObject * \nPyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims)\n{\n intp i, s_original, i_unknown, s_known;\n intp *dimensions = newdims->ptr;\n PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n if ((s_known == 0) || (s_original % s_known != 0)) {\n PyErr_SetString(PyExc_ValueError, msg);\n goto fail;\n }\n dimensions[i_unknown] = s_original/s_known;\n } else {\n if (s_original != s_known) {\n PyErr_SetString(PyExc_ValueError, msg);\n goto fail;\n }\n }\n \n\tret = (PyAO *)PyArray_New(self->ob_type,\n\t\t\t\t n, dimensions,\n\t\t\t\t self->descr->type_num,\n\t\t\t\t NULL,\n\t\t\t\t self->data,\n\t\t\t\t self->itemsize,\n\t\t\t\t self->flags, self);\n\n\tif (ret== NULL)\n goto fail;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\n\t\n fail:\n return NULL;\n}\n\n/* return a new view of the array object with all of its unit-length \n dimensions squeezed out if needed, otherwise\n return the same array.\n */\n\nstatic PyObject *\nPyArray_Squeeze(PyArrayObject *self)\n{\n\tint nd = self->nd;\n\tint newnd = nd;\n\tintp dimensions[MAX_DIMS];\n\tintp strides[MAX_DIMS];\n\tint i,j;\n\tPyObject *ret;\n\n\tif (nd == 0) {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\tfor (j=0, i=0; idimensions[i] == 1) {\n\t\t\tnewnd -= 1;\n\t\t}\n\t\telse {\n\t\t\tdimensions[j] = self->dimensions[i];\n\t\t\tstrides[j++] = self->strides[i];\n\t\t}\n\t}\n\t\n\tret = PyArray_New(self->ob_type, newnd, dimensions, \n\t\t\t self->descr->type_num, strides,\n\t\t\t self->data, self->itemsize, self->flags,\n\t\t\t self);\n\tself->flags &= ~OWN_DATA;\n\tself->base = (PyObject *)self;\n\tPy_INCREF(self);\n\treturn (PyObject *)ret;\n}\n\n\nstatic PyObject *\nPyArray_Mean(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL;\n\tPyObject *new, *ret;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\n\tobj1 = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,\n\t\t\t\t\t rtype);\n\tobj2 = PyFloat_FromDouble((double) PyArray_DIM(new,axis));\n Py_DECREF(new);\n\tif (obj1 == NULL || obj2 == NULL) {\n\t\tPy_XDECREF(obj1);\n\t\tPy_XDECREF(obj2);\n\t\treturn NULL;\n\t}\n\n\tret = PyNumber_Divide(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_Std(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL, *new=NULL;\n\tPyObject *ret=NULL, *newshape=NULL;\n\tint i, n;\n\tintp val;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\t\n\t/* Compute and reshape mean */\n\tobj1 = PyArray_EnsureArray(PyArray_Mean((PyAO *)new, axis, rtype));\n\tif (obj1 == NULL) {Py_DECREF(new); return NULL;} \n\tn = PyArray_NDIM(new);\n\tnewshape = PyTuple_New(n);\n\tif (newshape == NULL) {Py_DECREF(obj1); Py_DECREF(new); return NULL;}\n\tfor (i=0; ind != 1) {\n Py_DECREF(cond);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Condition must be 1-d array.\");\n return NULL;\n }\n\n res = PyArray_Nonzero(cond);\n Py_DECREF(cond);\n\tret = PyArray_Take(self, res, axis);\n\tPy_DECREF(res);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_Nonzero(PyArrayObject *self)\n{\n int n=self->nd, j;\n\tintp count=0, i, size;\n\tPyArrayIterObject *it=NULL;\n\tPyObject *ret=NULL, *item;\n\tintp *dptr[MAX_DIMS];\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (it==NULL) return NULL;\n\n\tsize = it->size;\n\tfor (i=0; idescr->nonzero(it->dataptr, self)) count++;\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\n\tPyArray_ITER_RESET(it);\n\tif (n==1) {\n\t\tret = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, \n\t\t\t\t NULL, NULL, 0, 0, self);\n\t\tif (ret == NULL) goto fail;\n\t\tdptr[0] = (intp *)PyArray_DATA(ret);\n\t\t\n\t\tfor (i=0; idescr->nonzero(it->dataptr, self)) \n\t\t\t\t*(dptr[0])++ = i;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t}\n\telse {\n\t\tret = PyTuple_New(n);\n\t\tfor (j=0; job_type, 1, &count, \n\t\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0,\n\t\t\t\t\t self);\n\t\t\tPyTuple_SET_ITEM(ret, j, item);\n\t\t\tif (item == NULL) goto fail;\n\t\t\tdptr[j] = (intp *)PyArray_DATA(item);\n\t\t}\n\t\t\n\t\t/* reset contiguous so that coordinates gets updated */\n\t\tit->contiguous = 0;\n\t\tfor (i=0; idescr->nonzero(it->dataptr, self)) \n\t\t\t\tfor (j=0; jcoordinates[j];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\n\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ret);\n\tPy_XDECREF(it);\n\treturn NULL;\n \n}\n\nstatic PyObject *\nPyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max)\n{\n\tPyObject *selector=NULL, *newtup=NULL, *ret=NULL;\n\tPyObject *res1=NULL, *res2=NULL, *res3=NULL;\n\tPyObject *two;\n\n\ttwo = PyInt_FromLong((long)2);\n\tres1 = PyArray_GenericBinaryFunction(self, max, n_ops.greater);\n\tres2 = PyArray_GenericBinaryFunction(self, min, n_ops.less);\n\tif ((res1 == NULL) || (res2 == NULL)) goto fail;\n\tres3 = PyNumber_Multiply(two, res1);\n\tPy_DECREF(two);\n\tPy_DECREF(res1);\n\tif (res3 == NULL) return NULL;\n\n\tselector = PyArray_EnsureArray(PyNumber_Add(res2, res3));\n\tPy_DECREF(res2);\n\tPy_DECREF(res3);\n\tif (selector == NULL) return NULL;\n\n\tnewtup = Py_BuildValue(\"(OOO)\", (PyObject *)self, min, max);\n\tif (newtup == NULL) goto fail;\n\tret = PyArray_Choose((PyAO *)selector, newtup);\n\tPy_DECREF(selector);\n\tPy_DECREF(newtup);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(res1);\n\tPy_XDECREF(res2);\n\tPy_XDECREF(two);\n\tPy_XDECREF(selector);\n\treturn NULL;\n}\n\nstatic PyObject *\nPyArray_Conjugate(PyArrayObject *self)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyObject *new;\n\t\tintp size, i;\n\t\t/* Make a copy */\n\t\tnew = PyArray_Copy(self);\n\t\tif (new==NULL) return NULL;\n\t\tsize = PyArray_SIZE(new);\n\t\tif (self->descr->type_num == PyArray_CFLOAT) {\n\t\t\tcfloat *dptr = (cfloat *) PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CDOUBLE) {\n\t\t\tcdouble *dptr = (cdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CLONGDOUBLE) {\n\t\t\tclongdouble *dptr = (clongdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\t\t\t\n\t\t}\t\t\n\t\treturn new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *) self;\n\t}\n}\n\nstatic PyObject *\nPyArray_Trace(PyArrayObject *self, int offset, int axis1, int axis2, \nint rtype)\n{\n\tPyObject *diag=NULL, *ret=NULL;\n\n\tdiag = PyArray_Diagonal(self, offset, axis1, axis2);\n\tif (diag == NULL) return NULL;\n\tret = PyArray_GenericReduceFunction((PyAO *)diag, n_ops.add, -1, rtype);\n\tPy_DECREF(diag);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)\n{\n\tint n = self->nd;\n\tPyObject *new;\n\tPyObject *newaxes;\n\tint i, pos;\t\n\n\tif (n < 2) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"array.ndim must be >= 2\");\n\t\treturn NULL;\n\t}\n\tif (axis1 < 0) axis1 += n;\n\tif (axis2 < 0) axis2 += n;\n\tif ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||\t\\\n\t (axis2 < 0) || (axis2 >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \"axis1(=%d) and axis2(=%d) \"\\\n\t\t\t \"must be different and within range (nd=%d)\",\n\t\t\t axis1, axis2, n);\n\t\treturn NULL;\n\t}\n \n\tnewaxes = PyTuple_New(n);\n\tif (newaxes==NULL) return NULL;\n\t/* insert at the end */\n\tPyTuple_SET_ITEM(newaxes, n-2, PyInt_FromLong((long)axis1));\n\tPyTuple_SET_ITEM(newaxes, n-1, PyInt_FromLong((long)axis2));\n\tpos = 0;\n\tfor (i=0; idimensions[0];\n\t\tn2 = self->dimensions[1];\n\t\tstep = n2+1;\n\t\tif (offset < 0) {\n\t\t\tstart = -n2 * offset;\n\t\t\tstop = MIN(n2, n1+offset)*(n2+1) - n2*offset;\n\t\t}\n\t\telse {\n\t\t\tstart = offset;\n\t\t\tstop = MIN(n1, n2-offset)*(n2+1) + offset;\n\t\t}\n\t\t\n\t\t/* count = ceil((stop-start)/step) */\n\t\tcount = ((stop-start) / step) + (((stop-start) % step) != 0);\n\t\t\t\n\t\tindices = PyArray_New(&PyArray_Type, 1, &count, \n\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0, NULL);\n\t\tif (indices == NULL) {\n\t\t\tPy_DECREF(self); return NULL;\n\t\t}\n\t\tdptr = (intp *)PyArray_DATA(indices);\n\t\tfor (n1=start; n1descr->type_num,\n\t\t\t\t\t self->itemsize, 0};\n\t\t\n\t\tmydiagonal = PyList_New(0);\n\t\tif (mydiagonal == NULL) {Py_DECREF(self); return NULL;}\n\t\tn1 = self->dimensions[0];\n\t\tfor (i=0; i 3)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"Only Carrays of 1-3 dimensions available.\");\n\t\treturn -1;\n\t}\n\tif ((ap = (PyArrayObject*)PyArray_FromAny(*op, &typecode, nd, nd,\n\t\t\t\t\t\t CARRAY_FLAGS)) == NULL)\n\t\treturn -1;\n\tswitch(nd) {\n\tcase 1:\n\t\t*((char **)ptr) = ap->data;\n\t\tbreak;\n\tcase 2:\n\t\tn = ap->dimensions[0];\n\t\tptr2 = (char **)malloc(n * sizeof(char *));\n\t\tif (!ptr2) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0];\n\t\t}\n\t\t*((char ***)ptr) = ptr2;\n\t\tbreak;\t\t\n\tcase 3:\n\t\tn = ap->dimensions[0];\n\t\tm = ap->dimensions[1];\n\t\tptr3 = (char ***)malloc(n*(m+1) * sizeof(char *));\n\t\tif (!ptr3) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0] + \\\n\t\t\t\t\tj*ap->strides[1];\n\t\t\t}\n\t\t}\n\t\t*((char ****)ptr) = ptr3;\n\t}\n\tmemcpy(dims, ap->dimensions, nd*sizeof(intp));\n\t*op = (PyObject *)ap;\n\treturn 0;\n\n fail:\n\tPyErr_SetString(PyExc_MemoryError, \"No memory.\");\n\treturn -1;\n}\n\n/* Deprecated --- Use PyArray_AsCArray instead */\n\nstatic int \nPyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode) \n{\n\tintp newd1;\n\t\n\tif (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, typecode) == -1)\n\t\treturn -1;\t\n\t*d1 = (int) newd1;\n\treturn 0;\n}\n\n\nstatic int \nPyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode) \n{\n\tintp newdims[2];\n\n\tif (PyArray_AsCArray(op, (void *)ptr, newdims, 2, typecode) == -1)\n\t\treturn -1;\n\n\t*d1 = (int ) newdims[0];\n\t*d2 = (int ) newdims[1];\n return 0;\n}\n\n/* End Deprecated */\n\nstatic int \nPyArray_Free(PyObject *op, void *ptr) \n{\n PyArrayObject *ap = (PyArrayObject *)op;\n\t\n if ((ap->nd < 1) || (ap->nd > 3)) \n\t\treturn -1;\n if (ap->nd >= 2) {\n\t\tfree(ptr);\n }\n Py_DECREF(ap);\n return 0;\n}\n\n\nstatic PyObject *\n_swap_and_concat(PyObject *op, int axis, int n)\n{\n\tPyObject *newtup=NULL;\n\tPyObject *otmp, *arr;\n\tint i;\n\n\tnewtup = PyTuple_New(n);\n\tif (newtup==NULL) return NULL;\n\tfor (i=0; i= MAX_DIMS) {\n\t\t\totmp = PyArray_Ravel(mps[i],0);\n\t\t\tPy_DECREF(mps[i]);\n\t\t\tmps[i] = (PyArrayObject *)otmp;\n\t\t}\n\t\tprior2 = PyArray_GetPriority((PyObject *)(mps[i]), 0.0);\n\t\tif (prior2 > prior1) {\n\t\t\tprior1 = prior2;\n\t\t\tsubtype = mps[i]->ob_type;\n\t\t\tret = mps[i];\n\t\t}\n\t}\n\t\n\tnew_dim = 0;\n\tfor(i=0; ind;\n\t\telse {\n\t\t\tif (nd != mps[i]->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"arrays must have same \"\\\n\t\t\t\t\t\t\"number of dimensions\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CompareLists(mps[0]->dimensions+1, \n\t\t\t\t\t\t mps[i]->dimensions+1, \n\t\t\t\t\t\t nd-1)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"array dimensions must \"\\\n\t\t\t\t\t\t\"agree except for d_0\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (nd == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"0d arrays can't be concatenated\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnew_dim += mps[i]->dimensions[0];\n\t}\n\t\n\ttmp = mps[0]->dimensions[0];\n\tmps[0]->dimensions[0] = new_dim;\n\tret = (PyArrayObject *)PyArray_New(subtype, nd,\n\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t type_num, NULL, NULL, 0, 0, ret);\n\tmps[0]->dimensions[0] = tmp;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tdata = ret->data;\n\tfor(i=0; idata, numbytes);\n\t\tdata += numbytes;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; ind;\n\tif (n <= 1) {\n\t\tPy_INCREF(ap);\n\t\treturn (PyObject *)ap;\n\t}\n\n\tif (a1 < 0) a1 += n;\n\tif (a2 < 0) a2 += n;\n\tif ((a1 < 0) || (a1 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Bad axis1 argument to swapaxes.\");\n\t\treturn NULL;\n\t}\n\tif ((a2 < 0) || (a2 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Bad axis2 argument to swapaxes.\");\n\t\treturn NULL;\n\t}\n\tnew_axes = PyTuple_New(n);\n\tfor (i=0; ind;\n\t\tpermutation = (intp *)malloc(n*sizeof(int));\n\t\tfor(i=0; ind+axis;\n\t\t\tif (axis < 0 || axis >= ap->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"invalid axis for this array\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tpermutation[i] = axis;\n\t\t}\n\t}\n\t\n\t/* this allocates memory for dimensions and strides (but fills them\n\t incorrectly), sets up descr, and points data at ap->data. */\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, n, permutation, \n\t\t\t\t\t ap->descr->type_num, NULL,\n\t\t\t\t\t ap->data, ap->itemsize, ap->flags,\n\t\t\t\t\t ap);\n\tif (ret == NULL) goto fail;\n\t\n\t/* point at true owner of memory: */\n\tret->base = (PyObject *)ap;\n\tPy_INCREF(ap);\n\t\n\tfor(i=0; idimensions[i] = ap->dimensions[permutation[i]];\n\t\tret->strides[i] = ap->strides[permutation[i]];\n\t}\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n\tif (op && (op != Py_None))\n\t\tPyArray_Free(op, (char *)axes);\n\tfree(permutation);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ret);\n\tif (permutation != NULL) free(permutation);\n\tif (op != Py_None)\n\t\tPyArray_Free(op, (char *)axes);\n\treturn NULL;\n}\n\nstatic PyObject *\nPyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis) {\n\tintp *counts;\n\tintp n, n_outer, i, j, k, chunk, total;\n\tintp tmp;\n\tint nd;\n\tPyArrayObject *repeats=NULL;\n\tPyObject *ap=NULL;\n\tPyArrayObject *ret=NULL;\n\tchar *new_data, *old_data;\n\n\trepeats = (PyAO *)PyArray_ContiguousFromObject(op, PyArray_INTP, 0, 1);\n\tif (repeats == NULL) return NULL;\n\tnd = repeats->nd;\n\tcounts = (intp *)repeats->data;\n\n\tif ((ap=_check_axis(aop, &axis, CARRAY_FLAGS))==NULL) {\n\t\tPy_DECREF(repeats);\n\t\treturn NULL;\n\t}\n\n\taop = (PyAO *)ap;\n\n\tif (nd == 1)\n\t\tn = repeats->dimensions[0];\n\telse /* nd == 0 */\n\t\tn = aop->dimensions[axis];\n\n\tif (aop->dimensions[axis] != n) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"a.shape[axis] != len(repeats)\");\n\t\tgoto fail;\n\t}\n\n\t\n\tif (nd == 0) \n\t\ttotal = counts[0]*n;\n\telse {\n\t\t\n\t\ttotal = 0;\n\t\tfor(j=0; jdimensions[axis] = total;\n\tret = (PyArrayObject *)PyArray_New(aop->ob_type, aop->nd,\n\t\t\t\t\t aop->dimensions, \n\t\t\t\t\t aop->descr->type_num,\n\t\t\t\t\t NULL, NULL, aop->itemsize, 0,\n\t\t\t\t\t aop);\n\taop->dimensions[axis] = n;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tnew_data = ret->data;\n\told_data = aop->data;\n\t\n\tchunk = aop->itemsize;\n\tfor(i=axis+1; ind; i++) {\n\t\tchunk *= aop->dimensions[i];\n\t}\n\t\n\tn_outer = 1;\n\tfor(i=0; idimensions[i];\n\n\tfor(i=0; ind < mps[i]->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many dimensions\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (!PyArray_CompareLists(ap->dimensions+(ap->nd-mps[i]->nd),\n\t\t\t\t mps[i]->dimensions, mps[i]->nd)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"array dimensions must agree\");\n\t\t\tgoto fail;\n\t\t}\n\t\tsizes[i] = PyArray_NBYTES(mps[i]);\n\t}\n\t\n\t/* why not ??? \n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tPyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Not implemented for flexible sizes\");\n\t\treturn NULL;\n\t}\n\t*/\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd,\n\t\t\t\t\t ap->dimensions, type_num,\n\t\t\t\t\t NULL, NULL, 0, 0, ap);\n\tif (ret == NULL) goto fail;\n\t\n\telsize = ret->itemsize;\n\tm = PyArray_SIZE(ret);\n\tself_data = (intp *)ap->data;\n\tret_data = ret->data;\n\t\n\tfor (i=0; i= n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid entry in choice array\");\n\t\t\tgoto fail;\n\t\t}\n\t\toffset = i*elsize;\n\t\tif (offset >= sizes[mi]) {offset = offset % sizes[mi]; }\n\t\tmemmove(ret_data, mps[mi]->data+offset, elsize);\n\t\tret_data += elsize; self_data++;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; idescr->compare(a,b,global_obj);\n}\n\n#define SWAPAXES(op, ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n#define SWAPBACK(op, ap) { \\\n\t\tif (axis != orign) { \\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\nstatic PyObject *\nPyArray_Sort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *store_arr=NULL;\n\tchar *ip;\n\tint i, n, m, elsize, orign;\n\n\tif ((ap = (PyAO*) _check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_CopyFromObject((PyObject *)op, \n\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\n\tif (ap->descr->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tPy_DECREF(ap);\n\t\treturn NULL;\n\t}\n\t\n\telsize = ap->itemsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\n\t/* Store global -- allows re-entry -- restore before leaving*/\n\tstore_arr = global_obj; \n\tglobal_obj = ap;\n\t\n\tfor (ip=ap->data, i=0; iitemsize;\n\tconst intp *ipa = ip1;\n\tconst intp *ipb = ip2;\t\n\treturn global_obj->descr->compare(global_data + (isize * *ipa),\n global_data + (isize * *ipb), \n\t\t\t\t\t global_obj);\n}\n\nstatic PyObject *\nPyArray_ArgSort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap, *ret, *store;\n\tintp *ip;\n\tintp i, j, n, m, orign;\n\tint argsort_elsize;\n\tchar *store_ptr;\n\n\tif ((ap = (PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_ContiguousFromObject((PyObject *)op, \n\t\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, ap);\n\tif (ret == NULL) goto fail;\n\t\n\tif (ap->descr->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tip = (intp *)ret->data;\n\targsort_elsize = ap->itemsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\tstore_ptr = global_data;\n\tglobal_data = ap->data;\n\tstore = global_obj;\n\tglobal_obj = ap;\n\tfor (i=0; idescr->compare;\n\tintp min_i, max_i, i, j;\n\tint location, elsize = ap1->itemsize;\n\tintp elements = ap1->dimensions[ap1->nd-1];\n\tintp n = PyArray_Size((PyObject *)ap2);\n\tintp *rp = (intp *)ret->data;\n\tchar *ip = ap2->data;\n\tchar *vp = ap1->data;\n\n\tfor (j=0; j 0) {\n\t\t\t\t\tif (compare(ip, vp+elsize*(--i), ap2) \\\n\t\t\t\t\t != 0) {\n\t\t\t\t\t\ti = i+1; break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmin_i = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (location < 0) {\n\t\t\t\tmax_i = i;\n\t\t\t} else {\n\t\t\t\tmin_i = i+1;\n\t\t\t}\n\t\t}\n\t\t*rp = min_i;\n\t}\n}\n\nstatic PyObject *\nPyArray_SearchSorted(PyArrayObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret;\n\tint typenum = 0;\n\n\t/* \n PyObject *args;\n args = Py_BuildValue(\"O\",op2);\n\tPy_DELEGATE_ARGS(((PyObject *)op1), searchsorted, args);\n Py_XDECREF(args);\n\t*/\n\n\ttypenum = PyArray_ObjectType((PyObject *)op1, 0);\n\ttypenum = PyArray_ObjectType(op2, typenum);\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromObject((PyObject *)op1, \n\t\t\t\t\t\t\t typenum, \n\t\t\t\t\t\t\t 1, 1);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromObject(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd, \n\t\t\t\t\t ap2->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, ap2);\n\tif (ret == NULL) goto fail;\n\n\tif (ap2->descr->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tlocal_where(ap1, ap2, ret); \n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n\n\n/* Could perhaps be redone to not make contiguous arrays \n */\n\nstatic PyObject *\nPyArray_InnerProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret;\n\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS], nd;\n\tPyArray_DotFunc *dot;\n\tPyTypeObject *subtype;\n double prior1, prior2;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromObject(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromObject(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = (ret->descr->dotfunc);\n\t\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\n\t\n\tis1 = ap1->strides[ap1->nd-1]; \n\tis2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->itemsize;\n\t\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\tif (ap2->nd > 1) {\n\t\tmatchDim = ap2->nd - 2;\n\t\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 0;\n\t}\n\n\tif (ap2->dimensions[matchDim] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"objects are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-2; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\tif(ap2->nd > 1) {\n\t\tdimensions[j++] = ap2->dimensions[ap2->nd-1];\n\t}\n\t/*\n\tfprintf(stderr, \"nd=%d dimensions=\", nd);\n\t for(i=0; i prior1 ? ap2->ob_type : ap1->ob_type);\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = ret->descr->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\t\n\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->itemsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_type, 2, dims, PyArray_TYPE(arr),\n\t\t\t NULL, NULL, elsize, 0, (PyArrayObject *)arr);\n\n\tif (ret == NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn NULL;\n\t}\n\t/* do 2-d loop */\n\toptr = PyArray_DATA(ret);\n\tstr2 = elsize*dims[0];\n\tfor (i=0; idimensions[ap1->nd-1];\n\tn2 = ap2->dimensions[ap2->nd-1];\n\n\tif (n1 < n2) { \n\t\tret = ap1; ap1 = ap2; ap2 = ret; \n\t\tret = NULL; i = n1;n1=n2;n2=i;\n\t}\n\tlength = n1;\n\tn = n2;\n\tswitch(mode) {\n\tcase 0:\t\n\t\tlength = length-n+1;\n\t\tn_left = n_right = 0;\n\t\tbreak;\n\tcase 1:\n\t\tn_left = (int)(n/2);\n\t\tn_right = n-n_left-1;\n\t\tbreak;\n\tcase 2:\n\t\tn_right = n-1;\n\t\tn_left = n-1;\n\t\tlength = length+n-1;\n\t\tbreak;\n\tdefault:\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mode must be 0,1, or 2\");\n\t\tgoto fail;\n\t}\n\t\n\tret = (PyArrayObject *)PyArray_New(ap1->ob_type, 1,\n\t\t\t\t\t &length, typenum, \n\t\t\t\t\t NULL, NULL, 0, 0, ap1);\n\tif (ret == NULL) goto fail;\n\n\t\n\tdot = ret->descr->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"function not available for this type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->itemsize;\n\t\n\tip1 = ap1->data; ip2 = ap2->data+n_left*is2;\n\tn = n-n_left;\n\tfor(i=0; idescr->argmax;\n\tif (arg_func == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"data type not ordered\");\n\t\tgoto fail;\n\t}\n\n\trp = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd-1,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, ap);\n\tif (rp == NULL) goto fail;\n\n\n\telsize = ap->itemsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) {\n\t\tPyErr_SetString(MultiArrayError, \n\t\t\t\t\"Attempt to get argmax/argmin \"\\\n\t\t\t\t\"of an empty sequence??\");\n\t\tgoto fail;\n\t}\n\tn = PyArray_SIZE(ap)/m;\n\trptr = (intp *)rp->data;\n\tfor (ip = ap->data, i=0; ind + indices->nd - 1;\n for (i=0; i< nd; i++) {\n if (i < axis) {\n shape[i] = self->dimensions[i];\n n *= shape[i];\n } else {\n if (i < axis+indices->nd) {\n shape[i] = indices->dimensions[i-axis];\n m *= shape[i];\n } else {\n shape[i] = self->dimensions[i-indices->nd+1];\n chunk *= shape[i];\n }\n }\n }\n ret = (PyArrayObject *)PyArray_New(self->ob_type, nd, shape, \n\t\t\t\t\t self->descr->type_num,\n\t\t\t\t\t NULL, NULL, 0, 0, self);\n\t\n if (ret == NULL) goto fail;\n\t\n max_item = self->dimensions[axis];\n chunk = chunk * ret->itemsize;\n src = self->data;\n dest = ret->data;\n\t\n for(i=0; idata))[j];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"Index out of range for \"\\\n\t\t\t\t\t\t\"array\");\n goto fail;\n }\n memmove(dest, src+tmp*chunk, chunk);\n dest += chunk;\n }\n src += chunk*max_item;\n }\n\t\n PyArray_INCREF(ret);\n\n Py_XDECREF(indices);\n Py_XDECREF(self);\n\n return (PyObject *)ret;\n\t\n\t\n fail:\n Py_XDECREF(ret);\n Py_XDECREF(indices);\n Py_XDECREF(self);\n return NULL;\n}\n\nstatic PyObject *\nPyArray_Put(PyArrayObject *self, PyObject *indices0, PyObject* values0) \n{\n PyArrayObject *indices, *values;\n int i, chunk, ni, max_item, nv, tmp; \n char *src, *dest;\n\n indices = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be contiguous\");\n return NULL;\n }\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->itemsize;\n\n indices = (PyArrayObject *)PyArray_ContiguousFromObject(indices0, PyArray_INTP, 0, 0);\n if (indices == NULL) goto fail;\n ni = PyArray_SIZE(indices);\n\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromObject(values0, self->descr->type_num, \n\t\t\t\t\t 0, 0);\n if (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\n if (nv > 0) { /* nv == 0 for a null array */\n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"Index out of range for array\");\n goto fail;\n }\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n\n Py_XDECREF(values);\n Py_XDECREF(indices);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(indices);\n Py_XDECREF(values);\n return NULL;\n}\n\nstatic PyObject *\nPyArray_PutMask(PyArrayObject *self, PyObject *mask0, PyObject* values0) \n{\n PyArrayObject *mask, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype;\n char *src, *dest;\n\n mask = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must \"\\\n\t\t\t\t\"be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must be contiguous\");\n return NULL;\n }\n\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->itemsize;\n\n mask = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromObject(mask0, PyArray_BOOL, 0, 0);\n if (mask == NULL) goto fail;\n ni = PyArray_SIZE(mask);\n if (ni != max_item) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: mask and data must be \"\\\n\t\t\t\t\"the same size.\");\n goto fail;\n }\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromObject(values0, thistype, 0, 0);\n\tif (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\t /* zero if null array */\n if (nv > 0) {\n\t\tfor(i=0; idata + chunk * (i % nv);\n\t\t\ttmp = ((Bool *)(mask->data))[i];\n\t\t\tif (tmp) {\n\t\t\t\tmemmove(dest + i * chunk, src, chunk);\n\t\t\t\tif (thistype == PyArray_OBJECT)\n\t\t\t\t\tPy_INCREF(*((PyObject **)src));\n\t\t\t}\n\t\t}\n }\n\n Py_XDECREF(values);\n Py_XDECREF(mask);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(mask);\n Py_XDECREF(values);\n return NULL;\n}\n\n\n/* This conversion function can be used with the \"O&\" argument for\n PyArg_ParseTuple. It will immediately return an object of array type\n or will convert to a CARRAY any other object. \n\n If you use PyArray_Converter, you must DECREF the array when finished\n as you get a new reference to it.\n*/\n \nstatic int \nPyArray_Converter(PyObject *object, PyObject **address) \n{\n if (PyArray_Check(object)) {\n *address = object;\n\t\tPy_INCREF(object);\n return PY_SUCCEED;\n }\n else {\n\t\t*address = PyArray_FromAny(object, NULL, 0, 0, CARRAY_FLAGS);\n\t\tif (*address == NULL) return PY_FAIL;\n\t\treturn PY_SUCCEED;\n }\n}\n\nstatic int\nPyArray_BoolConverter(PyObject *object, Bool *val)\n{\n\tif (PyObject_IsTrue(object)) *val=TRUE;\n\telse *val=FALSE;\n\tif (PyErr_Occurred()) return PY_FAIL;\n\treturn PY_SUCCEED;\n}\n\n\nstatic int\nPyArray_TypestrConvert(int itemsize, int gentype)\n{\n\tregister int newtype = gentype;\n\t\n\tif (gentype == PyArray_SIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_INT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_INT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_INT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_INT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_INT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\n\t}\n\n\telse if (gentype == PyArray_UNSIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_UINT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_UINT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_UINT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_UINT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_UINT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if (gentype == PyArray_FLOATINGLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 4:\n\t\t\tnewtype = PyArray_FLOAT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_FLOAT64;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 10:\n\t\t\tnewtype = PyArray_FLOAT80;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 12:\n\t\t\tnewtype = PyArray_FLOAT96;\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_FLOAT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\t\n\telse if (gentype == PyArray_COMPLEXLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 8:\n\t\t\tnewtype = PyArray_COMPLEX64;\n\t\t\tbreak;\n\t\tcase 16:\n\t\t\tnewtype = PyArray_COMPLEX128;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 20:\n\t\t\tnewtype = PyArray_COMPLEX160;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 24:\n\t\t\tnewtype = PyArray_COMPLEX192;\t\t\t\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 32:\n\t\t\tnewtype = PyArray_COMPLEX256;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\n\treturn newtype;\n}\n\n\n/* this function takes a Python object which exposes the (single-segment)\n buffer interface and returns a pointer to the data segment\n \n You should increment the reference count by one of buf->base\n if you will hang on to a reference\n\n You only get a borrowed reference to the object. Do not free the\n memory...\n*/\n\n\nstatic int\nPyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)\n{\n int buflen;\n\n buf->ptr = NULL;\n buf->flags = WRITEABLE;\n buf->base = NULL;\n\n\tif (obj == Py_None)\n\t\treturn PY_SUCCEED;\n\n if (PyObject_AsWriteBuffer(obj, &(buf->ptr), &buflen) < 0) {\n PyErr_Clear();\n buf->flags &= ~WRITEABLE;\n if (PyObject_AsReadBuffer(obj, (const void **)&(buf->ptr), \n &buflen) < 0)\n return PY_FAIL;\n }\n buf->len = (intp) buflen;\n \n /* Point to the base of the buffer object if present */\n if (PyBuffer_Check(obj)) buf->base = ((PyArray_Chunk *)obj)->base;\n if (buf->base == NULL) buf->base = obj;\n \n return PY_SUCCEED; \n}\n\n\n\n/* This function takes a Python sequence object and allocates and\n fills in an intp array with the converted values.\n\n **Remember to free the pointer seq.ptr when done using\n PyDimMem_FREE(seq.ptr)**\n*/\n\nstatic int\nPyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)\n{\n int len;\n int nd;\n\n seq->ptr = NULL;\n if (obj == Py_None) return PY_SUCCEED;\n len = PySequence_Size(obj);\n if (len == -1) { /* Check to see if it is a number */\n if (PyNumber_Check(obj)) len = 1;\n }\n if (len < 0) {\n PyErr_SetString(PyExc_TypeError, \n \"Expected sequence object with len >= 0\");\n return PY_FAIL;\n }\n if (len > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError, \"Sequence too large, \" \\\n \"must be smaller than %d\", MAX_DIMS);\n return PY_FAIL;\n }\n\tif (len > 0) {\n\t\tseq->ptr = PyDimMem_NEW(len);\n\t\tif (seq->ptr == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n seq->len = len;\n nd = PyArray_IntpFromSequence(obj, (intp *)seq->ptr, len);\n if (nd == -1 || nd != len) goto fail;\n return PY_SUCCEED;\n\n fail:\n\tPyDimMem_FREE(seq->ptr);\n\treturn PY_FAIL;\n}\n\n/* This function takes a Python object representing a type and converts it \n to a C type_num and an itemsize (elements of PyArray_Typecode structure)\n \n Many objects can be used to represent a type.\n */\n\nstatic int\nPyArray_TypecodeConverter(PyObject *obj, PyArray_Typecode *at)\n{\n char *type;\n PyArray_Descr *descr;\n int check_num=PyArray_NOTYPE+10;\n\tint len;\n\tPyObject *item, *attr=NULL;\n\n\tat->itemsize = 0;\n if (obj == Py_None) {\n at->type_num = PyArray_NOTYPE;\n return PY_SUCCEED;\n }\n\n if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, \n &PyGenericArrType_Type)) {\n PyArray_TypecodeFromTypeObject(obj, at);\n return PY_SUCCEED;\n }\n\n\n\t/* type object could be an array */\n\tif (PyArray_Check(obj)) {\n\t\tat->type_num = PyArray_TYPE(obj);\n\t\tat->itemsize = PyArray_ITEMSIZE(obj);\n\t\treturn PY_SUCCEED;\n\t}\n\n\t/* or an array scalar */\n if (PyArray_IsScalar(obj, Generic)) {\n PyArray_TypecodeFromScalar(obj, at);\n return PY_SUCCEED;\n }\n\n\t/* or a typecode string */\n\n\tif (PyString_Check(obj)) {\n\t\t/* Check for a string typecode. */\n\t\ttype = PyString_AS_STRING(obj);\n\t\tlen = PyString_GET_SIZE(obj);\t\t\n\t\tif (len > 0) {\n\t\t\tcheck_num = (int) type[0];\n\t\t}\n\t\tif (len > 1) {\n\t\t\tat->itemsize = atoi(type+1);\n\t\t\t/* When specifying length of UNICODE\n\t\t\t the number of characters is given to match \n\t\t\t the STRING interface. Each character can be\n\t\t\t more than one byte and itemsize must be\n\t\t\t the number of bytes.\n\t\t\t*/\n\t\t\tif (check_num == PyArray_UNICODELTR ||\t\\\n\t\t\t check_num == PyArray_UNICODE) \n\t\t\t at->itemsize *= sizeof(Py_UNICODE);\n\n\t\t\t/* Support for generic processing */\n\t\t\telse if ((check_num != PyArray_STRINGLTR) &&\n\t\t\t\t (check_num != PyArray_VOIDLTR) &&\n\t\t\t\t (check_num != PyArray_STRING) &&\n\t\t\t\t (check_num != PyArray_VOID)) {\n\t\t\t\tcheck_num = \\\n\t\t\t\t\tPyArray_TypestrConvert(at->itemsize, \n\t\t\t\t\t\t\t check_num);\n\t\t\t at->itemsize = 0;\n\t\t\t\tif (check_num == PyArray_NOTYPE) goto fail;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Arbitray object with dtypenum and itemsize attributes. */\n\telse if (PyObject_HasAttrString(obj, \"dtypenum\") && \n\t PyObject_HasAttrString(obj, \"itemsize\")) {\n\t\tattr = PyObject_GetAttrString(obj, \"dtypenum\");\n\t\tcheck_num = PyInt_AsLong(attr);\n\t\tif (PyErr_Occurred()) { /* not an integer, try character */\n\t\t\tPyErr_Clear();\n\t\t\ttype = PyString_AsString(attr);\n\t\t\tcheck_num = (int) type[0];\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tif (!PyErr_Occurred()) {\n\t\t\tattr = PyObject_GetAttrString(obj, \"itemsize\");\n\t\t\tat->itemsize = PyInt_AsLong(attr);\n\t\t\tPy_XDECREF(attr);\n\t\t}\t\t\t\n\t}\t\t\n\telse if (PyType_Check(obj)) {\n\t\tcheck_num = PyArray_OBJECT;\n\t\tif (obj == (PyObject *)(&PyInt_Type)) \n\t\t\tcheck_num = PyArray_LONG;\n\t\telse if (obj == (PyObject *)(&PyBool_Type))\n\t\t\tcheck_num = PyArray_BOOL;\n\t\telse if (obj == (PyObject *)(&PyFloat_Type)) \n\t\t\tcheck_num = PyArray_DOUBLE;\n\t\telse if (obj == (PyObject *)(&PyComplex_Type)) \n\t\t\tcheck_num = PyArray_CDOUBLE;\n else if (obj == (PyObject *)(&PyString_Type))\n check_num = PyArray_STRING;\n else if (obj == (PyObject *)(&PyUnicode_Type))\n check_num = PyArray_UNICODE;\n\t}\t\n else { /* Default -- try integer conversion */\n check_num = PyInt_AsLong(obj);\n\t}\n\n\tif (PyErr_Occurred()) goto fail;\n\n\t/*\n\tif (check_num == PyArray_NOTYPE) return PY_FAIL;\n\t*/\n\tif (check_num == PyArray_NOTYPE) {\n\t\tat->type_num = PyArray_NOTYPE;\n\t\tat->itemsize = 0;\n\t\treturn PY_SUCCEED;\n\t}\n\n if ((descr = PyArray_DescrFromType(check_num))==NULL) {\n\t\t/* Now check to see if the object is registered\n\t\t in typeDict */\n\t\tif (typeDict != NULL) {\n\t\t\titem = PyDict_GetItem(typeDict, obj);\n\t\t\tif (item) {\n\t\t\t\tPyArray_TypecodeFromTypeObject(obj, at);\n\t\t\t\tPyErr_Clear();\n\t\t\t\treturn PY_SUCCEED;\n\t\t\t}\n\t\t}\n return PY_FAIL;\n\t}\n\t\n at->type_num = descr->type_num;\n\tif (at->itemsize == 0) at->itemsize = descr->elsize;\n\t\n return PY_SUCCEED;\n fail:\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"data type not understood\");\n\treturn PY_FAIL;\n}\t\n\n\n/* This function returns true if the two typecodes are \n equivalent (same basic kind and same itemsize).\n*/\n\nstatic Bool\nPyArray_EquivalentTypes(PyArray_Typecode *typ1, PyArray_Typecode *typ2)\n{\n\tregister int typenum1=typ1->type_num;\n\tregister int typenum2=typ2->type_num;\n\tregister int size1=typ1->itemsize;\n\tregister int size2=typ2->itemsize;\n\n\tif (size1 != size2) return FALSE;\n\tif (typenum1==typenum2) return TRUE;\n\n\t/* If we are here then size1 == size2 */\n\tif (typenum1 < PyArray_FLOAT) {\n\t\tif (PyTypeNum_ISBOOL(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISBOOL(typenum2));\n\t\telse if (PyTypeNum_ISUNSIGNED(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISUNSIGNED(typenum2));\n\t\telse \n\t\t\treturn (Bool)(PyTypeNum_ISSIGNED(typenum2));\n\t}\n\telse {\n\t\tif (PyTypeNum_ISFLOAT(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISFLOAT(typenum2));\n\t\telse if (PyTypeNum_ISCOMPLEX(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISCOMPLEX(typenum2));\n\t}\n\t/* Default size1 != size2 and typenum1 != typenum2 */\n\treturn FALSE;\t\n}\n\nstatic Bool \nPyArray_EquivArrTypes(PyArrayObject *a1, PyArrayObject *a2)\n{\n PyArray_Typecode type1={PyArray_TYPE(a1), PyArray_ITEMSIZE(a1), 0};\n PyArray_Typecode type2={PyArray_TYPE(a2), PyArray_ITEMSIZE(a2), 0};\n \n return PyArray_EquivalentTypes(&type1, &type2);\n}\n\n\n/*** END C-API FUNCTIONS **/\n\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0) will return a new array formed from the given object type given. Object can anything with an __array__ method, or any (nested) sequence. If no type is given, then the type will be determined as the minimum type required to hold the objects in the sequence. If copy is zero and sequence is already an array with the right type, a reference will be returned. If the sequence is an array, type can be used only to upcast the array. For downcasting use .astype(t) method.\";\n\nstatic PyObject *\n_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)\n{\n\tPyObject *op, *ret=NULL;\n\tstatic char *kwd[]= {\"object\", \"dtype\", \"copy\", \"fortran\", NULL};\n\tBool copy=TRUE;\n\tPyArray_Typecode type = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode oldtype = {PyArray_NOTYPE, 0, 0};\n\tint type_num;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_TypecodeConverter,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran)) \n\t\treturn NULL;\n\ttype_num = type.type_num;\n\n\t/* fast exit if simple call */\n\tif (PyArray_Check(op) && (copy==0) &&\t\t\t\\\n\t (fortran == PyArray_CHKFLAGS(op, FORTRAN))) {\n\t\tif (type_num == PyArray_NOTYPE) {\n\t\t\tPy_INCREF(op);\n\t\t\treturn op;\n\t\t}\n\t\t/* One more chance */\n\t\toldtype.type_num = PyArray_TYPE(op);\n\t\toldtype.itemsize = PyArray_ITEMSIZE(op);\n\t\tif (PyArray_EquivalentTypes(&oldtype, &type)) {\n\t\t\tPy_INCREF(op);\n\t\t\treturn op;\n\t\t}\n\t}\n\n\ttype.fortran = fortran; \n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\n\tif ((ret = PyArray_FromAny(op, &type, 0, 0, flags)) == NULL) \n\t\treturn NULL;\n\n\treturn _ARET(ret);\n}\n\nstatic PyObject *\nPyArray_Empty(int nd, intp *dims, PyArray_Typecode *type)\n{\n\tPyArrayObject *ret;\n\tintp n;\n \n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, nd, dims, \n\t\t\t\t\t type->type_num,\n\t\t\t\t\t NULL, NULL, type->itemsize, \n\t\t\t\t\t type->fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tn = PyArray_SIZE(ret);\n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n PyArray_FillObjectArray(ret, Py_None);\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic char doc_empty[] = \"empty((d1,...,dn),dtype=intp,fortran=0) will return a new array\\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.\";\n\nstatic PyObject *\narray_empty(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0, 0};\n PyArray_Dims shape;\n\tBool fortran = FALSE;\t\n PyObject *ret;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_TypecodeConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter, &fortran)) \n\t\treturn NULL;\n\t\n\ttypecode.fortran = fortran;\n if (typecode.type_num ==PyArray_NOTYPE) \n\t\ttypecode.type_num = PyArray_INTP;\n \n\tret = PyArray_Empty(shape.len, shape.ptr, &typecode); \n PyDimMem_FREE(shape.ptr);\n return ret;\n}\n\nstatic char doc_scalar[] = \"scalar(dtypestr,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. typestr must be a valid data typestr (complete with < > or |). If dtypestr is object, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.\";\n\nstatic PyObject *\narray_scalar(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"dtypestr\",\"obj\", NULL};\n\tPyArray_Typecode typecode;\n\tPyObject *obj=NULL;\n\tchar *typestr;\n\tint typestrlen;\n\tint swap, alloc=0;\n\tvoid *dptr;\n\tPyObject *ret;\n\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"z#|O\",\n\t\t\t\t\t kwlist, &typestr, &typestrlen,\n\t\t\t\t\t &obj)) \n\t\treturn NULL;\n\t\n\tif (_array_typecode_fromstr(typestr, &swap, &typecode) < 0) \n\t\treturn NULL;\n\t\n\tif (typecode.itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\t\t\\\n\t\t\t\t\"itemsize cannot be zero\");\n\t\treturn NULL;\n\t}\n\n\tif (typecode.type_num == PyArray_OBJECT) {\n\t\tif (obj == NULL) obj = Py_None;\n\t\tdptr = &obj;\n\t\tswap = 0;\n\t}\n\telse {\n\t\tif (obj == NULL) {\n\t\t\tdptr = malloc(typecode.itemsize);\n\t\t\tif (dptr == NULL) {\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemset(dptr, '\\0', typecode.itemsize);\n\t\t\talloc = 1;\n\t\t}\n\t\telse {\n\t\t\tif (!PyString_Check(obj)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"initializing object must \"\\\n\t\t\t\t\t\t\"be a string.\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (PyString_GET_SIZE(obj) < typecode.itemsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"initialization string is too\"\\\n\t\t\t\t\t\t\" small\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = PyString_AS_STRING(obj);\n\t\t}\n\t}\n\n\tret = PyArray_Scalar(dptr, typecode.type_num,\n\t\t\t typecode.itemsize, swap); \n\n\t/* free dptr which contains zeros */\n\tif (alloc) free(dptr);\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_Zeros(int nd, intp *dims, PyArray_Typecode *type)\n{\n\tPyArrayObject *ret;\n\tintp n;\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, nd, dims, \n\t\t\t\t\t type->type_num,\n\t\t\t\t\t NULL, NULL, type->itemsize, \n\t\t\t\t\t type->fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tn = PyArray_SIZE(ret);\n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n\t\tPyObject *zero = PyInt_FromLong(0);\n PyArray_FillObjectArray(ret, zero);\n Py_DECREF(zero);\n\t}\n\telse {\t\t\n\t\tmemset(ret->data, 0, n*(ret->itemsize));\n\t}\n\treturn (PyObject *)ret;\n\n}\n\nstatic char doc_zeros[] = \"zeros((d1,...,dn),dtype=intp,fortran=0) will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.\";\n\n\nstatic PyObject *\narray_zeros(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0, 0};\n PyArray_Dims shape;\n\tBool fortran = FALSE;\t\n PyObject *ret;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_TypecodeConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\treturn NULL;\n\t\n\ttypecode.fortran = fortran;\n if (typecode.type_num ==PyArray_NOTYPE) \n\t\ttypecode.type_num = PyArray_INTP;\n \n\tret = PyArray_Zeros(shape.len, shape.ptr, &typecode); \n PyDimMem_FREE(shape.ptr);\n return ret;\n}\n\nstatic char doc_set_typeDict[] = \"set_typeDict(dict) set the internal \"\\\n\t\"dictionary that can look up an array type using a registered \"\\\n\t\"code\";\n\nstatic PyObject *\narray_set_typeDict(PyObject *ignored, PyObject *args)\n{\n\tPyObject *dict;\n\tif (!PyArg_ParseTuple(args, \"O\", &dict)) return NULL;\n\tPy_XDECREF(typeDict); /* Decrement old reference (if any)*/\n\ttypeDict = dict;\n\tPy_INCREF(dict); /* Create an internal reference to it */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=intp, count=-1, swap=False) returns a new 1d array initialized from the raw binary data in string. If count is positive, the new array will have count elements, otherwise it's size is determined by the size of string.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyArrayObject *ret; \n\tchar *data;\n\tlonglong nin=-1;\n\tintp s, n;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", \"swap\",NULL};\n\tPyArray_Typecode type = {PyArray_INTP, sizeof(intp), 0};\n\tint itemsize;\n\tint swapped=FALSE;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&LO&\", kwlist, \n\t\t\t\t\t &data, &s, \n\t\t\t\t\t PyArray_TypecodeConverter, &type,\n\t\t\t\t\t &nin, \n\t\t\t\t\t PyArray_BoolConverter,\n\t\t\t\t\t &swapped)) {\n\t\treturn NULL;\n\t}\n\t\n\tn = (intp) nin;\n\n\titemsize = type.itemsize;\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"zero-valued itemsize.\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tif ((ret = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &n, \n\t\t\t\t\t\ttype.type_num, NULL, \n\t\t\t\t\t\tNULL, itemsize, 0,\n\t\t\t\t\t\tNULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*ret->itemsize);\n\tif (swapped) ret->flags &= ~NOTSWAPPED;\n\tPyArray_INCREF(ret);\n\treturn (PyObject *)ret;\n}\n\n\n/* This needs an open file object and reads it in directly. \n memory-mapped files handled differently through buffer interface.\n\nfile pointer number in resulting 1d array \n(can easily reshape later, -1 for to end of file)\ntype of array\nsep is a separator string for character-based data (or NULL for binary)\n \" \" means whitespace\n*/\n\nstatic char doc_fromfile[] = \"\";\n\nstatic int\n_fill_in_itemsize(PyArray_Typecode *typecode)\n{\n\tPyArray_Descr *descr;\n\tdescr = PyArray_DescrFromType(typecode->type_num);\n\tif (descr==NULL) return -1;\n\ttypecode->itemsize = descr->elsize;\n\treturn 0;\n}\n\n\nstatic PyObject *\nPyArray_FromFile(FILE *fp, PyArray_Typecode *typecode, intp num, char *sep)\n{\n\tPyArrayObject *r;\n\tsize_t nread = 0;\n\tPyArray_ScanFunc *scan;\n\n\tif (typecode->itemsize == 0) {\n\t\tif (_fill_in_itemsize(typecode) < 0) \n\t\t\treturn NULL;\n\t}\n\n\tif (num == -1 && sep == NULL) { /* Get size for binary file*/\n\t\tintp start, numbytes;\n\t\tstart = (intp )ftell(fp);\n\t\tfseek(fp, 0, SEEK_END);\n\t\tnumbytes = (intp )ftell(fp) - start;\n\t\tfseek(fp, (long) start, SEEK_SET);\n\t\tif (numbytes == -1) {\n\t\t\tPyErr_SetString(PyExc_IOError, \"Could not seek in file.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (typecode->itemsize == 0) {\n\t\t\ttypecode->itemsize = numbytes;\n\t\t\tnum = 1;\n\t\t}\n\t\telse {\n\t\t\tnum = numbytes / typecode->itemsize;\n\t\t}\n\t}\n\t\n\tif (sep==NULL) { /* binary data */\n\t\tr = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &num, \n\t\t\t\t\t\t typecode->type_num,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t typecode->itemsize, 0, NULL);\n\t\tif (r==NULL) return NULL;\n\t\tnread = fread(r->data, typecode->itemsize, num, fp);\n\t}\n\telse { /* character reading */\n\t\tintp i;\n\t\tchar *dptr;\n\n\t\tif (num != -1) { /* number to read is known */\n\t\t\tr = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, \n\t\t\t\t\t\t\t &num, \n\t\t\t\t\t\t\t typecode->type_num,\n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t typecode->itemsize, \n\t\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\tscan = r->descr->scanfunc;\n\t\t\tif (scan == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"Don't know how to read \"\\\n\t\t\t\t\t\t\"character files with that \"\\\n\t\t\t\t\t\t\"array type\");\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = r->data;\n\t\t\tfor (i=0; i < num-1; i++) {\n\t\t\t\tif (scan(fp, dptr, r->itemsize, sep, NULL))\n\t\t\t\t\tbreak;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->itemsize;\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (!(scan(fp, dptr, r->itemsize, NULL, NULL)))\n\t\t\t\tnread += 1;\n\t\t}\n\t\telse { /* we have to watch for the end of the file and \n\t\t\t reallocate at the end */\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\t\t\tint done=0;\n\t\t\tr = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, \n\t\t\t\t\t\t\t &size, \n\t\t\t\t\t\t\t typecode->type_num,\n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t typecode->itemsize, \n\t\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * typecode->itemsize;\n\t\t\tdptr = r->data;\n\t\t\tscan = r->descr->scanfunc;\n\t\t\tif (scan == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"Don't know how to read \"\\\n\t\t\t\t\t\t\"character files with that \"\\\n\t\t\t\t\t\t\"array type\");\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\twhile (!done) {\n\t\t\t\tdone = scan(fp, dptr, r->itemsize, sep, NULL);\n\t\t\t\t/* end of file reached trying to \n\t\t\t\t scan value \n\t\t\t\t*/\n\t\t\t\tif (done == 1 || done < 0) break;\n\t\t\t\n\t\t\t\tthisbuf += 1;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->itemsize;\n\t\t\t\tif (!done && thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tr->data = PyDataMem_RENEW(r->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = r->data + (totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tr->data = PyDataMem_RENEW(r->data, nread*r->itemsize);\n\t\t\tPyArray_DIM(r,0) = nread;\n\t\t\tnum = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\tif (nread < num) {\n\t\tchar msg[80];\n\t\tsnprintf(msg, 80, \n\t\t\t \"%ld items requested only %ld read\", (long) num, \n (long) nread);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) {\n\t\t\tPy_DECREF(r);\n\t\t\treturn NULL;\n\t\t}\n\t\tr->data = PyDataMem_RENEW(r->data, nread * r->itemsize);\n\t\tPyArray_DIM(r,0) = nread;\n\t}\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *file=NULL, *ret;\n\tFILE *fp;\n\tchar *sep=\"\";\n\tchar *mode=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"file\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Typecode type = {PyArray_INTP, sizeof(intp), 0};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Ls\", kwlist, \n\t\t\t\t\t &file,\n\t\t\t\t\t PyArray_TypecodeConverter, &type,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"rb\";\n\t\telse mode=\"r\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfp = PyFile_AsFile(file);\n\tif (fp == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \"First argument must be an open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_FromFile(fp, &type, (intp) nin, sep);\n\tPy_DECREF(file);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_FromBuffer(PyObject *buf, PyArray_Typecode *type, \n\t\t intp count, int swapped) \n{\n\tPyArrayObject *ret;\n\tchar *data;\n\tint ts;\n\tintp s, n;\n\tint itemsize;\n\tint write=1;\n\n\tif (type->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an OBJECT array from memory\"\\\n\t\t\t\t\" buffer.\");\n\t\treturn NULL;\n\t}\n\tif (type->itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Itemsize cannot be zero in type\");\n\t\treturn NULL;\n\t}\n\n\tif (PyObject_AsWriteBuffer(buf, (void *)&data, &ts)==-1) {\n\t\twrite = 0;\n\t\tPyErr_Clear();\n\t\tif (PyObject_AsReadBuffer(buf, (void *)&data, &ts)==-1) {\n\t\t\treturn NULL;\n\t\t}\n\t}\n\ts = (intp)ts;\t\n\tn = (intp)count;\n\titemsize = type->itemsize;\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &n, \n\t\t\t\t\t\ttype->type_num, NULL, \n\t\t\t\t\t\tdata, itemsize, DEFAULT_FLAGS,\n\t\t\t\t\t\tNULL)) == NULL)\n\t\treturn NULL;\n\t\n\tif (!write) ret->flags &= ~WRITEABLE;\n\tif (swapped) ret->flags &= ~NOTSWAPPED;\n\tPy_INCREF(buf);\n\t/* Store a reference for decref on deallocation */\n\tret->base = buf;\n\tPyArray_UpdateFlags(ret, ALIGNED);\n\treturn (PyObject *)ret; \t\n}\n\nstatic char doc_frombuffer[] = \"\";\n\nstatic PyObject *\narray_frombuffer(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *obj=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"buffer\", \"dtype\", \"count\", \n\t\t\t\t \"swap\", NULL};\n\tPyArray_Typecode type = {PyArray_INTP, sizeof(intp), 0};\n\tint swapped=0;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Li\", kwlist, \n\t\t\t\t\t &obj,\n\t\t\t\t\t PyArray_TypecodeConverter, &type,\n\t\t\t\t\t &nin, &swapped)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromBuffer(obj, &type, (intp)nin, swapped);\n}\n\n\n\nstatic char doc_concatenate[] = \"concatenate((a1,a2,...),axis=None).\";\n\nstatic PyObject *\narray_concatenate(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *a0;\n\tint axis=0;\n\tstatic char *kwlist[] = {\"seq\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist,\n\t\t\t\t\t &a0,\n\t\t\t\t\t PyArray_AxisConverter, &axis))\n\t\treturn NULL;\n\treturn PyArray_Concatenate(a0, axis);\n}\n\nstatic char doc_innerproduct[] = \\\n\t\"inner(a,b) returns the dot product of two arrays, which has\\n\"\\\n\t\"shape a.shape[:-1] + b.shape[:-1] with elements computed by\\n\" \\\n\t\"the product of the elements from the last dimensions of a and b.\";\n\nstatic PyObject *array_innerproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *b0, *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a0, &b0)) return NULL;\n\t\n\treturn _ARET(PyArray_InnerProduct(a0, b0));\n}\n\nstatic char doc_matrixproduct[] = \\\n\t\"dot(a,v) returns matrix-multiplication between a and b. \\n\"\\\n\t\"The product-sum is over the last dimension of a and the \\n\"\\\n\t\"second-to-last dimension of b.\";\n\nstatic PyObject *array_matrixproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *v, *a;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a, &v)) return NULL;\n\t\n\treturn _ARET(PyArray_MatrixProduct(a, v));\n}\n\nstatic char doc_fastCopyAndTranspose[] = \"_fastCopyAndTranspose(a)\";\n\nstatic PyObject *array_fastCopyAndTranspose(PyObject *dummy, PyObject *args) {\n\tPyObject *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &a0)) return NULL;\n\t\n\treturn _ARET(PyArray_CopyAndTranspose(a0));\n}\n\nstatic char doc_correlate[] = \"cross_correlate(a,v, mode=0)\";\n\nstatic PyObject *array_correlate(PyObject *dummy, PyObject *args, PyObject *kwds) {\n\tPyObject *shape, *a0;\n\tint mode=0;\n\tstatic char *kwlist[] = {\"a\", \"v\", \"mode\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|i\", kwlist, \n\t\t\t\t\t &a0, &shape, &mode)) return NULL;\n\t\n\treturn PyArray_Correlate(a0, shape, mode);\n}\n\n\nstatic PyObject *\nPyArray_Arange(double start, double stop, double step, int type_num)\n{\n\tintp length, i;\n\tPyObject *range;\n\tchar *rptr;\n\tint elsize, type;\n\tdouble value;\n\tPyArray_Descr *dbl_descr;\n\n\tlength = (intp ) ceil((stop - start)/step);\n \n\tif (length <= 0) {\n\t\tlength = 0;\n\t\treturn PyArray_New(&PyArray_Type, 1, &length, type_num,\n\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t}\n\n\trange = PyArray_New(&PyArray_Type, 1, &length, type_num, \n\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (range == NULL) return NULL;\n\tdbl_descr = PyArray_DescrFromType(PyArray_DOUBLE);\n \n\trptr = ((PyArrayObject *)range)->data;\n\telsize = ((PyArrayObject *)range)->itemsize;\n\ttype = ((PyArrayObject *)range)->descr->type_num;\n\tfor (i=0; i < length; i++) {\n\t\tvalue = start + i*step;\n\t\tdbl_descr->cast[type]((char*)&value, rptr, 1, NULL, \n\t\t\t\t (PyArrayObject *)range);\n\t\trptr += elsize;\n\t}\n \n\treturn range;\n}\n\n\nstatic char doc_arange[] = \"arange(start, stop=None, step=1, dtype=intp)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\n\nstatic PyObject *\narray_arange(PyObject *ignored, PyObject *args, PyObject *kws) {\n\tPyObject *o_start=NULL, *o_stop=Py_None, *o_step=NULL;\n\tstatic char *kwd[]= {\"start\", \"stop\", \"step\", \"dtype\", NULL};\n\tdouble start, stop, step;\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0};\n\tint type_num;\n\tint deftype = PyArray_INTP;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|OOO&\", kwd, &o_start,\n\t\t\t\t\t&o_stop, &o_step, \n\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t&typecode)) \n\t\treturn NULL;\n\n\tdeftype = PyArray_ObjectType(o_start, deftype);\n\tif (o_stop != Py_None) {\n\t\tdeftype = PyArray_ObjectType(o_stop, deftype);\n\t}\n\tif (o_step != NULL) {\n\t\tdeftype = PyArray_ObjectType(o_step, deftype);\n\t}\n\n\ttype_num = typecode.type_num;\n\tif (type_num == PyArray_NOTYPE) {\n\t\ttype_num = deftype;\n\t}\n\n\tstart = PyFloat_AsDouble(o_start);\n\tif error_converting(start) return NULL;\n\n\tif (o_step == NULL) {\n\t\tstep = 1;\n\t}\n\telse {\n\t\tstep = PyFloat_AsDouble(o_step);\n\t\tif error_converting(step) return NULL;\n\t}\n\n\tif (o_stop == Py_None) {\n\t\tstop = start;\n\t\tstart = 0;\n\t}\n\telse {\n\t\tstop = PyFloat_AsDouble(o_stop);\n\t\tif error_converting(stop) return NULL;\n\t}\n\n\treturn PyArray_Arange(start, stop, step, type_num);\n}\n\n#undef _ARET\n\n/*****\n static char doc_arrayMap[] = \"arrayMap(func, [a1,...,an])\";\n\n static PyObject *array_arrayMap(PyObject *dummy, PyObject *args) {\n PyObject *shape, *a0;\n \n if (PyArg_ParseTuple(args, \"OO\", &a0, &shape) == NULL) return NULL;\n\t\n return PyArray_Map(a0, shape);\n }\n*****/\n\nstatic char \ndoc_set_string_function[] = \"set_string_function(f, repr=1) sets the python function f to be the function used to obtain a pretty printable string version of a array whenever a array is printed. f(M) should expect a array argument M, and should return a string consisting of the desired representation of M for printing.\";\n\nstatic PyObject *\narray_set_string_function(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *op;\n\tint repr=1;\n\tstatic char *kwlist[] = {\"f\", \"repr\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|i\", kwlist, \n\t\t\t\t\t&op, &repr)) return NULL; \n\tPyArray_SetStringFunction(op, repr);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char \ndoc_set_ops_function[] = \"set_numeric_ops(op=func, ...) sets some or all of the number methods for all array objects. Don't forget **dict can be used as the argument list. Returns the functions that were replaced -- can be stored and set later.\";\n\nstatic PyObject *\narray_set_ops_function(PyObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *oldops=NULL;\n\t\n\tif ((oldops = PyArray_GetNumericOps())==NULL) return NULL;\n\n\t/* Should probably ensure that objects are at least callable */\n\t/* Leave this to the caller for now --- error will be raised\n\t later when use is attempted \n\t*/\n\tif (PyArray_SetNumericOps(kwds) == -1) {\n\t\tPy_DECREF(oldops);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"One or more objects is not callable.\");\n\t\treturn NULL;\n\t}\n\treturn oldops;\n}\n\n\nstatic PyObject *\nPyArray_Where(PyObject *condition, PyObject *x, PyObject *y)\n{\n\tPyArrayObject *arr;\n\tPyObject *tup=NULL, *obj=NULL;\n\tPyObject *ret=NULL, *zero=NULL;\n\n\tif ((x==NULL) || (y==NULL)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"either both or neither\"\n\t\t\t\t\"of x and y should be given.\");\n\t\treturn NULL;\n\t}\n\n\tarr = (PyArrayObject *)PyArray_FromAny(condition, NULL, 0, 0, 0);\n\tif (arr == NULL) return NULL;\n\n\tif ((x==NULL) && (y==NULL)) {\n\t\tret = PyArray_Nonzero(arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\n\tzero = PyInt_FromLong((long) 0);\n\n\tobj = PyArray_EnsureArray(PyArray_GenericBinaryFunction(arr, zero, n_ops.not_equal));\n\tPy_DECREF(zero);\n\tPy_DECREF(arr);\n\tif (obj == NULL) return NULL;\n\n\ttup = Py_BuildValue(\"(OO)\", y, x);\n\tif (tup == NULL) {Py_DECREF(obj); return NULL;}\n\n\tret = PyArray_Choose((PyAO *)obj, tup);\n\n\tPy_DECREF(obj);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n\nstatic char doc_where[] = \"where(condition, | x, y) is shaped like condition\"\\\n\t\" and has elements of x and y where condition is respectively true or\"\\\n\t\" false. If x or y are not given, then it is equivalent to\"\\\n\t\" nonzero(condition).\";\n\nstatic PyObject *\narray_where(PyObject *ignored, PyObject *args)\n{\n\tPyObject *obj=NULL, *x=NULL, *y=NULL;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|OO\", &obj, &x, &y)) return NULL;\n\n\treturn PyArray_Where(obj, x, y);\n\n}\n\nstatic char doc_register_dtype[] = \\\n\t\"register_dtype(a) registers a new type object -- gives it a typenum\";\n\nstatic PyObject *\narray_register_dtype(PyObject *dummy, PyObject *args)\n{\n\tPyObject *dtype;\n\tint ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &dtype)) return NULL;\n\t\n\tret = PyArray_RegisterDataType((PyTypeObject *)dtype);\n\tif (ret < 0)\n\t\treturn NULL;\n\treturn PyInt_FromLong((long) ret);\n}\n\nstatic char doc_can_cast_safely[] = \\\n\t\"can_cast_safely(from=d1, to=d2) returns True if data type d1 \"\\\n\t\"can be cast to data type d2 without losing precision.\";\n\nstatic PyObject *\narray_can_cast_safely(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Typecode d1={PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode d2={PyArray_NOTYPE, 0, 0};\n\tBool ret;\n\tPyObject *retobj;\n\tstatic char *kwlist[] = {\"from\", \"to\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O&O&\", kwlist, \n\t\t\t\t\tPyArray_TypecodeConverter, &d1,\n\t\t\t\t\tPyArray_TypecodeConverter, &d2))\n\t\treturn NULL;\n\tif (d1.type_num == PyArray_NOTYPE || \\\n\t d2.type_num == PyArray_NOTYPE) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"did not understand one of the types. \"\\\n\t\t\t\t\"'None' not accepted.\");\n\t\treturn NULL;\n\t}\n\t\t\n\tret = PyArray_CanCastTo(&d1, &d2);\n\tretobj = (ret ? Py_True : Py_False);\n\tPy_INCREF(retobj);\n\treturn retobj;\n}\n\n\nstatic struct PyMethodDef array_module_methods[] = {\n\t{\"set_string_function\", (PyCFunction)array_set_string_function, \n\t METH_VARARGS|METH_KEYWORDS, doc_set_string_function},\n\t{\"set_numeric_ops\", (PyCFunction)array_set_ops_function,\n\t METH_VARARGS|METH_KEYWORDS, doc_set_ops_function},\n\t{\"set_typeDict\", (PyCFunction)array_set_typeDict,\n\t METH_VARARGS, doc_set_typeDict},\n\n\t{\"array\",\t(PyCFunction)_array_fromobject, \n\t METH_VARARGS|METH_KEYWORDS, doc_fromobject},\n\t{\"arange\", (PyCFunction)array_arange, \n\t METH_VARARGS|METH_KEYWORDS, doc_arange},\n\t{\"zeros\",\t(PyCFunction)array_zeros, \n\t METH_VARARGS|METH_KEYWORDS, doc_zeros},\n\t{\"empty\",\t(PyCFunction)array_empty, \n\t METH_VARARGS|METH_KEYWORDS, doc_empty},\n\t{\"scalar\", (PyCFunction)array_scalar,\n\t METH_VARARGS|METH_KEYWORDS, doc_scalar},\n\t{\"where\", (PyCFunction)array_where,\n\t METH_VARARGS, doc_where},\n\t{\"fromstring\",(PyCFunction)array_fromString,\n\t METH_VARARGS|METH_KEYWORDS, doc_fromString},\n\t{\"concatenate\", (PyCFunction)array_concatenate, \n\t METH_VARARGS|METH_KEYWORDS, doc_concatenate},\n\t{\"inner\", (PyCFunction)array_innerproduct, \n\t METH_VARARGS, doc_innerproduct}, \n\t{\"dot\", (PyCFunction)array_matrixproduct, \n\t METH_VARARGS, doc_matrixproduct}, \n\t{\"_fastCopyAndTranspose\", (PyCFunction)array_fastCopyAndTranspose, \n\t METH_VARARGS, doc_fastCopyAndTranspose},\n\t{\"correlate\", (PyCFunction)array_correlate, \n\t METH_VARARGS | METH_KEYWORDS, doc_correlate},\n\t{\"frombuffer\", (PyCFunction)array_frombuffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_frombuffer},\n\t{\"fromfile\", (PyCFunction)array_fromfile,\n\t METH_VARARGS | METH_KEYWORDS, doc_fromfile},\n\t{\"register_dtype\", (PyCFunction)array_register_dtype,\n\t METH_VARARGS, doc_register_dtype},\n\t{\"can_cast\", (PyCFunction)array_can_cast_safely,\n\t METH_VARARGS | METH_KEYWORDS, doc_can_cast_safely},\t\t\n\t/* {\"arrayMap\",\t(PyCFunction)array_arrayMap, \n\t METH_VARARGS, doc_arrayMap},*/\n\t\n\t{NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n#include \"__multiarray_api.c\"\n\n/* Establish scalar-type hierarchy */\n\n/* For dual inheritance we need to make sure that the objects being\n inherited from have the tp->mro object initialized. This is\n not necessarily true for the basic type objects of Python (it is \n checked for single inheritance but not dual in PyType_Ready).\n\n Thus, we call PyType_Ready on the standard Python Types, here.\n*/ \nstatic int\nsetup_scalartypes(PyObject *dict)\n{\n\n\tinitialize_numeric_types();\n\n if (PyType_Ready(&PyBool_Type) < 0) return -1;\n if (PyType_Ready(&PyInt_Type) < 0) return -1;\n if (PyType_Ready(&PyFloat_Type) < 0) return -1;\n if (PyType_Ready(&PyComplex_Type) < 0) return -1;\n if (PyType_Ready(&PyString_Type) < 0) return -1;\n if (PyType_Ready(&PyUnicode_Type) < 0) return -1;\n\n#define SINGLE_INHERIT(child, parent) \\\n Py##child##ArrType_Type.tp_base = &Py##parent##ArrType_Type;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) {\t\t\\\n PyErr_Print(); \\\n PyErr_Format(PyExc_SystemError, \\\n\t\t\t \"Could not initialize Py%sArrType_Tyupe\", \\\n #child); \\\n return -1;\t\t\t\t\t\t\\\n }\n \n if (PyType_Ready(&PyGenericArrType_Type) < 0)\n return -1;\n\n SINGLE_INHERIT(Numeric, Generic);\n SINGLE_INHERIT(Integer, Numeric);\n SINGLE_INHERIT(Inexact, Numeric);\n SINGLE_INHERIT(SignedInteger, Integer);\n SINGLE_INHERIT(UnsignedInteger, Integer);\n SINGLE_INHERIT(Floating, Inexact);\n SINGLE_INHERIT(ComplexFloating, Inexact);\n SINGLE_INHERIT(Flexible, Generic);\n SINGLE_INHERIT(Character, Flexible);\n\t\n#define DUAL_INHERIT(child, parent1, parent2) \\\n Py##child##ArrType_Type.tp_base = &Py##parent2##ArrType_Type;\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent2##ArrType_Type,\t\\\n\t\t\t &Py##parent1##_Type);\t\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"Could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n#define DUAL_INHERIT2(child, parent1, parent2)\t\t\t\t\\\n Py##child##ArrType_Type.tp_base = &Py##parent1##_Type;\t\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent1##_Type,\t\t\\\n\t\t\t &Py##parent2##ArrType_Type);\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"Could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n SINGLE_INHERIT(Bool, Generic);\n SINGLE_INHERIT(Byte, SignedInteger);\n SINGLE_INHERIT(Short, SignedInteger);\n#if SIZEOF_INT == SIZEOF_LONG\n DUAL_INHERIT(Int, Int, SignedInteger);\n#else\n SINGLE_INHERIT(Int, SignedInteger);\n#endif\n DUAL_INHERIT(Long, Int, SignedInteger);\n SINGLE_INHERIT(LongLong, SignedInteger);\n\n SINGLE_INHERIT(UByte, UnsignedInteger);\n SINGLE_INHERIT(UShort, UnsignedInteger);\n SINGLE_INHERIT(UInt, UnsignedInteger);\n SINGLE_INHERIT(ULong, UnsignedInteger);\n SINGLE_INHERIT(ULongLong, UnsignedInteger);\n\n SINGLE_INHERIT(Float, Floating);\n DUAL_INHERIT(Double, Float, Floating);\n SINGLE_INHERIT(LongDouble, Floating);\n\n SINGLE_INHERIT(CFloat, ComplexFloating);\n DUAL_INHERIT(CDouble, Complex, ComplexFloating);\n SINGLE_INHERIT(CLongDouble, ComplexFloating);\n\n DUAL_INHERIT2(String, String, Character);\n DUAL_INHERIT2(Unicode, Unicode, Character);\n\t\n SINGLE_INHERIT(Void, Flexible);\n \n SINGLE_INHERIT(Object, Generic);\n\n return 0;\n\n#undef SINGLE_INHERIT\n#undef DUAL_INHERIT\n\n\t/* Clean up string and unicode array types so they act more like\n\t strings -- get their tables from the standard types.\n\t \n\t \n\t*/\n}\n\n/* place a flag dictionary in d */\n\nstatic void\nset_flaginfo(PyObject *d)\n{\n PyObject *s;\n PyObject *newd;\n \n newd = PyDict_New();\n\n PyDict_SetItemString(newd, \"OWNDATA\", s=PyInt_FromLong(OWNDATA));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"FORTRAN\", s=PyInt_FromLong(FORTRAN));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"CONTIGUOUS\", s=PyInt_FromLong(CONTIGUOUS));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"ALIGNED\", s=PyInt_FromLong(ALIGNED));\n Py_DECREF(s);\n\n PyDict_SetItemString(newd, \"NOTSWAPPED\", s=PyInt_FromLong(NOTSWAPPED));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"UPDATEIFCOPY\", s=PyInt_FromLong(UPDATEIFCOPY));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"WRITEABLE\", s=PyInt_FromLong(WRITEABLE));\n Py_DECREF(s);\n \n PyDict_SetItemString(d, \"_flagdict\", newd);\n Py_DECREF(newd);\n return;\n}\n\n\n/* Initialization function for the module */\n\nDL_EXPORT(void) initmultiarray(void) {\n\tPyObject *m, *d, *s;\n\tPyObject *c_api;\n\t\n\t/* Create the module and add the functions */\n\tm = Py_InitModule(\"multiarray\", array_module_methods);\n\tif (!m) goto err;\n\n\t/* Add some symbolic constants to the module */\n\td = PyModule_GetDict(m);\n\tif (!d) goto err; \n\n\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\n\n\tif (PyType_Ready(&PyArray_Type) < 0)\n return;\n\n if (setup_scalartypes(d) < 0) goto err;\n\n\tif (PyType_Ready(&PyArrayIter_Type) < 0)\n\t\treturn; \n \n\tif (PyType_Ready(&PyArrayMapIter_Type) < 0)\n return; \n\n\tc_api = PyCObject_FromVoidPtr((void *)PyArray_API, NULL);\n\tif (PyErr_Occurred()) goto err;\n\tPyDict_SetItemString(d, \"_ARRAY_API\", c_api);\n\tPy_DECREF(c_api);\n\tif (PyErr_Occurred()) goto err;\n\n\tMultiArrayError = PyString_FromString (\"multiarray.error\");\n\tPyDict_SetItemString (d, \"error\", MultiArrayError);\n\t\n\ts = PyString_FromString(\"3.0\");\n\tPyDict_SetItemString(d, \"__version__\", s);\n\tPy_DECREF(s);\n Py_INCREF(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\n Py_INCREF(&PyArray_Type);\n\tPyDict_SetItemString(d, \"ndarray\", (PyObject *)&PyArray_Type);\n Py_INCREF(&PyArrayIter_Type);\n\tPyDict_SetItemString(d, \"flatiter\", (PyObject *)&PyArrayIter_Type);\n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\n set_flaginfo(d);\n\n\tif (set_typeinfo(d) == 0) \n return; /* otherwise there is an error */\n\n\n err:\t\n\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", "source_code_before": "\n/*\n Python Multiarray Module -- A useful collection of functions for creating and\n using ndarrays\n\n Original file \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n Modified for scipy_core in 2005 \n\n Travis E. Oliphant\n Assistant Professor at\n Brigham Young University\n \n*/\n\n/* $Id: multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp $ */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n/*#include \n#include \n*/\n\n#define _MULTIARRAYMODULE\n#include \"scipy/arrayobject.h\"\n\n#define PyAO PyArrayObject\n\nstatic PyObject *typeDict=NULL; /* Must be explicitly loaded */\n\n/* Including this file is the only way I know how to declare functions\n static in each file, and store the pointers from functions in both\n arrayobject.c and multiarraymodule.c for the C-API \n\n Declarying an external pointer-containing variable in arrayobject.c\n and trying to copy it to PyArray_API, did not work.\n\n Think about two modules with a common api that import each other...\n\n This file would just be the module calls. \n*/\n\n#include \"arrayobject.c\"\n\n\n/* An Error object -- rarely used? */\nstatic PyObject *MultiArrayError;\n\nstatic intp \nPyArray_MultiplyList(intp *l1, int n) \n{\n\tregister intp s=1;\n\tregister int i=0;\n while (i++ < n) s *= (*l1++);\n return s;\n}\n\n\nstatic int \nPyArray_AxisConverter(PyObject *obj, int *axis)\n{\n\tif (obj == Py_None) {\n\t\t*axis = MAX_DIMS;\n\t}\n\telse {\n\t\t*axis = (int) PyInt_AsLong(obj);\n\t\tif (PyErr_Occurred()) {\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\nstatic int \nPyArray_CompareLists(intp *l1, intp *l2, int n) \n{\n int i;\n for(i=0;itype_num;\n\t}\n\n\tnew = PyArray_New(self->ob_type,\n\t\t\t self->nd, self->dimensions,\n\t\t\t self->descr->type_num,\n\t\t\t self->strides,\n\t\t\t self->data,\n\t\t\t self->itemsize,\n\t\t\t self->flags, self);\n\n\tif (new==NULL) return NULL;\n\t\n Py_INCREF(self);\n PyArray_BASE(new) = (PyObject *)self;\n if ((type_num != PyArray_NOTYPE) && \\\n (type_num != self->descr->type_num)) {\n if (!PyTypeNum_ISFLEXIBLE(type_num)) {\n v = PyArray_TypeObjectFromType(type_num);\n }\n else {\n PyArray_Descr *descr;\n int itemsize = type->itemsize;\n descr = PyArray_DescrFromType(type_num);\n if (type_num == PyArray_UNICODE) \n itemsize /= sizeof(Py_UNICODE);\n /* construct a string representation */\n v = PyString_FromFormat(\"%c%d\", descr->type, \n itemsize);\n }\n if (v == NULL) goto fail;\n /* set attribute new.dtype = newtype */\n if (PyObject_SetAttrString(new, \"dtype\", v) < 0) goto fail;\n Py_DECREF(v);\n }\n\treturn new;\t\n\n fail:\n Py_XDECREF(v);\n Py_XDECREF(new);\n return NULL;\n}\n\nstatic PyObject *\nPyArray_Ravel(PyArrayObject *a, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n if (a->nd == 1) {\n Py_INCREF(a);\n return (PyObject *)a;\n }\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) \n\t\treturn PyArray_Newshape(a, &newdim);\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tsize = PyArray_SIZE(a);\n\tret = PyArray_New(a->ob_type,\n\t\t\t 1, &size,\n\t\t\t a->descr->type_num,\n\t\t\t NULL,\n NULL,\n\t\t\t a->itemsize,\n\t\t\t 0, a);\n\n\tif (ret== NULL) return NULL;\n\tif (fortran) {\n\t\tnew = PyArray_Transpose(a, NULL);\n\t\tif (new == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tPy_INCREF(a);\n\t\tnew = (PyObject *)a;\n\t}\n\tif (PyArray_CopyInto((PyArrayObject *)ret, (PyArrayObject *)new) < 0) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn NULL;\n\t}\n\tPy_DECREF(new);\n\treturn ret;\n}\n\n\n/* For back-ward compatability *\n\n/ * Not recommended */\n\nstatic PyObject *\nPyArray_Reshape(PyArrayObject *self, PyObject *shape) \n{\n PyObject *ret;\n PyArray_Dims newdims;\n\n if (!PyArray_IntpConverter(shape, &newdims)) return NULL;\n ret = PyArray_Newshape(self, &newdims);\n PyDimMem_FREE(newdims.ptr);\n return ret;\n}\n\n/* Returns a new array \n with the a new shape from the data\n in the old array\n*/\n\nstatic PyObject * \nPyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims)\n{\n intp i, s_original, i_unknown, s_known;\n intp *dimensions = newdims->ptr;\n PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n if ((s_known == 0) || (s_original % s_known != 0)) {\n PyErr_SetString(PyExc_ValueError, msg);\n goto fail;\n }\n dimensions[i_unknown] = s_original/s_known;\n } else {\n if (s_original != s_known) {\n PyErr_SetString(PyExc_ValueError, msg);\n goto fail;\n }\n }\n \n\tret = (PyAO *)PyArray_New(self->ob_type,\n\t\t\t\t n, dimensions,\n\t\t\t\t self->descr->type_num,\n\t\t\t\t NULL,\n\t\t\t\t self->data,\n\t\t\t\t self->itemsize,\n\t\t\t\t self->flags, self);\n\n\tif (ret== NULL)\n goto fail;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\n\t\n fail:\n return NULL;\n}\n\n/* return a new view of the array object with all of its unit-length \n dimensions squeezed out if needed, otherwise\n return the same array.\n */\n\nstatic PyObject *\nPyArray_Squeeze(PyArrayObject *self)\n{\n\tint nd = self->nd;\n\tint newnd = nd;\n\tintp dimensions[MAX_DIMS];\n\tintp strides[MAX_DIMS];\n\tint i,j;\n\tPyObject *ret;\n\n\tif (nd == 0) {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\tfor (j=0, i=0; idimensions[i] == 1) {\n\t\t\tnewnd -= 1;\n\t\t}\n\t\telse {\n\t\t\tdimensions[j] = self->dimensions[i];\n\t\t\tstrides[j++] = self->strides[i];\n\t\t}\n\t}\n\t\n\tret = PyArray_New(self->ob_type, newnd, dimensions, \n\t\t\t self->descr->type_num, strides,\n\t\t\t self->data, self->itemsize, self->flags,\n\t\t\t self);\n\tself->flags &= ~OWN_DATA;\n\tself->base = (PyObject *)self;\n\tPy_INCREF(self);\n\treturn (PyObject *)ret;\n}\n\n\nstatic PyObject *\nPyArray_Mean(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL;\n\tPyObject *new, *ret;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\n\tobj1 = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,\n\t\t\t\t\t rtype);\n\tobj2 = PyFloat_FromDouble((double) PyArray_DIM(new,axis));\n Py_DECREF(new);\n\tif (obj1 == NULL || obj2 == NULL) {\n\t\tPy_XDECREF(obj1);\n\t\tPy_XDECREF(obj2);\n\t\treturn NULL;\n\t}\n\n\tret = PyNumber_Divide(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_Std(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL, *new=NULL;\n\tPyObject *ret=NULL, *newshape=NULL;\n\tint i, n;\n\tintp val;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\t\n\t/* Compute and reshape mean */\n\tobj1 = PyArray_EnsureArray(PyArray_Mean((PyAO *)new, axis, rtype));\n\tif (obj1 == NULL) {Py_DECREF(new); return NULL;} \n\tn = PyArray_NDIM(new);\n\tnewshape = PyTuple_New(n);\n\tif (newshape == NULL) {Py_DECREF(obj1); Py_DECREF(new); return NULL;}\n\tfor (i=0; ind != 1) {\n Py_DECREF(cond);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Condition must be 1-d array.\");\n return NULL;\n }\n\n res = PyArray_Nonzero(cond);\n Py_DECREF(cond);\n\tret = PyArray_Take(self, res, axis);\n\tPy_DECREF(res);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_Nonzero(PyArrayObject *self)\n{\n int n=self->nd, j;\n\tintp count=0, i, size;\n\tPyArrayIterObject *it=NULL;\n\tPyObject *ret=NULL, *item;\n\tintp *dptr[MAX_DIMS];\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (it==NULL) return NULL;\n\n\tsize = it->size;\n\tfor (i=0; idescr->nonzero(it->dataptr, self)) count++;\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\n\tPyArray_ITER_RESET(it);\n\tif (n==1) {\n\t\tret = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, \n\t\t\t\t NULL, NULL, 0, 0, self);\n\t\tif (ret == NULL) goto fail;\n\t\tdptr[0] = (intp *)PyArray_DATA(ret);\n\t\t\n\t\tfor (i=0; idescr->nonzero(it->dataptr, self)) \n\t\t\t\t*(dptr[0])++ = i;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t}\n\telse {\n\t\tret = PyTuple_New(n);\n\t\tfor (j=0; job_type, 1, &count, \n\t\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0,\n\t\t\t\t\t self);\n\t\t\tPyTuple_SET_ITEM(ret, j, item);\n\t\t\tif (item == NULL) goto fail;\n\t\t\tdptr[j] = (intp *)PyArray_DATA(item);\n\t\t}\n\t\t\n\t\t/* reset contiguous so that coordinates gets updated */\n\t\tit->contiguous = 0;\n\t\tfor (i=0; idescr->nonzero(it->dataptr, self)) \n\t\t\t\tfor (j=0; jcoordinates[j];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\n\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ret);\n\tPy_XDECREF(it);\n\treturn NULL;\n \n}\n\nstatic PyObject *\nPyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max)\n{\n\tPyObject *selector=NULL, *newtup=NULL, *ret=NULL;\n\tPyObject *res1=NULL, *res2=NULL, *res3=NULL;\n\tPyObject *two;\n\n\ttwo = PyInt_FromLong((long)2);\n\tres1 = PyArray_GenericBinaryFunction(self, max, n_ops.greater);\n\tres2 = PyArray_GenericBinaryFunction(self, min, n_ops.less);\n\tif ((res1 == NULL) || (res2 == NULL)) goto fail;\n\tres3 = PyNumber_Multiply(two, res1);\n\tPy_DECREF(two);\n\tPy_DECREF(res1);\n\tif (res3 == NULL) return NULL;\n\n\tselector = PyArray_EnsureArray(PyNumber_Add(res2, res3));\n\tPy_DECREF(res2);\n\tPy_DECREF(res3);\n\tif (selector == NULL) return NULL;\n\n\tnewtup = Py_BuildValue(\"(OOO)\", (PyObject *)self, min, max);\n\tif (newtup == NULL) goto fail;\n\tret = PyArray_Choose((PyAO *)selector, newtup);\n\tPy_DECREF(selector);\n\tPy_DECREF(newtup);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(res1);\n\tPy_XDECREF(res2);\n\tPy_XDECREF(two);\n\tPy_XDECREF(selector);\n\treturn NULL;\n}\n\nstatic PyObject *\nPyArray_Conjugate(PyArrayObject *self)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyObject *new;\n\t\tintp size, i;\n\t\t/* Make a copy */\n\t\tnew = PyArray_Copy(self);\n\t\tif (new==NULL) return NULL;\n\t\tsize = PyArray_SIZE(new);\n\t\tif (self->descr->type_num == PyArray_CFLOAT) {\n\t\t\tcfloat *dptr = (cfloat *) PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CDOUBLE) {\n\t\t\tcdouble *dptr = (cdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CLONGDOUBLE) {\n\t\t\tclongdouble *dptr = (clongdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\t\t\t\n\t\t}\t\t\n\t\treturn new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *) self;\n\t}\n}\n\nstatic PyObject *\nPyArray_Trace(PyArrayObject *self, int offset, int axis1, int axis2, \nint rtype)\n{\n\tPyObject *diag=NULL, *ret=NULL;\n\n\tdiag = PyArray_Diagonal(self, offset, axis1, axis2);\n\tif (diag == NULL) return NULL;\n\tret = PyArray_GenericReduceFunction((PyAO *)diag, n_ops.add, -1, rtype);\n\tPy_DECREF(diag);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)\n{\n\tint n = self->nd;\n\tPyObject *new;\n\tPyObject *newaxes;\n\tint i, pos;\t\n\n\tif (n < 2) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"array.ndim must be >= 2\");\n\t\treturn NULL;\n\t}\n\tif (axis1 < 0) axis1 += n;\n\tif (axis2 < 0) axis2 += n;\n\tif ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||\t\\\n\t (axis2 < 0) || (axis2 >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \"axis1(=%d) and axis2(=%d) \"\\\n\t\t\t \"must be different and within range (nd=%d)\",\n\t\t\t axis1, axis2, n);\n\t\treturn NULL;\n\t}\n \n\tnewaxes = PyTuple_New(n);\n\tif (newaxes==NULL) return NULL;\n\t/* insert at the end */\n\tPyTuple_SET_ITEM(newaxes, n-2, PyInt_FromLong((long)axis1));\n\tPyTuple_SET_ITEM(newaxes, n-1, PyInt_FromLong((long)axis2));\n\tpos = 0;\n\tfor (i=0; idimensions[0];\n\t\tn2 = self->dimensions[1];\n\t\tstep = n2+1;\n\t\tif (offset < 0) {\n\t\t\tstart = -n2 * offset;\n\t\t\tstop = MIN(n2, n1+offset)*(n2+1) - n2*offset;\n\t\t}\n\t\telse {\n\t\t\tstart = offset;\n\t\t\tstop = MIN(n1, n2-offset)*(n2+1) + offset;\n\t\t}\n\t\t\n\t\t/* count = ceil((stop-start)/step) */\n\t\tcount = ((stop-start) / step) + (((stop-start) % step) != 0);\n\t\t\t\n\t\tindices = PyArray_New(&PyArray_Type, 1, &count, \n\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0, NULL);\n\t\tif (indices == NULL) {\n\t\t\tPy_DECREF(self); return NULL;\n\t\t}\n\t\tdptr = (intp *)PyArray_DATA(indices);\n\t\tfor (n1=start; n1descr->type_num,\n\t\t\t\t\t self->itemsize, 0};\n\t\t\n\t\tmydiagonal = PyList_New(0);\n\t\tif (mydiagonal == NULL) {Py_DECREF(self); return NULL;}\n\t\tn1 = self->dimensions[0];\n\t\tfor (i=0; i 3)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"Only Carrays of 1-3 dimensions available.\");\n\t\treturn -1;\n\t}\n\tif ((ap = (PyArrayObject*)PyArray_FromAny(*op, &typecode, nd, nd,\n\t\t\t\t\t\t CARRAY_FLAGS)) == NULL)\n\t\treturn -1;\n\tswitch(nd) {\n\tcase 1:\n\t\t*((char **)ptr) = ap->data;\n\t\tbreak;\n\tcase 2:\n\t\tn = ap->dimensions[0];\n\t\tptr2 = (char **)malloc(n * sizeof(char *));\n\t\tif (!ptr2) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0];\n\t\t}\n\t\t*((char ***)ptr) = ptr2;\n\t\tbreak;\t\t\n\tcase 3:\n\t\tn = ap->dimensions[0];\n\t\tm = ap->dimensions[1];\n\t\tptr3 = (char ***)malloc(n*(m+1) * sizeof(char *));\n\t\tif (!ptr3) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0] + \\\n\t\t\t\t\tj*ap->strides[1];\n\t\t\t}\n\t\t}\n\t\t*((char ****)ptr) = ptr3;\n\t}\n\tmemcpy(dims, ap->dimensions, nd*sizeof(intp));\n\t*op = (PyObject *)ap;\n\treturn 0;\n\n fail:\n\tPyErr_SetString(PyExc_MemoryError, \"No memory.\");\n\treturn -1;\n}\n\n/* Deprecated --- Use PyArray_AsCArray instead */\n\nstatic int \nPyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode) \n{\n\tintp newd1;\n\t\n\tif (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, typecode) == -1)\n\t\treturn -1;\t\n\t*d1 = (int) newd1;\n\treturn 0;\n}\n\n\nstatic int \nPyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode) \n{\n\tintp newdims[2];\n\n\tif (PyArray_AsCArray(op, (void *)ptr, newdims, 2, typecode) == -1)\n\t\treturn -1;\n\n\t*d1 = (int ) newdims[0];\n\t*d2 = (int ) newdims[1];\n return 0;\n}\n\n/* End Deprecated */\n\nstatic int \nPyArray_Free(PyObject *op, void *ptr) \n{\n PyArrayObject *ap = (PyArrayObject *)op;\n\t\n if ((ap->nd < 1) || (ap->nd > 3)) \n\t\treturn -1;\n if (ap->nd >= 2) {\n\t\tfree(ptr);\n }\n Py_DECREF(ap);\n return 0;\n}\n\n\nstatic PyObject *\n_swap_and_concat(PyObject *op, int axis, int n)\n{\n\tPyObject *newtup=NULL;\n\tPyObject *otmp, *arr;\n\tint i;\n\n\tnewtup = PyTuple_New(n);\n\tif (newtup==NULL) return NULL;\n\tfor (i=0; i= MAX_DIMS) {\n\t\t\totmp = PyArray_Ravel(mps[i],0);\n\t\t\tPy_DECREF(mps[i]);\n\t\t\tmps[i] = (PyArrayObject *)otmp;\n\t\t}\n\t\tprior2 = PyArray_GetPriority((PyObject *)(mps[i]), 0.0);\n\t\tif (prior2 > prior1) {\n\t\t\tprior1 = prior2;\n\t\t\tsubtype = mps[i]->ob_type;\n\t\t\tret = mps[i];\n\t\t}\n\t}\n\t\n\tnew_dim = 0;\n\tfor(i=0; ind;\n\t\telse {\n\t\t\tif (nd != mps[i]->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"arrays must have same \"\\\n\t\t\t\t\t\t\"number of dimensions\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CompareLists(mps[0]->dimensions+1, \n\t\t\t\t\t\t mps[i]->dimensions+1, \n\t\t\t\t\t\t nd-1)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"array dimensions must \"\\\n\t\t\t\t\t\t\"agree except for d_0\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (nd == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"0d arrays can't be concatenated\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnew_dim += mps[i]->dimensions[0];\n\t}\n\t\n\ttmp = mps[0]->dimensions[0];\n\tmps[0]->dimensions[0] = new_dim;\n\tret = (PyArrayObject *)PyArray_New(subtype, nd,\n\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t type_num, NULL, NULL, 0, 0, ret);\n\tmps[0]->dimensions[0] = tmp;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tdata = ret->data;\n\tfor(i=0; idata, numbytes);\n\t\tdata += numbytes;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; ind;\n\tif (n <= 1) {\n\t\tPy_INCREF(ap);\n\t\treturn (PyObject *)ap;\n\t}\n\n\tif (a1 < 0) a1 += n;\n\tif (a2 < 0) a2 += n;\n\tif ((a1 < 0) || (a1 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Bad axis1 argument to swapaxes.\");\n\t\treturn NULL;\n\t}\n\tif ((a2 < 0) || (a2 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Bad axis2 argument to swapaxes.\");\n\t\treturn NULL;\n\t}\n\tnew_axes = PyTuple_New(n);\n\tfor (i=0; ind;\n\t\tpermutation = (intp *)malloc(n*sizeof(int));\n\t\tfor(i=0; ind+axis;\n\t\t\tif (axis < 0 || axis >= ap->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"invalid axis for this array\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tpermutation[i] = axis;\n\t\t}\n\t}\n\t\n\t/* this allocates memory for dimensions and strides (but fills them\n\t incorrectly), sets up descr, and points data at ap->data. */\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, n, permutation, \n\t\t\t\t\t ap->descr->type_num, NULL,\n\t\t\t\t\t ap->data, ap->itemsize, ap->flags,\n\t\t\t\t\t ap);\n\tif (ret == NULL) goto fail;\n\t\n\t/* point at true owner of memory: */\n\tret->base = (PyObject *)ap;\n\tPy_INCREF(ap);\n\t\n\tfor(i=0; idimensions[i] = ap->dimensions[permutation[i]];\n\t\tret->strides[i] = ap->strides[permutation[i]];\n\t}\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n\tif (op && (op != Py_None))\n\t\tPyArray_Free(op, (char *)axes);\n\tfree(permutation);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ret);\n\tif (permutation != NULL) free(permutation);\n\tif (op != Py_None)\n\t\tPyArray_Free(op, (char *)axes);\n\treturn NULL;\n}\n\nstatic PyObject *\nPyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis) {\n\tintp *counts;\n\tintp n, n_outer, i, j, k, chunk, total;\n\tintp tmp;\n\tint nd;\n\tPyArrayObject *repeats=NULL;\n\tPyObject *ap=NULL;\n\tPyArrayObject *ret=NULL;\n\tchar *new_data, *old_data;\n\n\trepeats = (PyAO *)PyArray_ContiguousFromObject(op, PyArray_INTP, 0, 1);\n\tif (repeats == NULL) return NULL;\n\tnd = repeats->nd;\n\tcounts = (intp *)repeats->data;\n\n\tif ((ap=_check_axis(aop, &axis, CARRAY_FLAGS))==NULL) {\n\t\tPy_DECREF(repeats);\n\t\treturn NULL;\n\t}\n\n\taop = (PyAO *)ap;\n\n\tif (nd == 1)\n\t\tn = repeats->dimensions[0];\n\telse /* nd == 0 */\n\t\tn = aop->dimensions[axis];\n\n\tif (aop->dimensions[axis] != n) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"a.shape[axis] != len(repeats)\");\n\t\tgoto fail;\n\t}\n\n\t\n\tif (nd == 0) \n\t\ttotal = counts[0]*n;\n\telse {\n\t\t\n\t\ttotal = 0;\n\t\tfor(j=0; jdimensions[axis] = total;\n\tret = (PyArrayObject *)PyArray_New(aop->ob_type, aop->nd,\n\t\t\t\t\t aop->dimensions, \n\t\t\t\t\t aop->descr->type_num,\n\t\t\t\t\t NULL, NULL, aop->itemsize, 0,\n\t\t\t\t\t aop);\n\taop->dimensions[axis] = n;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tnew_data = ret->data;\n\told_data = aop->data;\n\t\n\tchunk = aop->itemsize;\n\tfor(i=axis+1; ind; i++) {\n\t\tchunk *= aop->dimensions[i];\n\t}\n\t\n\tn_outer = 1;\n\tfor(i=0; idimensions[i];\n\n\tfor(i=0; ind < mps[i]->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many dimensions\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (!PyArray_CompareLists(ap->dimensions+(ap->nd-mps[i]->nd),\n\t\t\t\t mps[i]->dimensions, mps[i]->nd)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"array dimensions must agree\");\n\t\t\tgoto fail;\n\t\t}\n\t\tsizes[i] = PyArray_NBYTES(mps[i]);\n\t}\n\t\n\t/* why not ??? \n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tPyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Not implemented for flexible sizes\");\n\t\treturn NULL;\n\t}\n\t*/\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd,\n\t\t\t\t\t ap->dimensions, type_num,\n\t\t\t\t\t NULL, NULL, 0, 0, ap);\n\tif (ret == NULL) goto fail;\n\t\n\telsize = ret->itemsize;\n\tm = PyArray_SIZE(ret);\n\tself_data = (intp *)ap->data;\n\tret_data = ret->data;\n\t\n\tfor (i=0; i= n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid entry in choice array\");\n\t\t\tgoto fail;\n\t\t}\n\t\toffset = i*elsize;\n\t\tif (offset >= sizes[mi]) {offset = offset % sizes[mi]; }\n\t\tmemmove(ret_data, mps[mi]->data+offset, elsize);\n\t\tret_data += elsize; self_data++;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; idescr->compare(a,b,global_obj);\n}\n\n#define SWAPAXES(op, ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n#define SWAPBACK(op, ap) { \\\n\t\tif (axis != orign) { \\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\nstatic PyObject *\nPyArray_Sort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *store_arr=NULL;\n\tchar *ip;\n\tint i, n, m, elsize, orign;\n\n\tif ((ap = (PyAO*) _check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_CopyFromObject((PyObject *)op, \n\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\n\tif (ap->descr->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tPy_DECREF(ap);\n\t\treturn NULL;\n\t}\n\t\n\telsize = ap->itemsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\n\t/* Store global -- allows re-entry -- restore before leaving*/\n\tstore_arr = global_obj; \n\tglobal_obj = ap;\n\t\n\tfor (ip=ap->data, i=0; iitemsize;\n\tconst intp *ipa = ip1;\n\tconst intp *ipb = ip2;\t\n\treturn global_obj->descr->compare(global_data + (isize * *ipa),\n global_data + (isize * *ipb), \n\t\t\t\t\t global_obj);\n}\n\nstatic PyObject *\nPyArray_ArgSort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap, *ret, *store;\n\tintp *ip;\n\tintp i, j, n, m, orign;\n\tint argsort_elsize;\n\tchar *store_ptr;\n\n\tif ((ap = (PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_ContiguousFromObject((PyObject *)op, \n\t\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, ap);\n\tif (ret == NULL) goto fail;\n\t\n\tif (ap->descr->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tip = (intp *)ret->data;\n\targsort_elsize = ap->itemsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\tstore_ptr = global_data;\n\tglobal_data = ap->data;\n\tstore = global_obj;\n\tglobal_obj = ap;\n\tfor (i=0; idescr->compare;\n\tintp min_i, max_i, i, j;\n\tint location, elsize = ap1->itemsize;\n\tintp elements = ap1->dimensions[ap1->nd-1];\n\tintp n = PyArray_Size((PyObject *)ap2);\n\tintp *rp = (intp *)ret->data;\n\tchar *ip = ap2->data;\n\tchar *vp = ap1->data;\n\n\tfor (j=0; j 0) {\n\t\t\t\t\tif (compare(ip, vp+elsize*(--i), ap2) \\\n\t\t\t\t\t != 0) {\n\t\t\t\t\t\ti = i+1; break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmin_i = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (location < 0) {\n\t\t\t\tmax_i = i;\n\t\t\t} else {\n\t\t\t\tmin_i = i+1;\n\t\t\t}\n\t\t}\n\t\t*rp = min_i;\n\t}\n}\n\nstatic PyObject *\nPyArray_SearchSorted(PyArrayObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret;\n\tint typenum = 0;\n\n\t/* \n PyObject *args;\n args = Py_BuildValue(\"O\",op2);\n\tPy_DELEGATE_ARGS(((PyObject *)op1), searchsorted, args);\n Py_XDECREF(args);\n\t*/\n\n\ttypenum = PyArray_ObjectType((PyObject *)op1, 0);\n\ttypenum = PyArray_ObjectType(op2, typenum);\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromObject((PyObject *)op1, \n\t\t\t\t\t\t\t typenum, \n\t\t\t\t\t\t\t 1, 1);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromObject(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd, \n\t\t\t\t\t ap2->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, ap2);\n\tif (ret == NULL) goto fail;\n\n\tif (ap2->descr->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tlocal_where(ap1, ap2, ret); \n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n\n\n/* Could perhaps be redone to not make contiguous arrays \n */\n\nstatic PyObject *\nPyArray_InnerProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret;\n\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS], nd;\n\tPyArray_DotFunc *dot;\n\tPyTypeObject *subtype;\n double prior1, prior2;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromObject(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromObject(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = (ret->descr->dotfunc);\n\t\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\n\t\n\tis1 = ap1->strides[ap1->nd-1]; \n\tis2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->itemsize;\n\t\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\tif (ap2->nd > 1) {\n\t\tmatchDim = ap2->nd - 2;\n\t\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 0;\n\t}\n\n\tif (ap2->dimensions[matchDim] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"objects are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-2; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\tif(ap2->nd > 1) {\n\t\tdimensions[j++] = ap2->dimensions[ap2->nd-1];\n\t}\n\t/*\n\tfprintf(stderr, \"nd=%d dimensions=\", nd);\n\t for(i=0; i prior1 ? ap2->ob_type : ap1->ob_type);\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = ret->descr->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\t\n\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->itemsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_type, 2, dims, PyArray_TYPE(arr),\n\t\t\t NULL, NULL, elsize, 0, (PyArrayObject *)arr);\n\n\tif (ret == NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn NULL;\n\t}\n\t/* do 2-d loop */\n\toptr = PyArray_DATA(ret);\n\tstr2 = elsize*dims[0];\n\tfor (i=0; idimensions[ap1->nd-1];\n\tn2 = ap2->dimensions[ap2->nd-1];\n\n\tif (n1 < n2) { \n\t\tret = ap1; ap1 = ap2; ap2 = ret; \n\t\tret = NULL; i = n1;n1=n2;n2=i;\n\t}\n\tlength = n1;\n\tn = n2;\n\tswitch(mode) {\n\tcase 0:\t\n\t\tlength = length-n+1;\n\t\tn_left = n_right = 0;\n\t\tbreak;\n\tcase 1:\n\t\tn_left = (int)(n/2);\n\t\tn_right = n-n_left-1;\n\t\tbreak;\n\tcase 2:\n\t\tn_right = n-1;\n\t\tn_left = n-1;\n\t\tlength = length+n-1;\n\t\tbreak;\n\tdefault:\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mode must be 0,1, or 2\");\n\t\tgoto fail;\n\t}\n\t\n\tret = (PyArrayObject *)PyArray_New(ap1->ob_type, 1,\n\t\t\t\t\t &length, typenum, \n\t\t\t\t\t NULL, NULL, 0, 0, ap1);\n\tif (ret == NULL) goto fail;\n\n\t\n\tdot = ret->descr->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"function not available for this type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->itemsize;\n\t\n\tip1 = ap1->data; ip2 = ap2->data+n_left*is2;\n\tn = n-n_left;\n\tfor(i=0; idescr->argmax;\n\tif (arg_func == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"data type not ordered\");\n\t\tgoto fail;\n\t}\n\n\trp = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd-1,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, ap);\n\tif (rp == NULL) goto fail;\n\n\n\telsize = ap->itemsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) {\n\t\tPyErr_SetString(MultiArrayError, \n\t\t\t\t\"Attempt to get argmax/argmin \"\\\n\t\t\t\t\"of an empty sequence??\");\n\t\tgoto fail;\n\t}\n\tn = PyArray_SIZE(ap)/m;\n\trptr = (intp *)rp->data;\n\tfor (ip = ap->data, i=0; ind + indices->nd - 1;\n for (i=0; i< nd; i++) {\n if (i < axis) {\n shape[i] = self->dimensions[i];\n n *= shape[i];\n } else {\n if (i < axis+indices->nd) {\n shape[i] = indices->dimensions[i-axis];\n m *= shape[i];\n } else {\n shape[i] = self->dimensions[i-indices->nd+1];\n chunk *= shape[i];\n }\n }\n }\n ret = (PyArrayObject *)PyArray_New(self->ob_type, nd, shape, \n\t\t\t\t\t self->descr->type_num,\n\t\t\t\t\t NULL, NULL, 0, 0, self);\n\t\n if (ret == NULL) goto fail;\n\t\n max_item = self->dimensions[axis];\n chunk = chunk * ret->itemsize;\n src = self->data;\n dest = ret->data;\n\t\n for(i=0; idata))[j];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"Index out of range for \"\\\n\t\t\t\t\t\t\"array\");\n goto fail;\n }\n memmove(dest, src+tmp*chunk, chunk);\n dest += chunk;\n }\n src += chunk*max_item;\n }\n\t\n PyArray_INCREF(ret);\n\n Py_XDECREF(indices);\n Py_XDECREF(self);\n\n return (PyObject *)ret;\n\t\n\t\n fail:\n Py_XDECREF(ret);\n Py_XDECREF(indices);\n Py_XDECREF(self);\n return NULL;\n}\n\nstatic PyObject *\nPyArray_Put(PyArrayObject *self, PyObject *indices0, PyObject* values0) \n{\n PyArrayObject *indices, *values;\n int i, chunk, ni, max_item, nv, tmp; \n char *src, *dest;\n\n indices = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be contiguous\");\n return NULL;\n }\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->itemsize;\n\n indices = (PyArrayObject *)PyArray_ContiguousFromObject(indices0, PyArray_INTP, 0, 0);\n if (indices == NULL) goto fail;\n ni = PyArray_SIZE(indices);\n\n values = (PyArrayObject *)PyArray_ContiguousFromObject(values0, \n self->descr->type, 0, 0);\n if (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\n if (nv > 0) { /* nv == 0 for a null array */\n for(i=0; idata + chunk * (i % nv);\n tmp = ((long *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"Index out of range for array\");\n goto fail;\n }\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n\n Py_XDECREF(values);\n Py_XDECREF(indices);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(indices);\n Py_XDECREF(values);\n return NULL;\n}\n\nstatic PyObject *\nPyArray_PutMask(PyArrayObject *self, PyObject *mask0, PyObject* values0) \n{\n PyArrayObject *mask, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype;\n char *src, *dest;\n\n mask = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must \"\\\n\t\t\t\t\"be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must be contiguous\");\n return NULL;\n }\n\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->itemsize;\n\n mask = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromObject(mask0, PyArray_BOOL, 0, 0);\n if (mask == NULL) goto fail;\n ni = PyArray_SIZE(mask);\n if (ni != max_item) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: mask and data must be \"\\\n\t\t\t\t\"the same size.\");\n goto fail;\n }\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromObject(values0, thistype, 0, 0);\n\tif (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\t /* zero if null array */\n if (nv > 0) {\n\t\tfor(i=0; idata + chunk * (i % nv);\n\t\t\ttmp = ((Bool *)(mask->data))[i];\n\t\t\tif (tmp) {\n\t\t\t\tmemmove(dest + i * chunk, src, chunk);\n\t\t\t\tif (thistype == PyArray_OBJECT)\n\t\t\t\t\tPy_INCREF(*((PyObject **)src));\n\t\t\t}\n\t\t}\n }\n\n Py_XDECREF(values);\n Py_XDECREF(mask);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(mask);\n Py_XDECREF(values);\n return NULL;\n}\n\n\n/* This conversion function can be used with the \"O&\" argument for\n PyArg_ParseTuple. It will immediately return an object of array type\n or will convert to a CARRAY any other object. \n\n If you use PyArray_Converter, you must DECREF the array when finished\n as you get a new reference to it.\n*/\n \nstatic int \nPyArray_Converter(PyObject *object, PyObject **address) \n{\n if (PyArray_Check(object)) {\n *address = object;\n\t\tPy_INCREF(object);\n return PY_SUCCEED;\n }\n else {\n\t\t*address = PyArray_FromAny(object, NULL, 0, 0, CARRAY_FLAGS);\n\t\tif (*address == NULL) return PY_FAIL;\n\t\treturn PY_SUCCEED;\n }\n}\n\nstatic int\nPyArray_BoolConverter(PyObject *object, Bool *val)\n{\n\tif (PyObject_IsTrue(object)) *val=TRUE;\n\telse *val=FALSE;\n\tif (PyErr_Occurred()) return PY_FAIL;\n\treturn PY_SUCCEED;\n}\n\n\nstatic int\nPyArray_TypestrConvert(int itemsize, int gentype)\n{\n\tregister int newtype = gentype;\n\t\n\tif (gentype == PyArray_SIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_INT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_INT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_INT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_INT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_INT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\n\t}\n\n\telse if (gentype == PyArray_UNSIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_UINT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_UINT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_UINT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_UINT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_UINT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if (gentype == PyArray_FLOATINGLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 4:\n\t\t\tnewtype = PyArray_FLOAT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_FLOAT64;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 10:\n\t\t\tnewtype = PyArray_FLOAT80;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 12:\n\t\t\tnewtype = PyArray_FLOAT96;\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_FLOAT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\t\n\telse if (gentype == PyArray_COMPLEXLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 8:\n\t\t\tnewtype = PyArray_COMPLEX64;\n\t\t\tbreak;\n\t\tcase 16:\n\t\t\tnewtype = PyArray_COMPLEX128;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 20:\n\t\t\tnewtype = PyArray_COMPLEX160;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 24:\n\t\t\tnewtype = PyArray_COMPLEX192;\t\t\t\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 32:\n\t\t\tnewtype = PyArray_COMPLEX256;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\n\treturn newtype;\n}\n\n\n/* this function takes a Python object which exposes the (single-segment)\n buffer interface and returns a pointer to the data segment\n \n You should increment the reference count by one of buf->base\n if you will hang on to a reference\n\n You only get a borrowed reference to the object. Do not free the\n memory...\n*/\n\n\nstatic int\nPyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)\n{\n int buflen;\n\n buf->ptr = NULL;\n buf->flags = WRITEABLE;\n buf->base = NULL;\n\n\tif (obj == Py_None)\n\t\treturn PY_SUCCEED;\n\n if (PyObject_AsWriteBuffer(obj, &(buf->ptr), &buflen) < 0) {\n PyErr_Clear();\n buf->flags &= ~WRITEABLE;\n if (PyObject_AsReadBuffer(obj, (const void **)&(buf->ptr), \n &buflen) < 0)\n return PY_FAIL;\n }\n buf->len = (intp) buflen;\n \n /* Point to the base of the buffer object if present */\n if (PyBuffer_Check(obj)) buf->base = ((PyArray_Chunk *)obj)->base;\n if (buf->base == NULL) buf->base = obj;\n \n return PY_SUCCEED; \n}\n\n\n\n/* This function takes a Python sequence object and allocates and\n fills in an intp array with the converted values.\n\n **Remember to free the pointer seq.ptr when done using\n PyDimMem_FREE(seq.ptr)**\n*/\n\nstatic int\nPyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)\n{\n int len;\n int nd;\n\n seq->ptr = NULL;\n if (obj == Py_None) return PY_SUCCEED;\n len = PySequence_Size(obj);\n if (len == -1) { /* Check to see if it is a number */\n if (PyNumber_Check(obj)) len = 1;\n }\n if (len < 0) {\n PyErr_SetString(PyExc_TypeError, \n \"Expected sequence object with len >= 0\");\n return PY_FAIL;\n }\n if (len > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError, \"Sequence too large, \" \\\n \"must be smaller than %d\", MAX_DIMS);\n return PY_FAIL;\n }\n\tif (len > 0) {\n\t\tseq->ptr = PyDimMem_NEW(len);\n\t\tif (seq->ptr == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n seq->len = len;\n nd = PyArray_IntpFromSequence(obj, (intp *)seq->ptr, len);\n if (nd == -1 || nd != len) goto fail;\n return PY_SUCCEED;\n\n fail:\n\tPyDimMem_FREE(seq->ptr);\n\treturn PY_FAIL;\n}\n\n/* This function takes a Python object representing a type and converts it \n to a C type_num and an itemsize (elements of PyArray_Typecode structure)\n \n Many objects can be used to represent a type.\n */\n\nstatic int\nPyArray_TypecodeConverter(PyObject *obj, PyArray_Typecode *at)\n{\n char *type;\n PyArray_Descr *descr;\n int check_num=PyArray_NOTYPE+10;\n\tint len;\n\tPyObject *item, *attr=NULL;\n\n\tat->itemsize = 0;\n if (obj == Py_None) {\n at->type_num = PyArray_NOTYPE;\n return PY_SUCCEED;\n }\n\n if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, \n &PyGenericArrType_Type)) {\n PyArray_TypecodeFromTypeObject(obj, at);\n return PY_SUCCEED;\n }\n\n\n\t/* type object could be an array */\n\tif (PyArray_Check(obj)) {\n\t\tat->type_num = PyArray_TYPE(obj);\n\t\tat->itemsize = PyArray_ITEMSIZE(obj);\n\t\treturn PY_SUCCEED;\n\t}\n\n\t/* or an array scalar */\n if (PyArray_IsScalar(obj, Generic)) {\n PyArray_TypecodeFromScalar(obj, at);\n return PY_SUCCEED;\n }\n\n\t/* or a typecode string */\n\n\tif (PyString_Check(obj)) {\n\t\t/* Check for a string typecode. */\n\t\ttype = PyString_AS_STRING(obj);\n\t\tlen = PyString_GET_SIZE(obj);\t\t\n\t\tif (len > 0) {\n\t\t\tcheck_num = (int) type[0];\n\t\t}\n\t\tif (len > 1) {\n\t\t\tat->itemsize = atoi(type+1);\n\t\t\t/* When specifying length of UNICODE\n\t\t\t the number of characters is given to match \n\t\t\t the STRING interface. Each character can be\n\t\t\t more than one byte and itemsize must be\n\t\t\t the number of bytes.\n\t\t\t*/\n\t\t\tif (check_num == PyArray_UNICODELTR ||\t\\\n\t\t\t check_num == PyArray_UNICODE) \n\t\t\t at->itemsize *= sizeof(Py_UNICODE);\n\n\t\t\t/* Support for generic processing */\n\t\t\telse if ((check_num != PyArray_STRINGLTR) &&\n\t\t\t\t (check_num != PyArray_VOIDLTR) &&\n\t\t\t\t (check_num != PyArray_STRING) &&\n\t\t\t\t (check_num != PyArray_VOID)) {\n\t\t\t\tcheck_num = \\\n\t\t\t\t\tPyArray_TypestrConvert(at->itemsize, \n\t\t\t\t\t\t\t check_num);\n\t\t\t at->itemsize = 0;\n\t\t\t\tif (check_num == PyArray_NOTYPE) goto fail;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Arbitray object with dtypenum and itemsize attributes. */\n\telse if (PyObject_HasAttrString(obj, \"dtypenum\") && \n\t PyObject_HasAttrString(obj, \"itemsize\")) {\n\t\tattr = PyObject_GetAttrString(obj, \"dtypenum\");\n\t\tcheck_num = PyInt_AsLong(attr);\n\t\tif (PyErr_Occurred()) { /* not an integer, try character */\n\t\t\tPyErr_Clear();\n\t\t\ttype = PyString_AsString(attr);\n\t\t\tcheck_num = (int) type[0];\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tif (!PyErr_Occurred()) {\n\t\t\tattr = PyObject_GetAttrString(obj, \"itemsize\");\n\t\t\tat->itemsize = PyInt_AsLong(attr);\n\t\t\tPy_XDECREF(attr);\n\t\t}\t\t\t\n\t}\t\t\n\telse if (PyType_Check(obj)) {\n\t\tcheck_num = PyArray_OBJECT;\n\t\tif (obj == (PyObject *)(&PyInt_Type)) \n\t\t\tcheck_num = PyArray_LONG;\n\t\telse if (obj == (PyObject *)(&PyBool_Type))\n\t\t\tcheck_num = PyArray_BOOL;\n\t\telse if (obj == (PyObject *)(&PyFloat_Type)) \n\t\t\tcheck_num = PyArray_DOUBLE;\n\t\telse if (obj == (PyObject *)(&PyComplex_Type)) \n\t\t\tcheck_num = PyArray_CDOUBLE;\n else if (obj == (PyObject *)(&PyString_Type))\n check_num = PyArray_STRING;\n else if (obj == (PyObject *)(&PyUnicode_Type))\n check_num = PyArray_UNICODE;\n\t}\t\n else { /* Default -- try integer conversion */\n check_num = PyInt_AsLong(obj);\n\t}\n\n\tif (PyErr_Occurred()) goto fail;\n\n\t/*\n\tif (check_num == PyArray_NOTYPE) return PY_FAIL;\n\t*/\n\tif (check_num == PyArray_NOTYPE) {\n\t\tat->type_num = PyArray_NOTYPE;\n\t\tat->itemsize = 0;\n\t\treturn PY_SUCCEED;\n\t}\n\n if ((descr = PyArray_DescrFromType(check_num))==NULL) {\n\t\t/* Now check to see if the object is registered\n\t\t in typeDict */\n\t\tif (typeDict != NULL) {\n\t\t\titem = PyDict_GetItem(typeDict, obj);\n\t\t\tif (item) {\n\t\t\t\tPyArray_TypecodeFromTypeObject(obj, at);\n\t\t\t\tPyErr_Clear();\n\t\t\t\treturn PY_SUCCEED;\n\t\t\t}\n\t\t}\n return PY_FAIL;\n\t}\n\t\n at->type_num = descr->type_num;\n\tif (at->itemsize == 0) at->itemsize = descr->elsize;\n\t\n return PY_SUCCEED;\n fail:\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"data type not understood\");\n\treturn PY_FAIL;\n}\t\n\n\n/* This function returns true if the two typecodes are \n equivalent (same basic kind and same itemsize).\n*/\n\nstatic Bool\nPyArray_EquivalentTypes(PyArray_Typecode *typ1, PyArray_Typecode *typ2)\n{\n\tregister int typenum1=typ1->type_num;\n\tregister int typenum2=typ2->type_num;\n\tregister int size1=typ1->itemsize;\n\tregister int size2=typ2->itemsize;\n\n\tif (size1 != size2) return FALSE;\n\tif (typenum1==typenum2) return TRUE;\n\n\t/* If we are here then size1 == size2 */\n\tif (typenum1 < PyArray_FLOAT) {\n\t\tif (PyTypeNum_ISBOOL(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISBOOL(typenum2));\n\t\telse if (PyTypeNum_ISUNSIGNED(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISUNSIGNED(typenum2));\n\t\telse \n\t\t\treturn (Bool)(PyTypeNum_ISSIGNED(typenum2));\n\t}\n\telse {\n\t\tif (PyTypeNum_ISFLOAT(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISFLOAT(typenum2));\n\t\telse if (PyTypeNum_ISCOMPLEX(typenum1))\n\t\t\treturn (Bool)(PyTypeNum_ISCOMPLEX(typenum2));\n\t}\n\t/* Default size1 != size2 and typenum1 != typenum2 */\n\treturn FALSE;\t\n}\n\nstatic Bool \nPyArray_EquivArrTypes(PyArrayObject *a1, PyArrayObject *a2)\n{\n PyArray_Typecode type1={PyArray_TYPE(a1), PyArray_ITEMSIZE(a1), 0};\n PyArray_Typecode type2={PyArray_TYPE(a2), PyArray_ITEMSIZE(a2), 0};\n \n return PyArray_EquivalentTypes(&type1, &type2);\n}\n\n\n/*** END C-API FUNCTIONS **/\n\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0) will return a new array formed from the given object type given. Object can anything with an __array__ method, or any (nested) sequence. If no type is given, then the type will be determined as the minimum type required to hold the objects in the sequence. If copy is zero and sequence is already an array with the right type, a reference will be returned. If the sequence is an array, type can be used only to upcast the array. For downcasting use .astype(t) method.\";\n\nstatic PyObject *\n_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)\n{\n\tPyObject *op, *ret=NULL;\n\tstatic char *kwd[]= {\"object\", \"dtype\", \"copy\", \"fortran\", NULL};\n\tBool copy=TRUE;\n\tPyArray_Typecode type = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode oldtype = {PyArray_NOTYPE, 0, 0};\n\tint type_num;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_TypecodeConverter,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran)) \n\t\treturn NULL;\n\ttype_num = type.type_num;\n\n\t/* fast exit if simple call */\n\tif (PyArray_Check(op) && (copy==0) &&\t\t\t\\\n\t (fortran == PyArray_CHKFLAGS(op, FORTRAN))) {\n\t\tif (type_num == PyArray_NOTYPE) {\n\t\t\tPy_INCREF(op);\n\t\t\treturn op;\n\t\t}\n\t\t/* One more chance */\n\t\toldtype.type_num = PyArray_TYPE(op);\n\t\toldtype.itemsize = PyArray_ITEMSIZE(op);\n\t\tif (PyArray_EquivalentTypes(&oldtype, &type)) {\n\t\t\tPy_INCREF(op);\n\t\t\treturn op;\n\t\t}\n\t}\n\n\ttype.fortran = fortran; \n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\n\tif ((ret = PyArray_FromAny(op, &type, 0, 0, flags)) == NULL) \n\t\treturn NULL;\n\n\treturn _ARET(ret);\n}\n\nstatic PyObject *\nPyArray_Empty(int nd, intp *dims, PyArray_Typecode *type)\n{\n\tPyArrayObject *ret;\n\tintp n;\n \n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, nd, dims, \n\t\t\t\t\t type->type_num,\n\t\t\t\t\t NULL, NULL, type->itemsize, \n\t\t\t\t\t type->fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tn = PyArray_SIZE(ret);\n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n PyArray_FillObjectArray(ret, Py_None);\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic char doc_empty[] = \"empty((d1,...,dn),dtype=intp,fortran=0) will return a new array\\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.\";\n\nstatic PyObject *\narray_empty(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0, 0};\n PyArray_Dims shape;\n\tBool fortran = FALSE;\t\n PyObject *ret;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_TypecodeConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter, &fortran)) \n\t\treturn NULL;\n\t\n\ttypecode.fortran = fortran;\n if (typecode.type_num ==PyArray_NOTYPE) \n\t\ttypecode.type_num = PyArray_INTP;\n \n\tret = PyArray_Empty(shape.len, shape.ptr, &typecode); \n PyDimMem_FREE(shape.ptr);\n return ret;\n}\n\nstatic char doc_scalar[] = \"scalar(dtypestr,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. typestr must be a valid data typestr (complete with < > or |). If dtypestr is object, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.\";\n\nstatic PyObject *\narray_scalar(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"dtypestr\",\"obj\", NULL};\n\tPyArray_Typecode typecode;\n\tPyObject *obj=NULL;\n\tchar *typestr;\n\tint typestrlen;\n\tint swap, alloc=0;\n\tvoid *dptr;\n\tPyObject *ret;\n\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"z#|O\",\n\t\t\t\t\t kwlist, &typestr, &typestrlen,\n\t\t\t\t\t &obj)) \n\t\treturn NULL;\n\t\n\tif (_array_typecode_fromstr(typestr, &swap, &typecode) < 0) \n\t\treturn NULL;\n\t\n\tif (typecode.itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\t\t\\\n\t\t\t\t\"itemsize cannot be zero\");\n\t\treturn NULL;\n\t}\n\n\tif (typecode.type_num == PyArray_OBJECT) {\n\t\tif (obj == NULL) obj = Py_None;\n\t\tdptr = &obj;\n\t\tswap = 0;\n\t}\n\telse {\n\t\tif (obj == NULL) {\n\t\t\tdptr = malloc(typecode.itemsize);\n\t\t\tif (dptr == NULL) {\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemset(dptr, '\\0', typecode.itemsize);\n\t\t\talloc = 1;\n\t\t}\n\t\telse {\n\t\t\tif (!PyString_Check(obj)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"initializing object must \"\\\n\t\t\t\t\t\t\"be a string.\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (PyString_GET_SIZE(obj) < typecode.itemsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"initialization string is too\"\\\n\t\t\t\t\t\t\" small\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = PyString_AS_STRING(obj);\n\t\t}\n\t}\n\n\tret = PyArray_Scalar(dptr, typecode.type_num,\n\t\t\t typecode.itemsize, swap); \n\n\t/* free dptr which contains zeros */\n\tif (alloc) free(dptr);\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_Zeros(int nd, intp *dims, PyArray_Typecode *type)\n{\n\tPyArrayObject *ret;\n\tintp n;\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, nd, dims, \n\t\t\t\t\t type->type_num,\n\t\t\t\t\t NULL, NULL, type->itemsize, \n\t\t\t\t\t type->fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tn = PyArray_SIZE(ret);\n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n\t\tPyObject *zero = PyInt_FromLong(0);\n PyArray_FillObjectArray(ret, zero);\n Py_DECREF(zero);\n\t}\n\telse {\t\t\n\t\tmemset(ret->data, 0, n*(ret->itemsize));\n\t}\n\treturn (PyObject *)ret;\n\n}\n\nstatic char doc_zeros[] = \"zeros((d1,...,dn),dtype=intp,fortran=0) will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.\";\n\n\nstatic PyObject *\narray_zeros(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0, 0};\n PyArray_Dims shape;\n\tBool fortran = FALSE;\t\n PyObject *ret;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_TypecodeConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\treturn NULL;\n\t\n\ttypecode.fortran = fortran;\n if (typecode.type_num ==PyArray_NOTYPE) \n\t\ttypecode.type_num = PyArray_INTP;\n \n\tret = PyArray_Zeros(shape.len, shape.ptr, &typecode); \n PyDimMem_FREE(shape.ptr);\n return ret;\n}\n\nstatic char doc_set_typeDict[] = \"set_typeDict(dict) set the internal \"\\\n\t\"dictionary that can look up an array type using a registered \"\\\n\t\"code\";\n\nstatic PyObject *\narray_set_typeDict(PyObject *ignored, PyObject *args)\n{\n\tPyObject *dict;\n\tif (!PyArg_ParseTuple(args, \"O\", &dict)) return NULL;\n\tPy_XDECREF(typeDict); /* Decrement old reference (if any)*/\n\ttypeDict = dict;\n\tPy_INCREF(dict); /* Create an internal reference to it */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=intp, count=-1, swap=False) returns a new 1d array initialized from the raw binary data in string. If count is positive, the new array will have count elements, otherwise it's size is determined by the size of string.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyArrayObject *ret; \n\tchar *data;\n\tlonglong nin=-1;\n\tintp s, n;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", \"swap\",NULL};\n\tPyArray_Typecode type = {PyArray_INTP, sizeof(intp), 0};\n\tint itemsize;\n\tint swapped=FALSE;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&LO&\", kwlist, \n\t\t\t\t\t &data, &s, \n\t\t\t\t\t PyArray_TypecodeConverter, &type,\n\t\t\t\t\t &nin, \n\t\t\t\t\t PyArray_BoolConverter,\n\t\t\t\t\t &swapped)) {\n\t\treturn NULL;\n\t}\n\t\n\tn = (intp) nin;\n\n\titemsize = type.itemsize;\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"zero-valued itemsize.\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tif ((ret = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &n, \n\t\t\t\t\t\ttype.type_num, NULL, \n\t\t\t\t\t\tNULL, itemsize, 0,\n\t\t\t\t\t\tNULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*ret->itemsize);\n\tif (swapped) ret->flags &= ~NOTSWAPPED;\n\tPyArray_INCREF(ret);\n\treturn (PyObject *)ret;\n}\n\n\n/* This needs an open file object and reads it in directly. \n memory-mapped files handled differently through buffer interface.\n\nfile pointer number in resulting 1d array \n(can easily reshape later, -1 for to end of file)\ntype of array\nsep is a separator string for character-based data (or NULL for binary)\n \" \" means whitespace\n*/\n\nstatic char doc_fromfile[] = \"\";\n\nstatic int\n_fill_in_itemsize(PyArray_Typecode *typecode)\n{\n\tPyArray_Descr *descr;\n\tdescr = PyArray_DescrFromType(typecode->type_num);\n\tif (descr==NULL) return -1;\n\ttypecode->itemsize = descr->elsize;\n\treturn 0;\n}\n\n\nstatic PyObject *\nPyArray_FromFile(FILE *fp, PyArray_Typecode *typecode, intp num, char *sep)\n{\n\tPyArrayObject *r;\n\tsize_t nread = 0;\n\tPyArray_ScanFunc *scan;\n\n\tif (typecode->itemsize == 0) {\n\t\tif (_fill_in_itemsize(typecode) < 0) \n\t\t\treturn NULL;\n\t}\n\n\tif (num == -1 && sep == NULL) { /* Get size for binary file*/\n\t\tintp start, numbytes;\n\t\tstart = (intp )ftell(fp);\n\t\tfseek(fp, 0, SEEK_END);\n\t\tnumbytes = (intp )ftell(fp) - start;\n\t\tfseek(fp, (long) start, SEEK_SET);\n\t\tif (numbytes == -1) {\n\t\t\tPyErr_SetString(PyExc_IOError, \"Could not seek in file.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (typecode->itemsize == 0) {\n\t\t\ttypecode->itemsize = numbytes;\n\t\t\tnum = 1;\n\t\t}\n\t\telse {\n\t\t\tnum = numbytes / typecode->itemsize;\n\t\t}\n\t}\n\t\n\tif (sep==NULL) { /* binary data */\n\t\tr = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &num, \n\t\t\t\t\t\t typecode->type_num,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t typecode->itemsize, 0, NULL);\n\t\tif (r==NULL) return NULL;\n\t\tnread = fread(r->data, typecode->itemsize, num, fp);\n\t}\n\telse { /* character reading */\n\t\tintp i;\n\t\tchar *dptr;\n\n\t\tif (num != -1) { /* number to read is known */\n\t\t\tr = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, \n\t\t\t\t\t\t\t &num, \n\t\t\t\t\t\t\t typecode->type_num,\n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t typecode->itemsize, \n\t\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\tscan = r->descr->scanfunc;\n\t\t\tif (scan == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"Don't know how to read \"\\\n\t\t\t\t\t\t\"character files with that \"\\\n\t\t\t\t\t\t\"array type\");\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = r->data;\n\t\t\tfor (i=0; i < num-1; i++) {\n\t\t\t\tif (scan(fp, dptr, r->itemsize, sep, NULL))\n\t\t\t\t\tbreak;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->itemsize;\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (!(scan(fp, dptr, r->itemsize, NULL, NULL)))\n\t\t\t\tnread += 1;\n\t\t}\n\t\telse { /* we have to watch for the end of the file and \n\t\t\t reallocate at the end */\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\t\t\tint done=0;\n\t\t\tr = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, \n\t\t\t\t\t\t\t &size, \n\t\t\t\t\t\t\t typecode->type_num,\n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t typecode->itemsize, \n\t\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * typecode->itemsize;\n\t\t\tdptr = r->data;\n\t\t\tscan = r->descr->scanfunc;\n\t\t\tif (scan == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"Don't know how to read \"\\\n\t\t\t\t\t\t\"character files with that \"\\\n\t\t\t\t\t\t\"array type\");\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\twhile (!done) {\n\t\t\t\tdone = scan(fp, dptr, r->itemsize, sep, NULL);\n\t\t\t\t/* end of file reached trying to \n\t\t\t\t scan value \n\t\t\t\t*/\n\t\t\t\tif (done == 1 || done < 0) break;\n\t\t\t\n\t\t\t\tthisbuf += 1;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->itemsize;\n\t\t\t\tif (!done && thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tr->data = PyDataMem_RENEW(r->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = r->data + (totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tr->data = PyDataMem_RENEW(r->data, nread*r->itemsize);\n\t\t\tPyArray_DIM(r,0) = nread;\n\t\t\tnum = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\tif (nread < num) {\n\t\tchar msg[80];\n\t\tsnprintf(msg, 80, \n\t\t\t \"%ld items requested only %ld read\", (long) num, \n (long) nread);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) {\n\t\t\tPy_DECREF(r);\n\t\t\treturn NULL;\n\t\t}\n\t\tr->data = PyDataMem_RENEW(r->data, nread * r->itemsize);\n\t\tPyArray_DIM(r,0) = nread;\n\t}\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *file=NULL, *ret;\n\tFILE *fp;\n\tchar *sep=\"\";\n\tchar *mode=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"file\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Typecode type = {PyArray_INTP, sizeof(intp), 0};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Ls\", kwlist, \n\t\t\t\t\t &file,\n\t\t\t\t\t PyArray_TypecodeConverter, &type,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"rb\";\n\t\telse mode=\"r\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfp = PyFile_AsFile(file);\n\tif (fp == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \"First argument must be an open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_FromFile(fp, &type, (intp) nin, sep);\n\tPy_DECREF(file);\n\treturn ret;\n}\n\nstatic PyObject *\nPyArray_FromBuffer(PyObject *buf, PyArray_Typecode *type, \n\t\t intp count, int swapped) \n{\n\tPyArrayObject *ret;\n\tchar *data;\n\tint ts;\n\tintp s, n;\n\tint itemsize;\n\tint write=1;\n\n\tif (type->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an OBJECT array from memory\"\\\n\t\t\t\t\" buffer.\");\n\t\treturn NULL;\n\t}\n\tif (type->itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Itemsize cannot be zero in type\");\n\t\treturn NULL;\n\t}\n\n\tif (PyObject_AsWriteBuffer(buf, (void *)&data, &ts)==-1) {\n\t\twrite = 0;\n\t\tPyErr_Clear();\n\t\tif (PyObject_AsReadBuffer(buf, (void *)&data, &ts)==-1) {\n\t\t\treturn NULL;\n\t\t}\n\t}\n\ts = (intp)ts;\t\n\tn = (intp)count;\n\titemsize = type->itemsize;\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &n, \n\t\t\t\t\t\ttype->type_num, NULL, \n\t\t\t\t\t\tdata, itemsize, DEFAULT_FLAGS,\n\t\t\t\t\t\tNULL)) == NULL)\n\t\treturn NULL;\n\t\n\tif (!write) ret->flags &= ~WRITEABLE;\n\tif (swapped) ret->flags &= ~NOTSWAPPED;\n\tPy_INCREF(buf);\n\t/* Store a reference for decref on deallocation */\n\tret->base = buf;\n\tPyArray_UpdateFlags(ret, ALIGNED);\n\treturn (PyObject *)ret; \t\n}\n\nstatic char doc_frombuffer[] = \"\";\n\nstatic PyObject *\narray_frombuffer(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *obj=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"buffer\", \"dtype\", \"count\", \n\t\t\t\t \"swap\", NULL};\n\tPyArray_Typecode type = {PyArray_INTP, sizeof(intp), 0};\n\tint swapped=0;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Li\", kwlist, \n\t\t\t\t\t &obj,\n\t\t\t\t\t PyArray_TypecodeConverter, &type,\n\t\t\t\t\t &nin, &swapped)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromBuffer(obj, &type, (intp)nin, swapped);\n}\n\n\n\nstatic char doc_concatenate[] = \"concatenate((a1,a2,...),axis=None).\";\n\nstatic PyObject *\narray_concatenate(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *a0;\n\tint axis=0;\n\tstatic char *kwlist[] = {\"seq\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist,\n\t\t\t\t\t &a0,\n\t\t\t\t\t PyArray_AxisConverter, &axis))\n\t\treturn NULL;\n\treturn PyArray_Concatenate(a0, axis);\n}\n\nstatic char doc_innerproduct[] = \\\n\t\"inner(a,b) returns the dot product of two arrays, which has\\n\"\\\n\t\"shape a.shape[:-1] + b.shape[:-1] with elements computed by\\n\" \\\n\t\"the product of the elements from the last dimensions of a and b.\";\n\nstatic PyObject *array_innerproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *b0, *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a0, &b0)) return NULL;\n\t\n\treturn _ARET(PyArray_InnerProduct(a0, b0));\n}\n\nstatic char doc_matrixproduct[] = \\\n\t\"dot(a,v) returns matrix-multiplication between a and b. \\n\"\\\n\t\"The product-sum is over the last dimension of a and the \\n\"\\\n\t\"second-to-last dimension of b.\";\n\nstatic PyObject *array_matrixproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *v, *a;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a, &v)) return NULL;\n\t\n\treturn _ARET(PyArray_MatrixProduct(a, v));\n}\n\nstatic char doc_fastCopyAndTranspose[] = \"_fastCopyAndTranspose(a)\";\n\nstatic PyObject *array_fastCopyAndTranspose(PyObject *dummy, PyObject *args) {\n\tPyObject *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &a0)) return NULL;\n\t\n\treturn _ARET(PyArray_CopyAndTranspose(a0));\n}\n\nstatic char doc_correlate[] = \"cross_correlate(a,v, mode=0)\";\n\nstatic PyObject *array_correlate(PyObject *dummy, PyObject *args, PyObject *kwds) {\n\tPyObject *shape, *a0;\n\tint mode=0;\n\tstatic char *kwlist[] = {\"a\", \"v\", \"mode\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|i\", kwlist, \n\t\t\t\t\t &a0, &shape, &mode)) return NULL;\n\t\n\treturn PyArray_Correlate(a0, shape, mode);\n}\n\n\nstatic PyObject *\nPyArray_Arange(double start, double stop, double step, int type_num)\n{\n\tintp length, i;\n\tPyObject *range;\n\tchar *rptr;\n\tint elsize, type;\n\tdouble value;\n\tPyArray_Descr *dbl_descr;\n\n\tlength = (intp ) ceil((stop - start)/step);\n \n\tif (length <= 0) {\n\t\tlength = 0;\n\t\treturn PyArray_New(&PyArray_Type, 1, &length, type_num,\n\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t}\n\n\trange = PyArray_New(&PyArray_Type, 1, &length, type_num, \n\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (range == NULL) return NULL;\n\tdbl_descr = PyArray_DescrFromType(PyArray_DOUBLE);\n \n\trptr = ((PyArrayObject *)range)->data;\n\telsize = ((PyArrayObject *)range)->itemsize;\n\ttype = ((PyArrayObject *)range)->descr->type_num;\n\tfor (i=0; i < length; i++) {\n\t\tvalue = start + i*step;\n\t\tdbl_descr->cast[type]((char*)&value, rptr, 1, NULL, \n\t\t\t\t (PyArrayObject *)range);\n\t\trptr += elsize;\n\t}\n \n\treturn range;\n}\n\n\nstatic char doc_arange[] = \"arange(start, stop=None, step=1, dtype=intp)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\n\nstatic PyObject *\narray_arange(PyObject *ignored, PyObject *args, PyObject *kws) {\n\tPyObject *o_start=NULL, *o_stop=Py_None, *o_step=NULL;\n\tstatic char *kwd[]= {\"start\", \"stop\", \"step\", \"dtype\", NULL};\n\tdouble start, stop, step;\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0};\n\tint type_num;\n\tint deftype = PyArray_INTP;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|OOO&\", kwd, &o_start,\n\t\t\t\t\t&o_stop, &o_step, \n\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t&typecode)) \n\t\treturn NULL;\n\n\tdeftype = PyArray_ObjectType(o_start, deftype);\n\tif (o_stop != Py_None) {\n\t\tdeftype = PyArray_ObjectType(o_stop, deftype);\n\t}\n\tif (o_step != NULL) {\n\t\tdeftype = PyArray_ObjectType(o_step, deftype);\n\t}\n\n\ttype_num = typecode.type_num;\n\tif (type_num == PyArray_NOTYPE) {\n\t\ttype_num = deftype;\n\t}\n\n\tstart = PyFloat_AsDouble(o_start);\n\tif error_converting(start) return NULL;\n\n\tif (o_step == NULL) {\n\t\tstep = 1;\n\t}\n\telse {\n\t\tstep = PyFloat_AsDouble(o_step);\n\t\tif error_converting(step) return NULL;\n\t}\n\n\tif (o_stop == Py_None) {\n\t\tstop = start;\n\t\tstart = 0;\n\t}\n\telse {\n\t\tstop = PyFloat_AsDouble(o_stop);\n\t\tif error_converting(stop) return NULL;\n\t}\n\n\treturn PyArray_Arange(start, stop, step, type_num);\n}\n\n#undef _ARET\n\n/*****\n static char doc_arrayMap[] = \"arrayMap(func, [a1,...,an])\";\n\n static PyObject *array_arrayMap(PyObject *dummy, PyObject *args) {\n PyObject *shape, *a0;\n \n if (PyArg_ParseTuple(args, \"OO\", &a0, &shape) == NULL) return NULL;\n\t\n return PyArray_Map(a0, shape);\n }\n*****/\n\nstatic char \ndoc_set_string_function[] = \"set_string_function(f, repr=1) sets the python function f to be the function used to obtain a pretty printable string version of a array whenever a array is printed. f(M) should expect a array argument M, and should return a string consisting of the desired representation of M for printing.\";\n\nstatic PyObject *\narray_set_string_function(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *op;\n\tint repr=1;\n\tstatic char *kwlist[] = {\"f\", \"repr\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|i\", kwlist, \n\t\t\t\t\t&op, &repr)) return NULL; \n\tPyArray_SetStringFunction(op, repr);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char \ndoc_set_ops_function[] = \"set_numeric_ops(op=func, ...) sets some or all of the number methods for all array objects. Don't forget **dict can be used as the argument list. Returns the functions that were replaced -- can be stored and set later.\";\n\nstatic PyObject *\narray_set_ops_function(PyObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *oldops=NULL;\n\t\n\tif ((oldops = PyArray_GetNumericOps())==NULL) return NULL;\n\n\t/* Should probably ensure that objects are at least callable */\n\t/* Leave this to the caller for now --- error will be raised\n\t later when use is attempted \n\t*/\n\tif (PyArray_SetNumericOps(kwds) == -1) {\n\t\tPy_DECREF(oldops);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"One or more objects is not callable.\");\n\t\treturn NULL;\n\t}\n\treturn oldops;\n}\n\n\nstatic PyObject *\nPyArray_Where(PyObject *condition, PyObject *x, PyObject *y)\n{\n\tPyArrayObject *arr;\n\tPyObject *tup=NULL, *obj=NULL;\n\tPyObject *ret=NULL, *zero=NULL;\n\n\tif ((x==NULL) || (y==NULL)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"either both or neither\"\n\t\t\t\t\"of x and y should be given.\");\n\t\treturn NULL;\n\t}\n\n\tarr = (PyArrayObject *)PyArray_FromAny(condition, NULL, 0, 0, 0);\n\tif (arr == NULL) return NULL;\n\n\tif ((x==NULL) && (y==NULL)) {\n\t\tret = PyArray_Nonzero(arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\n\tzero = PyInt_FromLong((long) 0);\n\n\tobj = PyArray_EnsureArray(PyArray_GenericBinaryFunction(arr, zero, n_ops.not_equal));\n\tPy_DECREF(zero);\n\tPy_DECREF(arr);\n\tif (obj == NULL) return NULL;\n\n\ttup = Py_BuildValue(\"(OO)\", y, x);\n\tif (tup == NULL) {Py_DECREF(obj); return NULL;}\n\n\tret = PyArray_Choose((PyAO *)obj, tup);\n\n\tPy_DECREF(obj);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n\nstatic char doc_where[] = \"where(condition, | x, y) is shaped like condition\"\\\n\t\" and has elements of x and y where condition is respectively true or\"\\\n\t\" false. If x or y are not given, then it is equivalent to\"\\\n\t\" nonzero(condition).\";\n\nstatic PyObject *\narray_where(PyObject *ignored, PyObject *args)\n{\n\tPyObject *obj=NULL, *x=NULL, *y=NULL;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|OO\", &obj, &x, &y)) return NULL;\n\n\treturn PyArray_Where(obj, x, y);\n\n}\n\nstatic char doc_register_dtype[] = \\\n\t\"register_dtype(a) registers a new type object -- gives it a typenum\";\n\nstatic PyObject *\narray_register_dtype(PyObject *dummy, PyObject *args)\n{\n\tPyObject *dtype;\n\tint ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &dtype)) return NULL;\n\t\n\tret = PyArray_RegisterDataType((PyTypeObject *)dtype);\n\tif (ret < 0)\n\t\treturn NULL;\n\treturn PyInt_FromLong((long) ret);\n}\n\nstatic char doc_can_cast_safely[] = \\\n\t\"can_cast_safely(from=d1, to=d2) returns True if data type d1 \"\\\n\t\"can be cast to data type d2 without losing precision.\";\n\nstatic PyObject *\narray_can_cast_safely(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Typecode d1={PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode d2={PyArray_NOTYPE, 0, 0};\n\tBool ret;\n\tPyObject *retobj;\n\tstatic char *kwlist[] = {\"from\", \"to\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O&O&\", kwlist, \n\t\t\t\t\tPyArray_TypecodeConverter, &d1,\n\t\t\t\t\tPyArray_TypecodeConverter, &d2))\n\t\treturn NULL;\n\tif (d1.type_num == PyArray_NOTYPE || \\\n\t d2.type_num == PyArray_NOTYPE) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"did not understand one of the types. \"\\\n\t\t\t\t\"'None' not accepted.\");\n\t\treturn NULL;\n\t}\n\t\t\n\tret = PyArray_CanCastTo(&d1, &d2);\n\tretobj = (ret ? Py_True : Py_False);\n\tPy_INCREF(retobj);\n\treturn retobj;\n}\n\n\nstatic struct PyMethodDef array_module_methods[] = {\n\t{\"set_string_function\", (PyCFunction)array_set_string_function, \n\t METH_VARARGS|METH_KEYWORDS, doc_set_string_function},\n\t{\"set_numeric_ops\", (PyCFunction)array_set_ops_function,\n\t METH_VARARGS|METH_KEYWORDS, doc_set_ops_function},\n\t{\"set_typeDict\", (PyCFunction)array_set_typeDict,\n\t METH_VARARGS, doc_set_typeDict},\n\n\t{\"array\",\t(PyCFunction)_array_fromobject, \n\t METH_VARARGS|METH_KEYWORDS, doc_fromobject},\n\t{\"arange\", (PyCFunction)array_arange, \n\t METH_VARARGS|METH_KEYWORDS, doc_arange},\n\t{\"zeros\",\t(PyCFunction)array_zeros, \n\t METH_VARARGS|METH_KEYWORDS, doc_zeros},\n\t{\"empty\",\t(PyCFunction)array_empty, \n\t METH_VARARGS|METH_KEYWORDS, doc_empty},\n\t{\"scalar\", (PyCFunction)array_scalar,\n\t METH_VARARGS|METH_KEYWORDS, doc_scalar},\n\t{\"where\", (PyCFunction)array_where,\n\t METH_VARARGS, doc_where},\n\t{\"fromstring\",(PyCFunction)array_fromString,\n\t METH_VARARGS|METH_KEYWORDS, doc_fromString},\n\t{\"concatenate\", (PyCFunction)array_concatenate, \n\t METH_VARARGS|METH_KEYWORDS, doc_concatenate},\n\t{\"inner\", (PyCFunction)array_innerproduct, \n\t METH_VARARGS, doc_innerproduct}, \n\t{\"dot\", (PyCFunction)array_matrixproduct, \n\t METH_VARARGS, doc_matrixproduct}, \n\t{\"_fastCopyAndTranspose\", (PyCFunction)array_fastCopyAndTranspose, \n\t METH_VARARGS, doc_fastCopyAndTranspose},\n\t{\"correlate\", (PyCFunction)array_correlate, \n\t METH_VARARGS | METH_KEYWORDS, doc_correlate},\n\t{\"frombuffer\", (PyCFunction)array_frombuffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_frombuffer},\n\t{\"fromfile\", (PyCFunction)array_fromfile,\n\t METH_VARARGS | METH_KEYWORDS, doc_fromfile},\n\t{\"register_dtype\", (PyCFunction)array_register_dtype,\n\t METH_VARARGS, doc_register_dtype},\n\t{\"can_cast\", (PyCFunction)array_can_cast_safely,\n\t METH_VARARGS | METH_KEYWORDS, doc_can_cast_safely},\t\t\n\t/* {\"arrayMap\",\t(PyCFunction)array_arrayMap, \n\t METH_VARARGS, doc_arrayMap},*/\n\t\n\t{NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n#include \"__multiarray_api.c\"\n\n/* Establish scalar-type hierarchy */\n\n/* For dual inheritance we need to make sure that the objects being\n inherited from have the tp->mro object initialized. This is\n not necessarily true for the basic type objects of Python (it is \n checked for single inheritance but not dual in PyType_Ready).\n\n Thus, we call PyType_Ready on the standard Python Types, here.\n*/ \nstatic int\nsetup_scalartypes(PyObject *dict)\n{\n\n\tinitialize_numeric_types();\n\n if (PyType_Ready(&PyBool_Type) < 0) return -1;\n if (PyType_Ready(&PyInt_Type) < 0) return -1;\n if (PyType_Ready(&PyFloat_Type) < 0) return -1;\n if (PyType_Ready(&PyComplex_Type) < 0) return -1;\n if (PyType_Ready(&PyString_Type) < 0) return -1;\n if (PyType_Ready(&PyUnicode_Type) < 0) return -1;\n\n#define SINGLE_INHERIT(child, parent) \\\n Py##child##ArrType_Type.tp_base = &Py##parent##ArrType_Type;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) {\t\t\\\n PyErr_Print(); \\\n PyErr_Format(PyExc_SystemError, \\\n\t\t\t \"Could not initialize Py%sArrType_Tyupe\", \\\n #child); \\\n return -1;\t\t\t\t\t\t\\\n }\n \n if (PyType_Ready(&PyGenericArrType_Type) < 0)\n return -1;\n\n SINGLE_INHERIT(Numeric, Generic);\n SINGLE_INHERIT(Integer, Numeric);\n SINGLE_INHERIT(Inexact, Numeric);\n SINGLE_INHERIT(SignedInteger, Integer);\n SINGLE_INHERIT(UnsignedInteger, Integer);\n SINGLE_INHERIT(Floating, Inexact);\n SINGLE_INHERIT(ComplexFloating, Inexact);\n SINGLE_INHERIT(Flexible, Generic);\n SINGLE_INHERIT(Character, Flexible);\n\t\n#define DUAL_INHERIT(child, parent1, parent2) \\\n Py##child##ArrType_Type.tp_base = &Py##parent2##ArrType_Type;\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent2##ArrType_Type,\t\\\n\t\t\t &Py##parent1##_Type);\t\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"Could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n#define DUAL_INHERIT2(child, parent1, parent2)\t\t\t\t\\\n Py##child##ArrType_Type.tp_base = &Py##parent1##_Type;\t\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent1##_Type,\t\t\\\n\t\t\t &Py##parent2##ArrType_Type);\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"Could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n SINGLE_INHERIT(Bool, Generic);\n SINGLE_INHERIT(Byte, SignedInteger);\n SINGLE_INHERIT(Short, SignedInteger);\n#if SIZEOF_INT == SIZEOF_LONG\n DUAL_INHERIT(Int, Int, SignedInteger);\n#else\n SINGLE_INHERIT(Int, SignedInteger);\n#endif\n DUAL_INHERIT(Long, Int, SignedInteger);\n SINGLE_INHERIT(LongLong, SignedInteger);\n\n SINGLE_INHERIT(UByte, UnsignedInteger);\n SINGLE_INHERIT(UShort, UnsignedInteger);\n SINGLE_INHERIT(UInt, UnsignedInteger);\n SINGLE_INHERIT(ULong, UnsignedInteger);\n SINGLE_INHERIT(ULongLong, UnsignedInteger);\n\n SINGLE_INHERIT(Float, Floating);\n DUAL_INHERIT(Double, Float, Floating);\n SINGLE_INHERIT(LongDouble, Floating);\n\n SINGLE_INHERIT(CFloat, ComplexFloating);\n DUAL_INHERIT(CDouble, Complex, ComplexFloating);\n SINGLE_INHERIT(CLongDouble, ComplexFloating);\n\n DUAL_INHERIT2(String, String, Character);\n DUAL_INHERIT2(Unicode, Unicode, Character);\n\t\n SINGLE_INHERIT(Void, Flexible);\n \n SINGLE_INHERIT(Object, Generic);\n\n return 0;\n\n#undef SINGLE_INHERIT\n#undef DUAL_INHERIT\n\n\t/* Clean up string and unicode array types so they act more like\n\t strings -- get their tables from the standard types.\n\t \n\t \n\t*/\n}\n\n/* place a flag dictionary in d */\n\nstatic void\nset_flaginfo(PyObject *d)\n{\n PyObject *s;\n PyObject *newd;\n \n newd = PyDict_New();\n\n PyDict_SetItemString(newd, \"OWNDATA\", s=PyInt_FromLong(OWNDATA));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"FORTRAN\", s=PyInt_FromLong(FORTRAN));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"CONTIGUOUS\", s=PyInt_FromLong(CONTIGUOUS));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"ALIGNED\", s=PyInt_FromLong(ALIGNED));\n Py_DECREF(s);\n\n PyDict_SetItemString(newd, \"NOTSWAPPED\", s=PyInt_FromLong(NOTSWAPPED));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"UPDATEIFCOPY\", s=PyInt_FromLong(UPDATEIFCOPY));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"WRITEABLE\", s=PyInt_FromLong(WRITEABLE));\n Py_DECREF(s);\n \n PyDict_SetItemString(d, \"_flagdict\", newd);\n Py_DECREF(newd);\n return;\n}\n\n\n/* Initialization function for the module */\n\nDL_EXPORT(void) initmultiarray(void) {\n\tPyObject *m, *d, *s;\n\tPyObject *c_api;\n\t\n\t/* Create the module and add the functions */\n\tm = Py_InitModule(\"multiarray\", array_module_methods);\n\tif (!m) goto err;\n\n\t/* Add some symbolic constants to the module */\n\td = PyModule_GetDict(m);\n\tif (!d) goto err; \n\n\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\n\n\tif (PyType_Ready(&PyArray_Type) < 0)\n return;\n\n if (setup_scalartypes(d) < 0) goto err;\n\n\tif (PyType_Ready(&PyArrayIter_Type) < 0)\n\t\treturn; \n \n\tif (PyType_Ready(&PyArrayMapIter_Type) < 0)\n return; \n\n\tc_api = PyCObject_FromVoidPtr((void *)PyArray_API, NULL);\n\tif (PyErr_Occurred()) goto err;\n\tPyDict_SetItemString(d, \"_ARRAY_API\", c_api);\n\tPy_DECREF(c_api);\n\tif (PyErr_Occurred()) goto err;\n\n\tMultiArrayError = PyString_FromString (\"multiarray.error\");\n\tPyDict_SetItemString (d, \"error\", MultiArrayError);\n\t\n\ts = PyString_FromString(\"3.0\");\n\tPyDict_SetItemString(d, \"__version__\", s);\n\tPy_DECREF(s);\n Py_INCREF(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\n Py_INCREF(&PyArray_Type);\n\tPyDict_SetItemString(d, \"ndarray\", (PyObject *)&PyArray_Type);\n Py_INCREF(&PyArrayIter_Type);\n\tPyDict_SetItemString(d, \"flatiter\", (PyObject *)&PyArrayIter_Type);\n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\n set_flaginfo(d);\n\n\tif (set_typeinfo(d) == 0) \n return; /* otherwise there is an error */\n\n\n err:\t\n\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", "methods": [ { "name": "PyArray_MultiplyList", "long_name": "PyArray_MultiplyList( intp * l1 , int n)", "filename": "multiarraymodule.c", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "l1", "n" ], "start_line": 51, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_AxisConverter", "long_name": "PyArray_AxisConverter( PyObject * obj , int * axis)", "filename": "multiarraymodule.c", "nloc": 13, "complexity": 3, "token_count": 53, "parameters": [ "obj", "axis" ], "start_line": 61, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_CompareLists", "long_name": "PyArray_CompareLists( intp * l1 , intp * l2 , int n)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 3, "token_count": 51, "parameters": [ "l1", "l2", "n" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_View", "long_name": "PyArray_View( PyArrayObject * self , PyArray_Typecode * type)", "filename": "multiarraymodule.c", "nloc": 42, "complexity": 9, "token_count": 241, "parameters": [ "self", "type" ], "start_line": 86, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "PyArray_Ravel", "long_name": "PyArray_Ravel( PyArrayObject * a , int fortran)", "filename": "multiarraymodule.c", "nloc": 14, "complexity": 4, "token_count": 87, "parameters": [ "a", "fortran" ], "start_line": 137, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "PyArray_Flatten", "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", "filename": "multiarraymodule.c", "nloc": 32, "complexity": 5, "token_count": 158, "parameters": [ "a", "fortran" ], "start_line": 154, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_Reshape", "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self", "shape" ], "start_line": 195, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "PyArray_Newshape", "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", "filename": "multiarraymodule.c", "nloc": 68, "complexity": 15, "token_count": 362, "parameters": [ "self", "newdims" ], "start_line": 212, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 0 }, { "name": "PyArray_Squeeze", "long_name": "PyArray_Squeeze( PyArrayObject * self)", "filename": "multiarraymodule.c", "nloc": 30, "complexity": 4, "token_count": 188, "parameters": [ "self" ], "start_line": 299, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyArray_Mean", "long_name": "PyArray_Mean( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 19, "complexity": 4, "token_count": 139, "parameters": [ "self", "axis", "rtype" ], "start_line": 334, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_Std", "long_name": "PyArray_Std( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 43, "complexity": 12, "token_count": 433, "parameters": [ "self", "axis", "rtype" ], "start_line": 358, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "PyArray_Sum", "long_name": "PyArray_Sum( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 417, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Prod", "long_name": "PyArray_Prod( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 430, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_CumSum", "long_name": "PyArray_CumSum( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 443, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_CumProd", "long_name": "PyArray_CumProd( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 456, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Any", "long_name": "PyArray_Any( PyArrayObject * self , int axis)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 66, "parameters": [ "self", "axis" ], "start_line": 470, "end_line": 481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_All", "long_name": "PyArray_All( PyArrayObject * self , int axis)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 66, "parameters": [ "self", "axis" ], "start_line": 484, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Compress", "long_name": "PyArray_Compress( PyArrayObject * self , PyObject * condition , int axis)", "filename": "multiarraymodule.c", "nloc": 18, "complexity": 3, "token_count": 110, "parameters": [ "self", "condition", "axis" ], "start_line": 499, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyArray_Nonzero", "long_name": "PyArray_Nonzero( PyArrayObject * self)", "filename": "multiarraymodule.c", "nloc": 50, "complexity": 13, "token_count": 395, "parameters": [ "self" ], "start_line": 522, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "PyArray_Clip", "long_name": "PyArray_Clip( PyArrayObject * self , PyObject * min , PyObject * max)", "filename": "multiarraymodule.c", "nloc": 30, "complexity": 6, "token_count": 241, "parameters": [ "self", "min", "max" ], "start_line": 583, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_Conjugate", "long_name": "PyArray_Conjugate( PyArrayObject * self)", "filename": "multiarraymodule.c", "nloc": 36, "complexity": 9, "token_count": 225, "parameters": [ "self" ], "start_line": 619, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_Trace", "long_name": "PyArray_Trace( PyArrayObject * self , int offset , int axis1 , int axis2 , int rtype)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 81, "parameters": [ "self", "offset", "axis1", "axis2", "rtype" ], "start_line": 658, "end_line": 668, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Diagonal", "long_name": "PyArray_Diagonal( PyArrayObject * self , int offset , int axis1 , int axis2)", "filename": "multiarraymodule.c", "nloc": 104, "complexity": 24, "token_count": 798, "parameters": [ "self", "offset", "axis1", "axis2" ], "start_line": 671, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 0 }, { "name": "PyArray_AsCArray", "long_name": "PyArray_AsCArray( PyObject ** op , * ptr , intp * dims , int nd , int type_num)", "filename": "multiarraymodule.c", "nloc": 54, "complexity": 13, "token_count": 426, "parameters": [ "op", "ptr", "dims", "nd", "type_num" ], "start_line": 806, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "PyArray_As1D", "long_name": "PyArray_As1D( PyObject ** op , char ** ptr , int * d1 , int typecode)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 2, "token_count": 60, "parameters": [ "op", "ptr", "d1", "typecode" ], "start_line": 866, "end_line": 874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_As2D", "long_name": "PyArray_As2D( PyObject ** op , char ** * ptr , int * d1 , int * d2 , int typecode)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 81, "parameters": [ "op", "ptr", "d1", "d2", "typecode" ], "start_line": 878, "end_line": 888, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Free", "long_name": "PyArray_Free( PyObject * op , * ptr)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 4, "token_count": 67, "parameters": [ "op", "ptr" ], "start_line": 893, "end_line": 904, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "_swap_and_concat", "long_name": "_swap_and_concat( PyObject * op , int axis , int n)", "filename": "multiarraymodule.c", "nloc": 27, "complexity": 6, "token_count": 185, "parameters": [ "op", "axis", "n" ], "start_line": 908, "end_line": 936, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_Concatenate", "long_name": "PyArray_Concatenate( PyObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 112, "complexity": 24, "token_count": 761, "parameters": [ "op", "axis" ], "start_line": 945, "end_line": 1071, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 127, "top_nesting_level": 0 }, { "name": "PyArray_SwapAxes", "long_name": "PyArray_SwapAxes( PyArrayObject * ap , int a1 , int a2)", "filename": "multiarraymodule.c", "nloc": 37, "complexity": 12, "token_count": 227, "parameters": [ "ap", "a1", "a2" ], "start_line": 1074, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_Transpose", "long_name": "PyArray_Transpose( PyArrayObject * ap , PyObject * op)", "filename": "multiarraymodule.c", "nloc": 49, "complexity": 15, "token_count": 399, "parameters": [ "ap", "op" ], "start_line": 1117, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "PyArray_Repeat", "long_name": "PyArray_Repeat( PyArrayObject * aop , PyObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 75, "complexity": 15, "token_count": 516, "parameters": [ "aop", "op", "axis" ], "start_line": 1179, "end_line": 1271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 93, "top_nesting_level": 0 }, { "name": "PyArray_Choose", "long_name": "PyArray_Choose( PyArrayObject * ip , PyObject * op)", "filename": "multiarraymodule.c", "nloc": 89, "complexity": 18, "token_count": 646, "parameters": [ "ip", "op" ], "start_line": 1275, "end_line": 1387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 113, "top_nesting_level": 0 }, { "name": "qsortCompare", "long_name": "qsortCompare( const * a , const * b)", "filename": "multiarraymodule.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "a", "b" ], "start_line": 1395, "end_line": 1398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PyArray_Sort", "long_name": "PyArray_Sort( PyArrayObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 36, "complexity": 7, "token_count": 250, "parameters": [ "op", "axis" ], "start_line": 1420, "end_line": 1469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "argsort_static_compare", "long_name": "argsort_static_compare( const * ip1 , const * ip2)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "ip1", "ip2" ], "start_line": 1475, "end_line": 1483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_ArgSort", "long_name": "PyArray_ArgSort( PyArrayObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 48, "complexity": 8, "token_count": 346, "parameters": [ "op", "axis" ], "start_line": 1486, "end_line": 1545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "local_where", "long_name": "local_where( PyArrayObject * ap1 , PyArrayObject * ap2 , PyArrayObject * ret)", "filename": "multiarraymodule.c", "nloc": 35, "complexity": 7, "token_count": 243, "parameters": [ "ap1", "ap2", "ret" ], "start_line": 1548, "end_line": 1583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_SearchSorted", "long_name": "PyArray_SearchSorted( PyArrayObject * op1 , PyObject * op2)", "filename": "multiarraymodule.c", "nloc": 33, "complexity": 5, "token_count": 219, "parameters": [ "op1", "op2" ], "start_line": 1586, "end_line": 1631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "PyArray_InnerProduct", "long_name": "PyArray_InnerProduct( PyObject * op1 , PyObject * op2)", "filename": "multiarraymodule.c", "nloc": 82, "complexity": 17, "token_count": 653, "parameters": [ "op1", "op2" ], "start_line": 1639, "end_line": 1741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 }, { "name": "PyArray_MatrixProduct", "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", "filename": "multiarraymodule.c", "nloc": 98, "complexity": 20, "token_count": 756, "parameters": [ "op1", "op2" ], "start_line": 1746, "end_line": 1867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 }, { "name": "PyArray_CopyAndTranspose", "long_name": "PyArray_CopyAndTranspose( PyObject * op)", "filename": "multiarraymodule.c", "nloc": 44, "complexity": 6, "token_count": 282, "parameters": [ "op" ], "start_line": 1870, "end_line": 1921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "PyArray_Correlate", "long_name": "PyArray_Correlate( PyObject * op1 , PyObject * op2 , int mode)", "filename": "multiarraymodule.c", "nloc": 86, "complexity": 13, "token_count": 598, "parameters": [ "op1", "op2", "mode" ], "start_line": 1924, "end_line": 2019, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "PyArray_ArgMin", "long_name": "PyArray_ArgMin( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 21, "complexity": 5, "token_count": 138, "parameters": [ "ap", "axis" ], "start_line": 2022, "end_line": 2047, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "PyArray_Max", "long_name": "PyArray_Max( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [ "ap", "axis" ], "start_line": 2050, "end_line": 2061, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Min", "long_name": "PyArray_Min( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [ "ap", "axis" ], "start_line": 2064, "end_line": 2075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Ptp", "long_name": "PyArray_Ptp( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 22, "complexity": 4, "token_count": 138, "parameters": [ "ap", "axis" ], "start_line": 2078, "end_line": 2101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "PyArray_ArgMax", "long_name": "PyArray_ArgMax( PyArrayObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 46, "complexity": 7, "token_count": 318, "parameters": [ "op", "axis" ], "start_line": 2105, "end_line": 2161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 0 }, { "name": "PyArray_Take", "long_name": "PyArray_Take( PyArrayObject * self0 , PyObject * indices0 , int axis)", "filename": "multiarraymodule.c", "nloc": 61, "complexity": 12, "token_count": 464, "parameters": [ "self0", "indices0", "axis" ], "start_line": 2165, "end_line": 2236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_Put", "long_name": "PyArray_Put( PyArrayObject * self , PyObject * indices0 , PyObject * values0)", "filename": "multiarraymodule.c", "nloc": 47, "complexity": 10, "token_count": 319, "parameters": [ "self", "indices0", "values0" ], "start_line": 2239, "end_line": 2291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "PyArray_PutMask", "long_name": "PyArray_PutMask( PyArrayObject * self , PyObject * mask0 , PyObject * values0)", "filename": "multiarraymodule.c", "nloc": 56, "complexity": 10, "token_count": 334, "parameters": [ "self", "mask0", "values0" ], "start_line": 2294, "end_line": 2356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_Converter", "long_name": "PyArray_Converter( PyObject * object , PyObject ** address)", "filename": "multiarraymodule.c", "nloc": 13, "complexity": 3, "token_count": 66, "parameters": [ "object", "address" ], "start_line": 2368, "end_line": 2380, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_BoolConverter", "long_name": "PyArray_BoolConverter( PyObject * object , Bool * val)", "filename": "multiarraymodule.c", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "object", "val" ], "start_line": 2383, "end_line": 2389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_TypestrConvert", "long_name": "PyArray_TypestrConvert( int itemsize , int gentype)", "filename": "multiarraymodule.c", "nloc": 90, "complexity": 33, "token_count": 284, "parameters": [ "itemsize", "gentype" ], "start_line": 2393, "end_line": 2502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 110, "top_nesting_level": 0 }, { "name": "PyArray_BufferConverter", "long_name": "PyArray_BufferConverter( PyObject * obj , PyArray_Chunk * buf)", "filename": "multiarraymodule.c", "nloc": 20, "complexity": 6, "token_count": 147, "parameters": [ "obj", "buf" ], "start_line": 2517, "end_line": 2542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "PyArray_IntpConverter", "long_name": "PyArray_IntpConverter( PyObject * obj , PyArray_Dims * seq)", "filename": "multiarraymodule.c", "nloc": 35, "complexity": 10, "token_count": 186, "parameters": [ "obj", "seq" ], "start_line": 2554, "end_line": 2590, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_TypecodeConverter", "long_name": "PyArray_TypecodeConverter( PyObject * obj , PyArray_Typecode * at)", "filename": "multiarraymodule.c", "nloc": 108, "complexity": 33, "token_count": 639, "parameters": [ "obj", "at" ], "start_line": 2599, "end_line": 2737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "PyArray_EquivalentTypes", "long_name": "PyArray_EquivalentTypes( PyArray_Typecode * typ1 , PyArray_Typecode * typ2)", "filename": "multiarraymodule.c", "nloc": 24, "complexity": 8, "token_count": 162, "parameters": [ "typ1", "typ2" ], "start_line": 2745, "end_line": 2772, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyArray_EquivArrTypes", "long_name": "PyArray_EquivArrTypes( PyArrayObject * a1 , PyArrayObject * a2)", "filename": "multiarraymodule.c", "nloc": 6, "complexity": 1, "token_count": 56, "parameters": [ "a1", "a2" ], "start_line": 2775, "end_line": 2781, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_array_fromobject", "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", "filename": "multiarraymodule.c", "nloc": 38, "complexity": 9, "token_count": 254, "parameters": [ "ignored", "args", "kws" ], "start_line": 2792, "end_line": 2836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_Empty", "long_name": "PyArray_Empty( int nd , intp * dims , PyArray_Typecode * type)", "filename": "multiarraymodule.c", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "nd", "dims", "type" ], "start_line": 2839, "end_line": 2855, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "array_empty", "long_name": "array_empty( PyObject * ignored , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 21, "complexity": 3, "token_count": 134, "parameters": [ "ignored", "args", "kwds" ], "start_line": 2861, "end_line": 2885, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_scalar", "long_name": "array_scalar( PyObject * ignored , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 56, "complexity": 11, "token_count": 290, "parameters": [ "ignored", "args", "kwds" ], "start_line": 2890, "end_line": 2954, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 }, { "name": "PyArray_Zeros", "long_name": "PyArray_Zeros( int nd , intp * dims , PyArray_Typecode * type)", "filename": "multiarraymodule.c", "nloc": 20, "complexity": 3, "token_count": 133, "parameters": [ "nd", "dims", "type" ], "start_line": 2958, "end_line": 2980, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_zeros", "long_name": "array_zeros( PyObject * ignored , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 22, "complexity": 3, "token_count": 134, "parameters": [ "ignored", "args", "kwds" ], "start_line": 2986, "end_line": 3010, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_set_typeDict", "long_name": "array_set_typeDict( PyObject * ignored , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "ignored", "args" ], "start_line": 3017, "end_line": 3026, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_fromString", "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", "filename": "multiarraymodule.c", "nloc": 50, "complexity": 8, "token_count": 283, "parameters": [ "ignored", "args", "keywds" ], "start_line": 3031, "end_line": 3086, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "_fill_in_itemsize", "long_name": "_fill_in_itemsize( PyArray_Typecode * typecode)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 2, "token_count": 42, "parameters": [ "typecode" ], "start_line": 3102, "end_line": 3109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_FromFile", "long_name": "PyArray_FromFile( FILE * fp , PyArray_Typecode * typecode , intp num , char * sep)", "filename": "multiarraymodule.c", "nloc": 130, "complexity": 26, "token_count": 764, "parameters": [ "fp", "typecode", "num", "sep" ], "start_line": 3113, "end_line": 3253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 141, "top_nesting_level": 0 }, { "name": "array_fromfile", "long_name": "array_fromfile( PyObject * ignored , PyObject * args , PyObject * keywds)", "filename": "multiarraymodule.c", "nloc": 34, "complexity": 6, "token_count": 221, "parameters": [ "ignored", "args", "keywds" ], "start_line": 3256, "end_line": 3291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_FromBuffer", "long_name": "PyArray_FromBuffer( PyObject * buf , PyArray_Typecode * type , intp count , int swapped)", "filename": "multiarraymodule.c", "nloc": 58, "complexity": 11, "token_count": 306, "parameters": [ "buf", "type", "count", "swapped" ], "start_line": 3294, "end_line": 3357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "array_frombuffer", "long_name": "array_frombuffer( PyObject * ignored , PyObject * args , PyObject * keywds)", "filename": "multiarraymodule.c", "nloc": 16, "complexity": 2, "token_count": 115, "parameters": [ "ignored", "args", "keywds" ], "start_line": 3362, "end_line": 3379, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_concatenate", "long_name": "array_concatenate( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3386, "end_line": 3397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "array_innerproduct", "long_name": "array_innerproduct( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "dummy", "args" ], "start_line": 3404, "end_line": 3410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_matrixproduct", "long_name": "array_matrixproduct( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "dummy", "args" ], "start_line": 3417, "end_line": 3423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_fastCopyAndTranspose", "long_name": "array_fastCopyAndTranspose( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 5, "complexity": 2, "token_count": 41, "parameters": [ "dummy", "args" ], "start_line": 3427, "end_line": 3433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_correlate", "long_name": "array_correlate( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 2, "token_count": 81, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3437, "end_line": 3446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "PyArray_Arange", "long_name": "PyArray_Arange( double start , double stop , double step , int type_num)", "filename": "multiarraymodule.c", "nloc": 29, "complexity": 4, "token_count": 229, "parameters": [ "start", "stop", "step", "type_num" ], "start_line": 3450, "end_line": 3483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_arange", "long_name": "array_arange( PyObject * ignored , PyObject * args , PyObject * kws)", "filename": "multiarraymodule.c", "nloc": 42, "complexity": 10, "token_count": 258, "parameters": [ "ignored", "args", "kws" ], "start_line": 3489, "end_line": 3537, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "array_set_string_function", "long_name": "array_set_string_function( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 78, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3557, "end_line": 3568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "array_set_ops_function", "long_name": "array_set_ops_function( PyObject * self , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 12, "complexity": 3, "token_count": 67, "parameters": [ "self", "args", "kwds" ], "start_line": 3574, "end_line": 3591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Where", "long_name": "PyArray_Where( PyObject * condition , PyObject * x , PyObject * y)", "filename": "multiarraymodule.c", "nloc": 29, "complexity": 8, "token_count": 226, "parameters": [ "condition", "x", "y" ], "start_line": 3595, "end_line": 3631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "array_where", "long_name": "array_where( PyObject * ignored , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "ignored", "args" ], "start_line": 3639, "end_line": 3647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_register_dtype", "long_name": "array_register_dtype( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 3, "token_count": 64, "parameters": [ "dummy", "args" ], "start_line": 3653, "end_line": 3664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "array_can_cast_safely", "long_name": "array_can_cast_safely( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 23, "complexity": 5, "token_count": 145, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3671, "end_line": 3695, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "setup_scalartypes", "long_name": "setup_scalartypes( PyObject * dict)", "filename": "multiarraymodule.c", "nloc": 44, "complexity": 9, "token_count": 342, "parameters": [ "dict" ], "start_line": 3756, "end_line": 3861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "set_flaginfo", "long_name": "set_flaginfo( PyObject * d)", "filename": "multiarraymodule.c", "nloc": 23, "complexity": 1, "token_count": 171, "parameters": [ "d" ], "start_line": 3866, "end_line": 3892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "initmultiarray", "long_name": "initmultiarray()", "filename": "multiarraymodule.c", "nloc": 52, "complexity": 12, "token_count": 361, "parameters": [], "start_line": 3897, "end_line": 3973, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyArray_MultiplyList", "long_name": "PyArray_MultiplyList( intp * l1 , int n)", "filename": "multiarraymodule.c", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "l1", "n" ], "start_line": 51, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_AxisConverter", "long_name": "PyArray_AxisConverter( PyObject * obj , int * axis)", "filename": "multiarraymodule.c", "nloc": 13, "complexity": 3, "token_count": 53, "parameters": [ "obj", "axis" ], "start_line": 61, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_CompareLists", "long_name": "PyArray_CompareLists( intp * l1 , intp * l2 , int n)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 3, "token_count": 51, "parameters": [ "l1", "l2", "n" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_View", "long_name": "PyArray_View( PyArrayObject * self , PyArray_Typecode * type)", "filename": "multiarraymodule.c", "nloc": 42, "complexity": 9, "token_count": 241, "parameters": [ "self", "type" ], "start_line": 86, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "PyArray_Ravel", "long_name": "PyArray_Ravel( PyArrayObject * a , int fortran)", "filename": "multiarraymodule.c", "nloc": 14, "complexity": 4, "token_count": 87, "parameters": [ "a", "fortran" ], "start_line": 137, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "PyArray_Flatten", "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", "filename": "multiarraymodule.c", "nloc": 32, "complexity": 5, "token_count": 158, "parameters": [ "a", "fortran" ], "start_line": 154, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_Reshape", "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self", "shape" ], "start_line": 195, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "PyArray_Newshape", "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", "filename": "multiarraymodule.c", "nloc": 68, "complexity": 15, "token_count": 362, "parameters": [ "self", "newdims" ], "start_line": 212, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 0 }, { "name": "PyArray_Squeeze", "long_name": "PyArray_Squeeze( PyArrayObject * self)", "filename": "multiarraymodule.c", "nloc": 30, "complexity": 4, "token_count": 188, "parameters": [ "self" ], "start_line": 299, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyArray_Mean", "long_name": "PyArray_Mean( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 19, "complexity": 4, "token_count": 139, "parameters": [ "self", "axis", "rtype" ], "start_line": 334, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_Std", "long_name": "PyArray_Std( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 43, "complexity": 12, "token_count": 433, "parameters": [ "self", "axis", "rtype" ], "start_line": 358, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "PyArray_Sum", "long_name": "PyArray_Sum( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 417, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Prod", "long_name": "PyArray_Prod( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 430, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_CumSum", "long_name": "PyArray_CumSum( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 443, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_CumProd", "long_name": "PyArray_CumProd( PyArrayObject * self , int axis , int rtype)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 69, "parameters": [ "self", "axis", "rtype" ], "start_line": 456, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Any", "long_name": "PyArray_Any( PyArrayObject * self , int axis)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 66, "parameters": [ "self", "axis" ], "start_line": 470, "end_line": 481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_All", "long_name": "PyArray_All( PyArrayObject * self , int axis)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 66, "parameters": [ "self", "axis" ], "start_line": 484, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Compress", "long_name": "PyArray_Compress( PyArrayObject * self , PyObject * condition , int axis)", "filename": "multiarraymodule.c", "nloc": 18, "complexity": 3, "token_count": 110, "parameters": [ "self", "condition", "axis" ], "start_line": 499, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyArray_Nonzero", "long_name": "PyArray_Nonzero( PyArrayObject * self)", "filename": "multiarraymodule.c", "nloc": 50, "complexity": 13, "token_count": 395, "parameters": [ "self" ], "start_line": 522, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "PyArray_Clip", "long_name": "PyArray_Clip( PyArrayObject * self , PyObject * min , PyObject * max)", "filename": "multiarraymodule.c", "nloc": 30, "complexity": 6, "token_count": 241, "parameters": [ "self", "min", "max" ], "start_line": 583, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_Conjugate", "long_name": "PyArray_Conjugate( PyArrayObject * self)", "filename": "multiarraymodule.c", "nloc": 36, "complexity": 9, "token_count": 225, "parameters": [ "self" ], "start_line": 619, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_Trace", "long_name": "PyArray_Trace( PyArrayObject * self , int offset , int axis1 , int axis2 , int rtype)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 81, "parameters": [ "self", "offset", "axis1", "axis2", "rtype" ], "start_line": 658, "end_line": 668, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Diagonal", "long_name": "PyArray_Diagonal( PyArrayObject * self , int offset , int axis1 , int axis2)", "filename": "multiarraymodule.c", "nloc": 104, "complexity": 24, "token_count": 798, "parameters": [ "self", "offset", "axis1", "axis2" ], "start_line": 671, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 0 }, { "name": "PyArray_AsCArray", "long_name": "PyArray_AsCArray( PyObject ** op , * ptr , intp * dims , int nd , int type_num)", "filename": "multiarraymodule.c", "nloc": 54, "complexity": 13, "token_count": 426, "parameters": [ "op", "ptr", "dims", "nd", "type_num" ], "start_line": 806, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "PyArray_As1D", "long_name": "PyArray_As1D( PyObject ** op , char ** ptr , int * d1 , int typecode)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 2, "token_count": 60, "parameters": [ "op", "ptr", "d1", "typecode" ], "start_line": 866, "end_line": 874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_As2D", "long_name": "PyArray_As2D( PyObject ** op , char ** * ptr , int * d1 , int * d2 , int typecode)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 2, "token_count": 81, "parameters": [ "op", "ptr", "d1", "d2", "typecode" ], "start_line": 878, "end_line": 888, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Free", "long_name": "PyArray_Free( PyObject * op , * ptr)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 4, "token_count": 67, "parameters": [ "op", "ptr" ], "start_line": 893, "end_line": 904, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "_swap_and_concat", "long_name": "_swap_and_concat( PyObject * op , int axis , int n)", "filename": "multiarraymodule.c", "nloc": 27, "complexity": 6, "token_count": 185, "parameters": [ "op", "axis", "n" ], "start_line": 908, "end_line": 936, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_Concatenate", "long_name": "PyArray_Concatenate( PyObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 112, "complexity": 24, "token_count": 761, "parameters": [ "op", "axis" ], "start_line": 945, "end_line": 1071, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 127, "top_nesting_level": 0 }, { "name": "PyArray_SwapAxes", "long_name": "PyArray_SwapAxes( PyArrayObject * ap , int a1 , int a2)", "filename": "multiarraymodule.c", "nloc": 37, "complexity": 12, "token_count": 227, "parameters": [ "ap", "a1", "a2" ], "start_line": 1074, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_Transpose", "long_name": "PyArray_Transpose( PyArrayObject * ap , PyObject * op)", "filename": "multiarraymodule.c", "nloc": 49, "complexity": 15, "token_count": 399, "parameters": [ "ap", "op" ], "start_line": 1117, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "PyArray_Repeat", "long_name": "PyArray_Repeat( PyArrayObject * aop , PyObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 75, "complexity": 15, "token_count": 516, "parameters": [ "aop", "op", "axis" ], "start_line": 1179, "end_line": 1271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 93, "top_nesting_level": 0 }, { "name": "PyArray_Choose", "long_name": "PyArray_Choose( PyArrayObject * ip , PyObject * op)", "filename": "multiarraymodule.c", "nloc": 89, "complexity": 18, "token_count": 646, "parameters": [ "ip", "op" ], "start_line": 1275, "end_line": 1387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 113, "top_nesting_level": 0 }, { "name": "qsortCompare", "long_name": "qsortCompare( const * a , const * b)", "filename": "multiarraymodule.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "a", "b" ], "start_line": 1395, "end_line": 1398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PyArray_Sort", "long_name": "PyArray_Sort( PyArrayObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 36, "complexity": 7, "token_count": 250, "parameters": [ "op", "axis" ], "start_line": 1420, "end_line": 1469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "argsort_static_compare", "long_name": "argsort_static_compare( const * ip1 , const * ip2)", "filename": "multiarraymodule.c", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "ip1", "ip2" ], "start_line": 1475, "end_line": 1483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_ArgSort", "long_name": "PyArray_ArgSort( PyArrayObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 48, "complexity": 8, "token_count": 346, "parameters": [ "op", "axis" ], "start_line": 1486, "end_line": 1545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "local_where", "long_name": "local_where( PyArrayObject * ap1 , PyArrayObject * ap2 , PyArrayObject * ret)", "filename": "multiarraymodule.c", "nloc": 35, "complexity": 7, "token_count": 243, "parameters": [ "ap1", "ap2", "ret" ], "start_line": 1548, "end_line": 1583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_SearchSorted", "long_name": "PyArray_SearchSorted( PyArrayObject * op1 , PyObject * op2)", "filename": "multiarraymodule.c", "nloc": 33, "complexity": 5, "token_count": 219, "parameters": [ "op1", "op2" ], "start_line": 1586, "end_line": 1631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "PyArray_InnerProduct", "long_name": "PyArray_InnerProduct( PyObject * op1 , PyObject * op2)", "filename": "multiarraymodule.c", "nloc": 82, "complexity": 17, "token_count": 653, "parameters": [ "op1", "op2" ], "start_line": 1639, "end_line": 1741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 103, "top_nesting_level": 0 }, { "name": "PyArray_MatrixProduct", "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", "filename": "multiarraymodule.c", "nloc": 98, "complexity": 20, "token_count": 756, "parameters": [ "op1", "op2" ], "start_line": 1746, "end_line": 1867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 }, { "name": "PyArray_CopyAndTranspose", "long_name": "PyArray_CopyAndTranspose( PyObject * op)", "filename": "multiarraymodule.c", "nloc": 44, "complexity": 6, "token_count": 282, "parameters": [ "op" ], "start_line": 1870, "end_line": 1921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "PyArray_Correlate", "long_name": "PyArray_Correlate( PyObject * op1 , PyObject * op2 , int mode)", "filename": "multiarraymodule.c", "nloc": 86, "complexity": 13, "token_count": 598, "parameters": [ "op1", "op2", "mode" ], "start_line": 1924, "end_line": 2019, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "PyArray_ArgMin", "long_name": "PyArray_ArgMin( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 21, "complexity": 5, "token_count": 138, "parameters": [ "ap", "axis" ], "start_line": 2022, "end_line": 2047, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "PyArray_Max", "long_name": "PyArray_Max( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [ "ap", "axis" ], "start_line": 2050, "end_line": 2061, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Min", "long_name": "PyArray_Min( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [ "ap", "axis" ], "start_line": 2064, "end_line": 2075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_Ptp", "long_name": "PyArray_Ptp( PyArrayObject * ap , int axis)", "filename": "multiarraymodule.c", "nloc": 22, "complexity": 4, "token_count": 138, "parameters": [ "ap", "axis" ], "start_line": 2078, "end_line": 2101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "PyArray_ArgMax", "long_name": "PyArray_ArgMax( PyArrayObject * op , int axis)", "filename": "multiarraymodule.c", "nloc": 46, "complexity": 7, "token_count": 318, "parameters": [ "op", "axis" ], "start_line": 2105, "end_line": 2161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 0 }, { "name": "PyArray_Take", "long_name": "PyArray_Take( PyArrayObject * self0 , PyObject * indices0 , int axis)", "filename": "multiarraymodule.c", "nloc": 61, "complexity": 12, "token_count": 464, "parameters": [ "self0", "indices0", "axis" ], "start_line": 2165, "end_line": 2236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_Put", "long_name": "PyArray_Put( PyArrayObject * self , PyObject * indices0 , PyObject * values0)", "filename": "multiarraymodule.c", "nloc": 46, "complexity": 10, "token_count": 318, "parameters": [ "self", "indices0", "values0" ], "start_line": 2239, "end_line": 2290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "PyArray_PutMask", "long_name": "PyArray_PutMask( PyArrayObject * self , PyObject * mask0 , PyObject * values0)", "filename": "multiarraymodule.c", "nloc": 56, "complexity": 10, "token_count": 334, "parameters": [ "self", "mask0", "values0" ], "start_line": 2293, "end_line": 2355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_Converter", "long_name": "PyArray_Converter( PyObject * object , PyObject ** address)", "filename": "multiarraymodule.c", "nloc": 13, "complexity": 3, "token_count": 66, "parameters": [ "object", "address" ], "start_line": 2367, "end_line": 2379, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_BoolConverter", "long_name": "PyArray_BoolConverter( PyObject * object , Bool * val)", "filename": "multiarraymodule.c", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "object", "val" ], "start_line": 2382, "end_line": 2388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_TypestrConvert", "long_name": "PyArray_TypestrConvert( int itemsize , int gentype)", "filename": "multiarraymodule.c", "nloc": 90, "complexity": 33, "token_count": 284, "parameters": [ "itemsize", "gentype" ], "start_line": 2392, "end_line": 2501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 110, "top_nesting_level": 0 }, { "name": "PyArray_BufferConverter", "long_name": "PyArray_BufferConverter( PyObject * obj , PyArray_Chunk * buf)", "filename": "multiarraymodule.c", "nloc": 20, "complexity": 6, "token_count": 147, "parameters": [ "obj", "buf" ], "start_line": 2516, "end_line": 2541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "PyArray_IntpConverter", "long_name": "PyArray_IntpConverter( PyObject * obj , PyArray_Dims * seq)", "filename": "multiarraymodule.c", "nloc": 35, "complexity": 10, "token_count": 186, "parameters": [ "obj", "seq" ], "start_line": 2553, "end_line": 2589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_TypecodeConverter", "long_name": "PyArray_TypecodeConverter( PyObject * obj , PyArray_Typecode * at)", "filename": "multiarraymodule.c", "nloc": 108, "complexity": 33, "token_count": 639, "parameters": [ "obj", "at" ], "start_line": 2598, "end_line": 2736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "PyArray_EquivalentTypes", "long_name": "PyArray_EquivalentTypes( PyArray_Typecode * typ1 , PyArray_Typecode * typ2)", "filename": "multiarraymodule.c", "nloc": 24, "complexity": 8, "token_count": 162, "parameters": [ "typ1", "typ2" ], "start_line": 2744, "end_line": 2771, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyArray_EquivArrTypes", "long_name": "PyArray_EquivArrTypes( PyArrayObject * a1 , PyArrayObject * a2)", "filename": "multiarraymodule.c", "nloc": 6, "complexity": 1, "token_count": 56, "parameters": [ "a1", "a2" ], "start_line": 2774, "end_line": 2780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_array_fromobject", "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", "filename": "multiarraymodule.c", "nloc": 38, "complexity": 9, "token_count": 254, "parameters": [ "ignored", "args", "kws" ], "start_line": 2791, "end_line": 2835, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_Empty", "long_name": "PyArray_Empty( int nd , intp * dims , PyArray_Typecode * type)", "filename": "multiarraymodule.c", "nloc": 15, "complexity": 3, "token_count": 99, "parameters": [ "nd", "dims", "type" ], "start_line": 2838, "end_line": 2854, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "array_empty", "long_name": "array_empty( PyObject * ignored , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 21, "complexity": 3, "token_count": 134, "parameters": [ "ignored", "args", "kwds" ], "start_line": 2860, "end_line": 2884, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_scalar", "long_name": "array_scalar( PyObject * ignored , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 56, "complexity": 11, "token_count": 290, "parameters": [ "ignored", "args", "kwds" ], "start_line": 2889, "end_line": 2953, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 }, { "name": "PyArray_Zeros", "long_name": "PyArray_Zeros( int nd , intp * dims , PyArray_Typecode * type)", "filename": "multiarraymodule.c", "nloc": 20, "complexity": 3, "token_count": 133, "parameters": [ "nd", "dims", "type" ], "start_line": 2957, "end_line": 2979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_zeros", "long_name": "array_zeros( PyObject * ignored , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 22, "complexity": 3, "token_count": 134, "parameters": [ "ignored", "args", "kwds" ], "start_line": 2985, "end_line": 3009, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_set_typeDict", "long_name": "array_set_typeDict( PyObject * ignored , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "ignored", "args" ], "start_line": 3016, "end_line": 3025, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_fromString", "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", "filename": "multiarraymodule.c", "nloc": 50, "complexity": 8, "token_count": 283, "parameters": [ "ignored", "args", "keywds" ], "start_line": 3030, "end_line": 3085, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "_fill_in_itemsize", "long_name": "_fill_in_itemsize( PyArray_Typecode * typecode)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 2, "token_count": 42, "parameters": [ "typecode" ], "start_line": 3101, "end_line": 3108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_FromFile", "long_name": "PyArray_FromFile( FILE * fp , PyArray_Typecode * typecode , intp num , char * sep)", "filename": "multiarraymodule.c", "nloc": 130, "complexity": 26, "token_count": 764, "parameters": [ "fp", "typecode", "num", "sep" ], "start_line": 3112, "end_line": 3252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 141, "top_nesting_level": 0 }, { "name": "array_fromfile", "long_name": "array_fromfile( PyObject * ignored , PyObject * args , PyObject * keywds)", "filename": "multiarraymodule.c", "nloc": 34, "complexity": 6, "token_count": 221, "parameters": [ "ignored", "args", "keywds" ], "start_line": 3255, "end_line": 3290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_FromBuffer", "long_name": "PyArray_FromBuffer( PyObject * buf , PyArray_Typecode * type , intp count , int swapped)", "filename": "multiarraymodule.c", "nloc": 58, "complexity": 11, "token_count": 306, "parameters": [ "buf", "type", "count", "swapped" ], "start_line": 3293, "end_line": 3356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "array_frombuffer", "long_name": "array_frombuffer( PyObject * ignored , PyObject * args , PyObject * keywds)", "filename": "multiarraymodule.c", "nloc": 16, "complexity": 2, "token_count": 115, "parameters": [ "ignored", "args", "keywds" ], "start_line": 3361, "end_line": 3378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_concatenate", "long_name": "array_concatenate( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3385, "end_line": 3396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "array_innerproduct", "long_name": "array_innerproduct( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "dummy", "args" ], "start_line": 3403, "end_line": 3409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_matrixproduct", "long_name": "array_matrixproduct( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "dummy", "args" ], "start_line": 3416, "end_line": 3422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_fastCopyAndTranspose", "long_name": "array_fastCopyAndTranspose( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 5, "complexity": 2, "token_count": 41, "parameters": [ "dummy", "args" ], "start_line": 3426, "end_line": 3432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_correlate", "long_name": "array_correlate( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 8, "complexity": 2, "token_count": 81, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3436, "end_line": 3445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "PyArray_Arange", "long_name": "PyArray_Arange( double start , double stop , double step , int type_num)", "filename": "multiarraymodule.c", "nloc": 29, "complexity": 4, "token_count": 229, "parameters": [ "start", "stop", "step", "type_num" ], "start_line": 3449, "end_line": 3482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_arange", "long_name": "array_arange( PyObject * ignored , PyObject * args , PyObject * kws)", "filename": "multiarraymodule.c", "nloc": 42, "complexity": 10, "token_count": 258, "parameters": [ "ignored", "args", "kws" ], "start_line": 3488, "end_line": 3536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "array_set_string_function", "long_name": "array_set_string_function( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 11, "complexity": 2, "token_count": 78, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3556, "end_line": 3567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "array_set_ops_function", "long_name": "array_set_ops_function( PyObject * self , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 12, "complexity": 3, "token_count": 67, "parameters": [ "self", "args", "kwds" ], "start_line": 3573, "end_line": 3590, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Where", "long_name": "PyArray_Where( PyObject * condition , PyObject * x , PyObject * y)", "filename": "multiarraymodule.c", "nloc": 29, "complexity": 8, "token_count": 226, "parameters": [ "condition", "x", "y" ], "start_line": 3594, "end_line": 3630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "array_where", "long_name": "array_where( PyObject * ignored , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "ignored", "args" ], "start_line": 3638, "end_line": 3646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_register_dtype", "long_name": "array_register_dtype( PyObject * dummy , PyObject * args)", "filename": "multiarraymodule.c", "nloc": 10, "complexity": 3, "token_count": 64, "parameters": [ "dummy", "args" ], "start_line": 3652, "end_line": 3663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "array_can_cast_safely", "long_name": "array_can_cast_safely( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "multiarraymodule.c", "nloc": 23, "complexity": 5, "token_count": 145, "parameters": [ "dummy", "args", "kwds" ], "start_line": 3670, "end_line": 3694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "setup_scalartypes", "long_name": "setup_scalartypes( PyObject * dict)", "filename": "multiarraymodule.c", "nloc": 44, "complexity": 9, "token_count": 342, "parameters": [ "dict" ], "start_line": 3755, "end_line": 3860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "set_flaginfo", "long_name": "set_flaginfo( PyObject * d)", "filename": "multiarraymodule.c", "nloc": 23, "complexity": 1, "token_count": 171, "parameters": [ "d" ], "start_line": 3865, "end_line": 3891, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "initmultiarray", "long_name": "initmultiarray()", "filename": "multiarraymodule.c", "nloc": 52, "complexity": 12, "token_count": 361, "parameters": [], "start_line": 3896, "end_line": 3972, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "PyArray_Put", "long_name": "PyArray_Put( PyArrayObject * self , PyObject * indices0 , PyObject * values0)", "filename": "multiarraymodule.c", "nloc": 47, "complexity": 10, "token_count": 319, "parameters": [ "self", "indices0", "values0" ], "start_line": 2239, "end_line": 2291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 } ], "nloc": 3075, "complexity": 635, "token_count": 20164, "diff_parsed": { "added": [ " values = (PyArrayObject *)\\", "\t\tPyArray_ContiguousFromObject(values0, self->descr->type_num,", "\t\t\t\t\t 0, 0);", " tmp = ((intp *)(indices->data))[i];" ], "deleted": [ " values = (PyArrayObject *)PyArray_ContiguousFromObject(values0,", " self->descr->type, 0, 0);", " tmp = ((long *)(indices->data))[i];" ] } }, { "old_path": "scipy/base/src/ufuncobject.c", "new_path": "scipy/base/src/ufuncobject.c", "filename": "ufuncobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -1230,7 +1230,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t/* Everything is notswapped, aligned and of the \n \t\t right type but not contiguous. -- Almost as fast.\n \t\t*/\n- fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);\n+ /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n \t\twhile (loop->index < loop->size) {\n \t\t\tfor (i=0; inargs; i++) \n \t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n@@ -1282,7 +1282,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n \t\t */ \n-\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n+\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/\n \t\twhile (index < size) {\n \t\t\t/*copy input data */\n \t\t\tfor (i=0; inin; i++) {\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\t\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ibufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n loop->iters[i] = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t\tcntcast = descr->elsize;\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\tcntcast += mps[i]->itemsize;\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't use factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D) \n\t\t\t so don't worry about resetting it) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n#define _PyD PyArray_DescrFromType\n\t\t\t\t\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations: \n\t\t 1) move data better into and out of the buffers \n\t\t --- not one at a time. \n\t\t 2) don't call copyswap unless needed -- and\n\t\t call it on the data in the buffer using\n\t\t copyswapn.\n\t\t */\n\n\t\tPyArray_CopySwapFunc *copyswap[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswap[i] = mps[i]->descr->copyswap;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t */ \n\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tcopyswap[i](dptr[i],\n\t\t\t\t\t iters[i]->dataptr,\n\t\t\t\t\t swap[i],\n\t\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\n\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) \n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n \n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\tcopyswap[i](iters[i]->dataptr,\n\t\t\t\t\t\t\t dptr[i],\n\t\t\t\t\t\t\t swap[i],\n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = loop->buffer[i];\n\t\t\t\t\n\t\t\t} \n\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t}\n\t}\n\t}\t\n\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[self->nin+i]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[self->nin+i]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[self->nin+i]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\t\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ibufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n loop->iters[i] = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t\tcntcast = descr->elsize;\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\tcntcast += mps[i]->itemsize;\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't use factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D) \n\t\t\t so don't worry about resetting it) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n#define _PyD PyArray_DescrFromType\n\t\t\t\t\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations: \n\t\t 1) move data better into and out of the buffers \n\t\t --- not one at a time. \n\t\t 2) don't call copyswap unless needed -- and\n\t\t call it on the data in the buffer using\n\t\t copyswapn.\n\t\t */\n\n\t\tPyArray_CopySwapFunc *copyswap[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswap[i] = mps[i]->descr->copyswap;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t */ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tcopyswap[i](dptr[i],\n\t\t\t\t\t iters[i]->dataptr,\n\t\t\t\t\t swap[i],\n\t\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\n\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) \n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n \n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\tcopyswap[i](iters[i]->dataptr,\n\t\t\t\t\t\t\t dptr[i],\n\t\t\t\t\t\t\t swap[i],\n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = loop->buffer[i];\n\t\t\t\t\n\t\t\t} \n\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t}\n\t}\n\t}\t\n\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[self->nin+i]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[self->nin+i]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[self->nin+i]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "methods": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 177, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 783, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 213, "complexity": 51, "token_count": 1646, "parameters": [ "loop", "args", "mps" ], "start_line": 786, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 297, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1089, "end_line": 1138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 100, "complexity": 20, "token_count": 699, "parameters": [ "self", "args", "mps" ], "start_line": 1206, "end_line": 1355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 150, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1358, "end_line": 1378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1381, "end_line": 1403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1412, "end_line": 1641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1653, "end_line": 1782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1786, "end_line": 1916, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 1938, "end_line": 2065, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2074, "end_line": 2184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2191, "end_line": 2243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 39, "complexity": 11, "token_count": 311, "parameters": [ "self", "args" ], "start_line": 2246, "end_line": 2300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2308, "end_line": 2377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2381, "end_line": 2412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2415, "end_line": 2456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2459, "end_line": 2471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2474, "end_line": 2486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2490, "end_line": 2496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2499, "end_line": 2506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2518, "end_line": 2587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2591, "end_line": 2595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2598, "end_line": 2602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2605, "end_line": 2608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2628, "end_line": 2650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2655, "end_line": 2738, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2743, "end_line": 2746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 177, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 783, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 213, "complexity": 51, "token_count": 1646, "parameters": [ "loop", "args", "mps" ], "start_line": 786, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 297, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1089, "end_line": 1138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 102, "complexity": 20, "token_count": 721, "parameters": [ "self", "args", "mps" ], "start_line": 1206, "end_line": 1355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 150, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1358, "end_line": 1378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1381, "end_line": 1403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1412, "end_line": 1641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1653, "end_line": 1782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1786, "end_line": 1916, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 1938, "end_line": 2065, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2074, "end_line": 2184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2191, "end_line": 2243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 39, "complexity": 11, "token_count": 311, "parameters": [ "self", "args" ], "start_line": 2246, "end_line": 2300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2308, "end_line": 2377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2381, "end_line": 2412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2415, "end_line": 2456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2459, "end_line": 2471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2474, "end_line": 2486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2490, "end_line": 2496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2499, "end_line": 2506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2518, "end_line": 2587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2591, "end_line": 2595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2598, "end_line": 2602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2605, "end_line": 2608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2628, "end_line": 2650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2655, "end_line": 2738, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2743, "end_line": 2746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 100, "complexity": 20, "token_count": 699, "parameters": [ "self", "args", "mps" ], "start_line": 1206, "end_line": 1355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 150, "top_nesting_level": 0 } ], "nloc": 2059, "complexity": 421, "token_count": 15055, "diff_parsed": { "added": [ " /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/", "\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/" ], "deleted": [ " fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);", "\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);" ] } } ] }, { "hash": "2d40d9e98c57824edd7f9130d9036fb9115bc70d", "msg": "Moved inclusion of files from MANIFEST.in to proper setup.py files.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2005-10-05T07:28:03+00:00", "author_timezone": 0, "committer_date": "2005-10-05T07:28:03+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "77ec6f047995d7a473523feb4fc2a93b537d51c3" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 7, "insertions": 13, "lines": 20, "files": 4, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "MANIFEST.in", "new_path": "MANIFEST.in", "filename": "MANIFEST.in", "extension": "in", "change_type": "MODIFY", "diff": "@@ -8,7 +8,7 @@ include MANIFEST.in\n #recursive-include scipy/f2py2e/tests/mixed *.f *.f90\n ##recursive-include scipy/f2py2e/doc *.py *.txt *.tex *.html Makefile\n #recursive-include scipy/f2py2e/docs *.txt *.html *.dat *.f *.f90 *.pyf setup_example.py f2py_style.css\n-include scipy/corelib/blasdot/cblas.h\n-recursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi\n-prune scipy/base/include/scipy\n-recursive-include scipy/base/include/scipy *object.h\n+#include scipy/corelib/blasdot/cblas.h\n+#recursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi\n+#prune scipy/base/include/scipy\n+#recursive-include scipy/base/include/scipy *object.h\n", "added_lines": 4, "deleted_lines": 4, "source_code": "recursive-include . *.txt\ninclude MANIFEST.in\n#include scipy/f2py2e/f2py.1\n#recursive-include scipy/f2py2e *.cfg\n#recursive-include scipy/f2py2e *.py\n#recursive-include scipy/f2py2e/src fortranobject.c fortranobject.h\n#recursive-include scipy/f2py2e/tests *.py\n#recursive-include scipy/f2py2e/tests/mixed *.f *.f90\n##recursive-include scipy/f2py2e/doc *.py *.txt *.tex *.html Makefile\n#recursive-include scipy/f2py2e/docs *.txt *.html *.dat *.f *.f90 *.pyf setup_example.py f2py_style.css\n#include scipy/corelib/blasdot/cblas.h\n#recursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi\n#prune scipy/base/include/scipy\n#recursive-include scipy/base/include/scipy *object.h\n", "source_code_before": "recursive-include . *.txt\ninclude MANIFEST.in\n#include scipy/f2py2e/f2py.1\n#recursive-include scipy/f2py2e *.cfg\n#recursive-include scipy/f2py2e *.py\n#recursive-include scipy/f2py2e/src fortranobject.c fortranobject.h\n#recursive-include scipy/f2py2e/tests *.py\n#recursive-include scipy/f2py2e/tests/mixed *.f *.f90\n##recursive-include scipy/f2py2e/doc *.py *.txt *.tex *.html Makefile\n#recursive-include scipy/f2py2e/docs *.txt *.html *.dat *.f *.f90 *.pyf setup_example.py f2py_style.css\ninclude scipy/corelib/blasdot/cblas.h\nrecursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi\nprune scipy/base/include/scipy\nrecursive-include scipy/base/include/scipy *object.h\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "#include scipy/corelib/blasdot/cblas.h", "#recursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi", "#prune scipy/base/include/scipy", "#recursive-include scipy/base/include/scipy *object.h" ], "deleted": [ "include scipy/corelib/blasdot/cblas.h", "recursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi", "prune scipy/base/include/scipy", "recursive-include scipy/base/include/scipy *object.h" ] } }, { "old_path": "scipy/base/setup.py", "new_path": "scipy/base/setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -138,6 +138,7 @@ def generate_umath_c(ext,build_dir):\n join('src','arraymethods.c'),\n join('src','scalartypes.inc.src'),\n join('src','arraytypes.inc.src'),\n+ join('include','scipy','*object.h')\n ]\n \n config.add_extension('multiarray',\n", "added_lines": 1, "deleted_lines": 0, "source_code": "\nimport imp\nimport os\nfrom os.path import join\nfrom glob import glob\nfrom scipy.distutils.misc_util import Configuration,dot_join\nfrom distutils.dep_util import newer,newer_group\n\nfrom scipy.distutils.command.build import build\n\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('base',parent_package,top_path)\n local_dir = config.local_path\n codegen_dir = join(local_dir,'code_generators')\n\n generate_umath_py = join(codegen_dir,'generate_umath.py')\n n = dot_join(config.name,'generate_umath')\n generate_umath = imp.load_module('_'.join(n.split('.')),\n open(generate_umath_py,'U'),generate_umath_py,\n ('.py','U',1))\n\n header_dir = join(*(config.name.split('.')+['include','scipy']))\n\n def generate_config_h(ext, build_dir):\n target = join(build_dir,'config.h')\n if newer(__file__,target):\n config_cmd = config.get_config_cmd()\n print 'Generating',target\n #\n tc = generate_testcode(target)\n from distutils import sysconfig\n python_include = sysconfig.get_python_inc()\n result = config_cmd.try_run(tc,include_dirs=[python_include])\n if not result:\n raise \"ERROR: Failed to test configuration\" \n moredefs = []\n\n #\n mathlibs = []\n tc = testcode_mathlib()\n mathlibs_choices = [[],['m'],['cpml']]\n mathlib = os.environ.get('MATHLIB')\n if mathlib:\n mathlibs_choices.insert(0,mathlib.split(','))\n for libs in mathlibs_choices:\n if config_cmd.try_run(tc,libraries=libs):\n mathlibs = libs\n break\n else:\n raise \"math library missing; rerun setup.py after setting the MATHLIB env variable\"\n ext.libraries.extend(mathlibs)\n moredefs.append(('MATHLIB',','.join(mathlibs)))\n\n libs = mathlibs\n kws_args = {'libraries':libs,'decl':0,'headers':['math.h']}\n if config_cmd.check_func('expl', **kws_args):\n moredefs.append('HAVE_LONGDOUBLE_FUNCS')\n if config_cmd.check_func('expf', **kws_args):\n moredefs.append('HAVE_FLOAT_FUNCS')\n if config_cmd.check_func('asinh', **kws_args):\n moredefs.append('HAVE_INVERSE_HYPERBOLIC')\n if config_cmd.check_func('atanhf', **kws_args):\n moredefs.append('HAVE_INVERSE_HYPERBOLIC_FLOAT')\n if config_cmd.check_func('isnan', **kws_args):\n moredefs.append('HAVE_ISNAN')\n\n if moredefs:\n target_f = open(target,'a')\n for d in moredefs:\n if isinstance(d,str):\n target_f.write('#define %s\\n' % (d))\n else:\n target_f.write('#define %s %s\\n' % (d[0],d[1]))\n target_f.close()\n else:\n mathlibs = []\n target_f = open(target)\n for line in target_f.readlines():\n s = '#define MATHLIB'\n if line.startswith(s):\n value = line[len(s):].strip()\n if value:\n mathlibs.extend(value.split(','))\n target_f.close()\n\n ext.libraries.extend(mathlibs)\n\n incl_dir = os.path.dirname(target)\n if incl_dir not in config.scipy_include_dirs:\n config.scipy_include_dirs.append(incl_dir)\n\n config.add_data_files((header_dir,target))\n return target\n\n def generate_array_api(ext,build_dir):\n target = join(build_dir,'__multiarray_api.h')\n script = join(codegen_dir,'generate_array_api.py')\n if newer(script,target):\n script = os.path.abspath(script)\n old_cwd = os.getcwd()\n os.chdir(build_dir)\n print 'executing',script\n execfile(script,{},{})\n os.chdir(old_cwd)\n config.add_data_files((header_dir,target))\n return target\n\n def generate_ufunc_api(ext,build_dir):\n target = join(build_dir,'__ufunc_api.h')\n script = join(codegen_dir,'generate_ufunc_api.py')\n if newer(script,target):\n script = os.path.abspath(script)\n old_cwd = os.getcwd()\n os.chdir(build_dir)\n print 'executing',script\n execfile(script,{},{})\n os.chdir(old_cwd)\n config.add_data_files((header_dir,target))\n return target\n\n def generate_umath_c(ext,build_dir):\n target = join(build_dir,'__umath_generated.c')\n script = generate_umath_py\n if newer(script,target):\n f = open(target,'w')\n f.write(generate_umath.make_code(generate_umath.defdict,\n generate_umath.__file__))\n f.close()\n return []\n\n config.add_data_files(join('include','scipy','*.h'))\n config.add_include_dirs('src')\n\n config.scipy_include_dirs.extend(config.paths('include'))\n\n deps = [join('src','arrayobject.c'),\n join('src','arraymethods.c'),\n join('src','scalartypes.inc.src'),\n join('src','arraytypes.inc.src'),\n join('include','scipy','*object.h')\n ]\n\n config.add_extension('multiarray',\n sources = [join('src','multiarraymodule.c'),\n generate_config_h,\n generate_array_api,\n join('src','scalartypes.inc.src'),\n join('src','arraytypes.inc.src'),\n join(codegen_dir,'generate_array_api.py'),\n join('*.py')\n ],\n depends = deps,\n )\n\n config.add_extension('umath',\n sources = [generate_config_h,\n join('src','umathmodule.c.src'),\n generate_umath_c,\n generate_ufunc_api,\n join('src','scalartypes.inc.src'),\n join('src','arraytypes.inc.src'),\n ],\n depends = [join('src','ufuncobject.c'),\n generate_umath_py,\n join(codegen_dir,'generate_ufunc_api.py')\n ]+deps,\n )\n\n config.add_extension('_compiled_base',\n sources=[join('src','_compiled_base.c'),\n generate_config_h,\n generate_array_api,\n ],\n )\n\n config.add_data_dir('tests')\n\n return config\n\ndef testcode_mathlib():\n return \"\"\"\\\n/* check whether libm is broken */\n#include \nint main(int argc, char *argv[])\n{\n return exp(-720.) > 1.0; /* typically an IEEE denormal */\n}\n\"\"\"\n\nimport sys\ndef generate_testcode(target):\n if sys.platform == 'win32':\n target = target.replace('\\\\','\\\\\\\\')\n testcode = [r'''\n#include \n#include \n#include \n\nint main(int argc, char **argv)\n{\n\n FILE *fp;\n\n fp = fopen(\"'''+target+'''\",\"w\");\n ''']\n\n c_size_test = r'''\n#ifndef %(sz)s\n fprintf(fp,\"#define %(sz)s %%d\\n\", sizeof(%(type)s));\n#else\n fprintf(fp,\"/* #define %(sz)s %%d */\\n\", %(sz)s);\n#endif\n'''\n for sz, t in [('SIZEOF_SHORT', 'short'),\n ('SIZEOF_INT', 'int'),\n ('SIZEOF_LONG', 'long'),\n ('SIZEOF_FLOAT', 'float'),\n ('SIZEOF_DOUBLE', 'double'),\n ('SIZEOF_LONG_DOUBLE', 'long double'),\n ('SIZEOF_PY_INTPTR_T', 'Py_intptr_t'),\n ]:\n testcode.append(c_size_test % {'sz' : sz, 'type' : t})\n\n testcode.append('#ifdef PY_LONG_LONG')\n testcode.append(c_size_test % {'sz' : 'SIZEOF_LONG_LONG',\n 'type' : 'PY_LONG_LONG'})\n testcode.append(c_size_test % {'sz' : 'SIZEOF_PY_LONG_LONG',\n 'type' : 'PY_LONG_LONG'})\n \n\n testcode.append(r'''\n#else\n fprintf(fp, \"/* PY_LONG_LONG not defined */\\n\");\n#endif\n#ifndef CHAR_BIT\n {\n unsigned char var = 2;\n int i=0;\n while (var >= 2) {\n var = var << 1;\n i++;\n }\n fprintf(fp,\"#define CHAR_BIT %d\\n\", i+1);\n }\n#else\n fprintf(fp, \"/* #define CHAR_BIT %d */\\n\", CHAR_BIT);\n#endif\n fclose(fp);\n return 0;\n}\n''')\n testcode = '\\n'.join(testcode) \n return testcode\n\nif __name__=='__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", "source_code_before": "\nimport imp\nimport os\nfrom os.path import join\nfrom glob import glob\nfrom scipy.distutils.misc_util import Configuration,dot_join\nfrom distutils.dep_util import newer,newer_group\n\nfrom scipy.distutils.command.build import build\n\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('base',parent_package,top_path)\n local_dir = config.local_path\n codegen_dir = join(local_dir,'code_generators')\n\n generate_umath_py = join(codegen_dir,'generate_umath.py')\n n = dot_join(config.name,'generate_umath')\n generate_umath = imp.load_module('_'.join(n.split('.')),\n open(generate_umath_py,'U'),generate_umath_py,\n ('.py','U',1))\n\n header_dir = join(*(config.name.split('.')+['include','scipy']))\n\n def generate_config_h(ext, build_dir):\n target = join(build_dir,'config.h')\n if newer(__file__,target):\n config_cmd = config.get_config_cmd()\n print 'Generating',target\n #\n tc = generate_testcode(target)\n from distutils import sysconfig\n python_include = sysconfig.get_python_inc()\n result = config_cmd.try_run(tc,include_dirs=[python_include])\n if not result:\n raise \"ERROR: Failed to test configuration\" \n moredefs = []\n\n #\n mathlibs = []\n tc = testcode_mathlib()\n mathlibs_choices = [[],['m'],['cpml']]\n mathlib = os.environ.get('MATHLIB')\n if mathlib:\n mathlibs_choices.insert(0,mathlib.split(','))\n for libs in mathlibs_choices:\n if config_cmd.try_run(tc,libraries=libs):\n mathlibs = libs\n break\n else:\n raise \"math library missing; rerun setup.py after setting the MATHLIB env variable\"\n ext.libraries.extend(mathlibs)\n moredefs.append(('MATHLIB',','.join(mathlibs)))\n\n libs = mathlibs\n kws_args = {'libraries':libs,'decl':0,'headers':['math.h']}\n if config_cmd.check_func('expl', **kws_args):\n moredefs.append('HAVE_LONGDOUBLE_FUNCS')\n if config_cmd.check_func('expf', **kws_args):\n moredefs.append('HAVE_FLOAT_FUNCS')\n if config_cmd.check_func('asinh', **kws_args):\n moredefs.append('HAVE_INVERSE_HYPERBOLIC')\n if config_cmd.check_func('atanhf', **kws_args):\n moredefs.append('HAVE_INVERSE_HYPERBOLIC_FLOAT')\n if config_cmd.check_func('isnan', **kws_args):\n moredefs.append('HAVE_ISNAN')\n\n if moredefs:\n target_f = open(target,'a')\n for d in moredefs:\n if isinstance(d,str):\n target_f.write('#define %s\\n' % (d))\n else:\n target_f.write('#define %s %s\\n' % (d[0],d[1]))\n target_f.close()\n else:\n mathlibs = []\n target_f = open(target)\n for line in target_f.readlines():\n s = '#define MATHLIB'\n if line.startswith(s):\n value = line[len(s):].strip()\n if value:\n mathlibs.extend(value.split(','))\n target_f.close()\n\n ext.libraries.extend(mathlibs)\n\n incl_dir = os.path.dirname(target)\n if incl_dir not in config.scipy_include_dirs:\n config.scipy_include_dirs.append(incl_dir)\n\n config.add_data_files((header_dir,target))\n return target\n\n def generate_array_api(ext,build_dir):\n target = join(build_dir,'__multiarray_api.h')\n script = join(codegen_dir,'generate_array_api.py')\n if newer(script,target):\n script = os.path.abspath(script)\n old_cwd = os.getcwd()\n os.chdir(build_dir)\n print 'executing',script\n execfile(script,{},{})\n os.chdir(old_cwd)\n config.add_data_files((header_dir,target))\n return target\n\n def generate_ufunc_api(ext,build_dir):\n target = join(build_dir,'__ufunc_api.h')\n script = join(codegen_dir,'generate_ufunc_api.py')\n if newer(script,target):\n script = os.path.abspath(script)\n old_cwd = os.getcwd()\n os.chdir(build_dir)\n print 'executing',script\n execfile(script,{},{})\n os.chdir(old_cwd)\n config.add_data_files((header_dir,target))\n return target\n\n def generate_umath_c(ext,build_dir):\n target = join(build_dir,'__umath_generated.c')\n script = generate_umath_py\n if newer(script,target):\n f = open(target,'w')\n f.write(generate_umath.make_code(generate_umath.defdict,\n generate_umath.__file__))\n f.close()\n return []\n\n config.add_data_files(join('include','scipy','*.h'))\n config.add_include_dirs('src')\n\n config.scipy_include_dirs.extend(config.paths('include'))\n\n deps = [join('src','arrayobject.c'),\n join('src','arraymethods.c'),\n join('src','scalartypes.inc.src'),\n join('src','arraytypes.inc.src'),\n ]\n\n config.add_extension('multiarray',\n sources = [join('src','multiarraymodule.c'),\n generate_config_h,\n generate_array_api,\n join('src','scalartypes.inc.src'),\n join('src','arraytypes.inc.src'),\n join(codegen_dir,'generate_array_api.py'),\n join('*.py')\n ],\n depends = deps,\n )\n\n config.add_extension('umath',\n sources = [generate_config_h,\n join('src','umathmodule.c.src'),\n generate_umath_c,\n generate_ufunc_api,\n join('src','scalartypes.inc.src'),\n join('src','arraytypes.inc.src'),\n ],\n depends = [join('src','ufuncobject.c'),\n generate_umath_py,\n join(codegen_dir,'generate_ufunc_api.py')\n ]+deps,\n )\n\n config.add_extension('_compiled_base',\n sources=[join('src','_compiled_base.c'),\n generate_config_h,\n generate_array_api,\n ],\n )\n\n config.add_data_dir('tests')\n\n return config\n\ndef testcode_mathlib():\n return \"\"\"\\\n/* check whether libm is broken */\n#include \nint main(int argc, char *argv[])\n{\n return exp(-720.) > 1.0; /* typically an IEEE denormal */\n}\n\"\"\"\n\nimport sys\ndef generate_testcode(target):\n if sys.platform == 'win32':\n target = target.replace('\\\\','\\\\\\\\')\n testcode = [r'''\n#include \n#include \n#include \n\nint main(int argc, char **argv)\n{\n\n FILE *fp;\n\n fp = fopen(\"'''+target+'''\",\"w\");\n ''']\n\n c_size_test = r'''\n#ifndef %(sz)s\n fprintf(fp,\"#define %(sz)s %%d\\n\", sizeof(%(type)s));\n#else\n fprintf(fp,\"/* #define %(sz)s %%d */\\n\", %(sz)s);\n#endif\n'''\n for sz, t in [('SIZEOF_SHORT', 'short'),\n ('SIZEOF_INT', 'int'),\n ('SIZEOF_LONG', 'long'),\n ('SIZEOF_FLOAT', 'float'),\n ('SIZEOF_DOUBLE', 'double'),\n ('SIZEOF_LONG_DOUBLE', 'long double'),\n ('SIZEOF_PY_INTPTR_T', 'Py_intptr_t'),\n ]:\n testcode.append(c_size_test % {'sz' : sz, 'type' : t})\n\n testcode.append('#ifdef PY_LONG_LONG')\n testcode.append(c_size_test % {'sz' : 'SIZEOF_LONG_LONG',\n 'type' : 'PY_LONG_LONG'})\n testcode.append(c_size_test % {'sz' : 'SIZEOF_PY_LONG_LONG',\n 'type' : 'PY_LONG_LONG'})\n \n\n testcode.append(r'''\n#else\n fprintf(fp, \"/* PY_LONG_LONG not defined */\\n\");\n#endif\n#ifndef CHAR_BIT\n {\n unsigned char var = 2;\n int i=0;\n while (var >= 2) {\n var = var << 1;\n i++;\n }\n fprintf(fp,\"#define CHAR_BIT %d\\n\", i+1);\n }\n#else\n fprintf(fp, \"/* #define CHAR_BIT %d */\\n\", CHAR_BIT);\n#endif\n fclose(fp);\n return 0;\n}\n''')\n testcode = '\\n'.join(testcode) \n return testcode\n\nif __name__=='__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", "methods": [ { "name": "configuration.generate_config_h", "long_name": "configuration.generate_config_h( ext , build_dir )", "filename": "setup.py", "nloc": 62, "complexity": 18, "token_count": 447, "parameters": [ "ext", "build_dir" ], "start_line": 25, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 1 }, { "name": "configuration.generate_array_api", "long_name": "configuration.generate_array_api( ext , build_dir )", "filename": "setup.py", "nloc": 12, "complexity": 2, "token_count": 86, "parameters": [ "ext", "build_dir" ], "start_line": 96, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "configuration.generate_ufunc_api", "long_name": "configuration.generate_ufunc_api( ext , build_dir )", "filename": "setup.py", "nloc": 12, "complexity": 2, "token_count": 86, "parameters": [ "ext", "build_dir" ], "start_line": 109, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "configuration.generate_umath_c", "long_name": "configuration.generate_umath_c( ext , build_dir )", "filename": "setup.py", "nloc": 9, "complexity": 2, "token_count": 59, "parameters": [ "ext", "build_dir" ], "start_line": 122, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 55, "complexity": 1, "token_count": 333, "parameters": [ "parent_package", "top_path" ], "start_line": 12, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 }, { "name": "testcode_mathlib", "long_name": "testcode_mathlib( )", "filename": "setup.py", "nloc": 9, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "generate_testcode", "long_name": "generate_testcode( target )", "filename": "setup.py", "nloc": 59, "complexity": 3, "token_count": 157, "parameters": [ "target" ], "start_line": 192, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration.generate_config_h", "long_name": "configuration.generate_config_h( ext , build_dir )", "filename": "setup.py", "nloc": 62, "complexity": 18, "token_count": 447, "parameters": [ "ext", "build_dir" ], "start_line": 25, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 1 }, { "name": "configuration.generate_array_api", "long_name": "configuration.generate_array_api( ext , build_dir )", "filename": "setup.py", "nloc": 12, "complexity": 2, "token_count": 86, "parameters": [ "ext", "build_dir" ], "start_line": 96, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "configuration.generate_ufunc_api", "long_name": "configuration.generate_ufunc_api( ext , build_dir )", "filename": "setup.py", "nloc": 12, "complexity": 2, "token_count": 86, "parameters": [ "ext", "build_dir" ], "start_line": 109, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "configuration.generate_umath_c", "long_name": "configuration.generate_umath_c( ext , build_dir )", "filename": "setup.py", "nloc": 9, "complexity": 2, "token_count": 59, "parameters": [ "ext", "build_dir" ], "start_line": 122, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 54, "complexity": 1, "token_count": 325, "parameters": [ "parent_package", "top_path" ], "start_line": 12, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 167, "top_nesting_level": 0 }, { "name": "testcode_mathlib", "long_name": "testcode_mathlib( )", "filename": "setup.py", "nloc": 9, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 180, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "generate_testcode", "long_name": "generate_testcode( target )", "filename": "setup.py", "nloc": 59, "complexity": 3, "token_count": 157, "parameters": [ "target" ], "start_line": 191, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 55, "complexity": 1, "token_count": 333, "parameters": [ "parent_package", "top_path" ], "start_line": 12, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 } ], "nloc": 225, "complexity": 29, "token_count": 1244, "diff_parsed": { "added": [ " join('include','scipy','*object.h')" ], "deleted": [] } }, { "old_path": "scipy/corelib/setup.py", "new_path": "scipy/corelib/setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -15,12 +15,14 @@ def configuration(parent_package='',top_path=None):\n #blas_info = {}\n def get_dotblas_sources(ext, build_dir):\n if blas_info:\n- return ext.depends\n+ return ext.depends[:1]\n return None # no extension module will be built\n \n config.add_extension('_dotblas',\n sources = [get_dotblas_sources],\n- depends=[join('blasdot','_dotblas.c')],\n+ depends=[join('blasdot','_dotblas.c'),\n+ join('blasdot','cblas.h'),\n+ ],\n include_dirs = ['blasdot'],\n extra_info = blas_info\n )\n@@ -38,6 +40,10 @@ def get_dotblas_sources(ext, build_dir):\n 'distributions.c', 'gamma.c', 'polevl.c', \n 'isnan.c', 'const.c']],\n libraries=['m'],\n+ depends = [join('mtrand','*.h'),\n+ join('mtrand','*.pyx'),\n+ join('mtrand','*.pxi'),\n+ ]\n )\n \n # Configure lapack_lite\n", "added_lines": 8, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\nimport os\nfrom os.path import join\nfrom scipy.distutils.core import setup\nfrom scipy.distutils.misc_util import Configuration, allpath\nfrom scipy.distutils.system_info import get_info\nimport sys\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('lib',parent_package,top_path)\n local_dir = config.local_path\n\n # Configure blasdot\n blas_info = get_info('blas_opt')\n #blas_info = {}\n def get_dotblas_sources(ext, build_dir):\n if blas_info:\n return ext.depends[:1]\n return None # no extension module will be built\n\n config.add_extension('_dotblas',\n sources = [get_dotblas_sources],\n depends=[join('blasdot','_dotblas.c'),\n join('blasdot','cblas.h'),\n ],\n include_dirs = ['blasdot'],\n extra_info = blas_info\n )\n\n # Configure fftpack_lite\n config.add_extension('fftpack_lite',\n sources=[join('fftpack_lite', x) for x in \\\n ['fftpack_litemodule.c', 'fftpack.c']]\n )\n\n # Configure mtrand\n config.add_extension('mtrand',\n sources=[join('mtrand', x) for x in \n ['mtrand.c', 'randomkit.c', 'initarray.c',\n 'distributions.c', 'gamma.c', 'polevl.c', \n 'isnan.c', 'const.c']],\n libraries=['m'],\n depends = [join('mtrand','*.h'),\n join('mtrand','*.pyx'),\n join('mtrand','*.pxi'),\n ]\n )\n\n # Configure lapack_lite\n lapack_info = get_info('lapack_opt')\n def get_lapack_lite_sources(ext, build_dir):\n if not lapack_info:\n print \"### Warning: Using unoptimized lapack ###\"\n return ext.depends\n else:\n return ext.depends[:1]\n\n config.add_extension('lapack_lite',\n sources = [get_lapack_lite_sources],\n depends=[join('lapack_lite', x) for x in \\\n ['lapack_litemodule.c',\n 'zlapack_lite.c', 'dlapack_lite.c',\n 'blas_lite.c', 'dlamch.c',\n 'f2c_lite.c']],\n extra_info = lapack_info\n )\n \n return config.todict()\n\nif __name__ == '__main__':\n setup(**configuration(top_path=''))\n", "source_code_before": "#!/usr/bin/env python\nimport os\nfrom os.path import join\nfrom scipy.distutils.core import setup\nfrom scipy.distutils.misc_util import Configuration, allpath\nfrom scipy.distutils.system_info import get_info\nimport sys\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('lib',parent_package,top_path)\n local_dir = config.local_path\n\n # Configure blasdot\n blas_info = get_info('blas_opt')\n #blas_info = {}\n def get_dotblas_sources(ext, build_dir):\n if blas_info:\n return ext.depends\n return None # no extension module will be built\n\n config.add_extension('_dotblas',\n sources = [get_dotblas_sources],\n depends=[join('blasdot','_dotblas.c')],\n include_dirs = ['blasdot'],\n extra_info = blas_info\n )\n\n # Configure fftpack_lite\n config.add_extension('fftpack_lite',\n sources=[join('fftpack_lite', x) for x in \\\n ['fftpack_litemodule.c', 'fftpack.c']]\n )\n\n # Configure mtrand\n config.add_extension('mtrand',\n sources=[join('mtrand', x) for x in \n ['mtrand.c', 'randomkit.c', 'initarray.c',\n 'distributions.c', 'gamma.c', 'polevl.c', \n 'isnan.c', 'const.c']],\n libraries=['m'],\n )\n\n # Configure lapack_lite\n lapack_info = get_info('lapack_opt')\n def get_lapack_lite_sources(ext, build_dir):\n if not lapack_info:\n print \"### Warning: Using unoptimized lapack ###\"\n return ext.depends\n else:\n return ext.depends[:1]\n\n config.add_extension('lapack_lite',\n sources = [get_lapack_lite_sources],\n depends=[join('lapack_lite', x) for x in \\\n ['lapack_litemodule.c',\n 'zlapack_lite.c', 'dlapack_lite.c',\n 'blas_lite.c', 'dlamch.c',\n 'f2c_lite.c']],\n extra_info = lapack_info\n )\n \n return config.todict()\n\nif __name__ == '__main__':\n setup(**configuration(top_path=''))\n", "methods": [ { "name": "configuration.get_dotblas_sources", "long_name": "configuration.get_dotblas_sources( ext , build_dir )", "filename": "setup.py", "nloc": 4, "complexity": 2, "token_count": 20, "parameters": [ "ext", "build_dir" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configuration.get_lapack_lite_sources", "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", "filename": "setup.py", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [ "ext", "build_dir" ], "start_line": 51, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 40, "complexity": 4, "token_count": 228, "parameters": [ "parent_package", "top_path" ], "start_line": 9, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration.get_dotblas_sources", "long_name": "configuration.get_dotblas_sources( ext , build_dir )", "filename": "setup.py", "nloc": 4, "complexity": 2, "token_count": 16, "parameters": [ "ext", "build_dir" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configuration.get_lapack_lite_sources", "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", "filename": "setup.py", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [ "ext", "build_dir" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 34, "complexity": 4, "token_count": 195, "parameters": [ "parent_package", "top_path" ], "start_line": 9, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration.get_dotblas_sources", "long_name": "configuration.get_dotblas_sources( ext , build_dir )", "filename": "setup.py", "nloc": 4, "complexity": 2, "token_count": 20, "parameters": [ "ext", "build_dir" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configuration", "long_name": "configuration( parent_package = '' , top_path = None )", "filename": "setup.py", "nloc": 40, "complexity": 4, "token_count": 228, "parameters": [ "parent_package", "top_path" ], "start_line": 9, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 } ], "nloc": 56, "complexity": 8, "token_count": 325, "diff_parsed": { "added": [ " return ext.depends[:1]", " depends=[join('blasdot','_dotblas.c'),", " join('blasdot','cblas.h'),", " ],", " depends = [join('mtrand','*.h'),", " join('mtrand','*.pyx'),", " join('mtrand','*.pxi'),", " ]" ], "deleted": [ " return ext.depends", " depends=[join('blasdot','_dotblas.c')]," ] } }, { "old_path": "scipy/distutils/misc_util.py", "new_path": "scipy/distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -554,7 +554,6 @@ def add_extension(self,name,sources,**kw):\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n \n-\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n", "added_lines": 0, "deleted_lines": 1, "source_code": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport types\nimport glob\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" Return path of the module.\n\n Returned path is relative to parent_path when given,\n otherwise it is absolute path.\n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n __import__(mod_name)\n mod = sys.modules[mod_name]\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d or '.'\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if type(item) is not types.StringType:\n return False\n return True\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob.glob(os.path.join(dir,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if type(directory) is not type(''):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef _gsf_visit_func(filenames,dirname,names):\n if os.path.basename(dirname) in ['CVS','.svn','build']:\n names[:] = []\n return\n for name in names:\n if name[-1] in \"~#\":\n continue\n fullname = os.path.join(dirname,name)\n ext = os.path.splitext(fullname)[1]\n if ext and ext in ['.pyc','.o']:\n continue\n if os.path.isfile(fullname):\n filenames.append(fullname)\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(lambda s:type(s) is types.StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(lambda s:type(s) is types.StringType,scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(lambda s:type(s) is types.StringType,sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = build_info.get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if type(data) is types.StringType:\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n s = s()\n if s is None:\n continue\n if is_local_src_dir(s):\n os.path.walk(s,_gsf_visit_func,filenames)\n elif type(s) is type('') and os.path.isfile(s):\n filenames.append(s)\n else:\n raise TypeError,`s`\n return filenames\n\ndef dot_join(*args):\n return '.'.join(filter(None,args))\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration:\n\n _list_keys = ['packages','ext_modules','data_files','include_dirs',\n 'libraries','headers','scripts']\n _dict_keys = ['package_dir']\n\n scipy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(1)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n \n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(os.path.join(self.local_path,package_path)):\n package_path = os.path.join(self.local_path,package_path)\n self.top_path = top_path\n\n self.list_keys = copy.copy(self._list_keys)\n self.dict_keys = copy.copy(self._dict_keys)\n\n for n in self.list_keys:\n setattr(self,n,copy.copy(attrs.get(n,[])))\n\n for n in self.dict_keys:\n setattr(self,n,copy.copy(attrs.get(n,{})))\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if type(a) is types.ListType:\n self.list_keys.append(n)\n elif type(a) is types.DictType:\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(os.path.join(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path \n return\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def __dict__(self):\n return self.todict()\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution \n return dist\n\n def get_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Return subpackage configuration.\n \"\"\"\n if subpackage_name is None:\n assert subpackage_path is not None\n subpackage_name = os.path.basename(subpackage_path)\n assert '.' not in subpackage_name,`subpackage_name`\n if subpackage_path is None:\n subpackage_path = os.path.join(self.local_path,subpackage_name)\n else:\n subpackage_path = self._fix_paths([subpackage_path])[0]\n\n setup_py = os.path.join(subpackage_path,'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n setup_py = os.path.join(subpackage_path,'setup.py')\n if not os.path.isfile(setup_py):\n print 'Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py),subpackage_name)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n info = (open(setup_py),setup_py,('.py','U',1))\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),*info)\n\n if not hasattr(setup_module,'configuration'):\n print 'Assuming default configuration '\\\n '(%s does not define configuration())' % (setup_module)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n args = (self.name,)\n if setup_module.configuration.func_code.co_argcount>1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n\n finally:\n del sys.path[0]\n\n return config\n\n def add_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n config = self.get_subpackage(subpackage_name,subpackage_path)\n\n if not config:\n print 'No configuration returned, assuming unavailable.'\n else:\n\n if isinstance(config,Configuration):\n print 'Appending %s configuration to %s' % (config.name,self.name)\n self.dict_append(**config.todict())\n else:\n print 'Appending %s configuration to %s' % (config.get('name'),self.name)\n self.dict_append(**config)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a subpackage', subpackage_name\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Add files under data_path to data_files list.\n \"\"\"\n for path in self.paths(data_path):\n filenames = []\n os.path.walk(path, _gsf_visit_func,filenames)\n if not os.path.isabs(path):\n self.add_data_files((path,filenames))\n else:\n self.add_data_files(*filenames)\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir suffix defaults\n to package dir.\n If path is not absolute then it's datadir suffix is\n package dir + dirname of the path.\n \"\"\"\n data_dict = {}\n for p in files:\n if type(p) is type(''):\n d = os.path.join(*(self.name.split('.')))\n file_list = self.paths(p)\n if not os.path.isabs(p):\n d = appendpath(d,os.path.dirname(p))\n elif type(p) is type(()):\n assert len(p)==2,`p`\n d = p[0]\n if type(p[1]) is type(''):\n file_list = self.paths(p[1])\n else:\n file_list = self.paths(*p[1])\n else:\n # function\n d = os.path.join(*(self.name.split('.')))\n file_list = [p]\n if not data_dict.has_key(d):\n data_dict[d] = file_list[:]\n else:\n data_dict[d].extend(file_list)\n\n dist = self.get_distribution()\n if dist is not None:\n dist.data_files.extend(data_dict.items())\n else:\n self.data_files.extend(data_dict.items())\n\n return \n \n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self._fix_paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if type(path) is type(''):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n assert type(path) in [type(()),type([])] and len(path)==2,`path`\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def _fix_paths(self,paths):\n new_paths = []\n for n in paths:\n if isinstance(n,str):\n if '*' in n or '?' in n:\n p = glob.glob(n)\n p2 = glob.glob(os.path.join(self.local_path,n))\n if p2:\n new_paths.extend(p2)\n elif p:\n new_paths.extend(p)\n else:\n new_paths.append(n)\n else:\n n2 = os.path.join(self.local_path,n)\n if os.path.exists(n2):\n new_paths.append(n2)\n else:\n new_paths.append(n)\n else:\n new_paths.append(n)\n return new_paths\n\n def paths(self,*paths):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n return self._fix_paths(paths)\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if type(extra_info) is type({}):\n extra_info = [extra_info]\n for info in extra_info:\n assert type(info) is type({}),`info`\n dict_append(ext_args,**info)\n\n for k in ext_args.keys():\n v = ext_args[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(os.path.join(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from scipy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add an extension', name\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n \n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name + '__OF__' + self.name\n build_info['sources'] = sources\n\n for k in build_info.keys():\n v = build_info[k]\n if k in ['sources','depends']:\n new_v = self._fix_paths(v)\n build_info[k] = new_v\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a library', name\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self._fix_paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n print 'Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?'))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %r\\n' % (k,a)\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if type(extlib) is type(()):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from scipy.distutils.core import Extension\n assert isinstance(extlib,Extension),`extlib`\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = os.path.join(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = os.path.join(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n print msg\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = os.path.join(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n print 'Creating %s (version=%r)' % (target,version)\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n \n import atexit\n def rm_file(f=target):\n try: os.remove(f); print 'removed',f\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(generate_svn_version_py)\n return\n\ndef get_cmd(cmdname,_cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError,\\\n 'setup distribution instance not initialized'\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_scipy_include_dirs():\n include_dirs = Configuration.scipy_include_dirs[:]\n if not include_dirs:\n import scipy.base as base\n include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))\n #from distutils.sysconfig import get_python_inc\n #prefix = []\n #for name in scipy.__file__.split(os.sep):\n # if name=='lib':\n # break\n # prefix.append(name)\n #include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n return include_dirs\n\n#########################\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n if os.path.join(absprefix[:len(d)],absprefix[len(d):])!=absprefix \\\n or os.path.join(path[:len(d)],path[len(d):])!=path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(os.path.join(prefix, subpath))\n\ndef generate_config_py(extension, build_dir):\n \"\"\" Generate /config.py file containing system_info\n information used during building the package.\n\n Usage:\\\n ext = Extension(dot_join(config['name'],'config'),\n sources=[generate_config_py])\n config['ext_modules'].append(ext)\n \"\"\"\n from scipy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n target = os.path.join(*([build_dir]+extension.name.split('.'))) + '.py'\n mkpath(os.path.dirname(target))\n f = open(target,'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k,i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k,i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n\ndef generate_svn_version_py(extension, build_dir):\n \"\"\" Generate __svn_version__.py file containing SVN\n revision number of a module.\n \n To use, add the following codelet to setup\n configuration(..) function\n\n ext = Extension(dot_join(config['name'],'__svn_version__'),\n sources=[generate_svn_version_py])\n ext.local_path = local_path\n config['ext_modules'].append(ext)\n\n \"\"\"\n from distutils import dep_util\n local_path = extension.local_path\n target = os.path.join(build_dir, '__svn_version__.py')\n entries = os.path.join(local_path,'.svn','entries')\n if os.path.isfile(entries):\n if not dep_util.newer(entries, target):\n return target\n elif os.path.isfile(target):\n return target\n\n revision = get_svn_revision(local_path)\n f = open(target,'w')\n f.write('revision=%s\\n' % (revision))\n f.close()\n return target\n", "source_code_before": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport types\nimport glob\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" Return path of the module.\n\n Returned path is relative to parent_path when given,\n otherwise it is absolute path.\n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n __import__(mod_name)\n mod = sys.modules[mod_name]\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d or '.'\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if type(item) is not types.StringType:\n return False\n return True\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob.glob(os.path.join(dir,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if type(directory) is not type(''):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef _gsf_visit_func(filenames,dirname,names):\n if os.path.basename(dirname) in ['CVS','.svn','build']:\n names[:] = []\n return\n for name in names:\n if name[-1] in \"~#\":\n continue\n fullname = os.path.join(dirname,name)\n ext = os.path.splitext(fullname)[1]\n if ext and ext in ['.pyc','.o']:\n continue\n if os.path.isfile(fullname):\n filenames.append(fullname)\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(lambda s:type(s) is types.StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(lambda s:type(s) is types.StringType,scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(lambda s:type(s) is types.StringType,sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = build_info.get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if type(data) is types.StringType:\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n s = s()\n if s is None:\n continue\n if is_local_src_dir(s):\n os.path.walk(s,_gsf_visit_func,filenames)\n elif type(s) is type('') and os.path.isfile(s):\n filenames.append(s)\n else:\n raise TypeError,`s`\n return filenames\n\ndef dot_join(*args):\n return '.'.join(filter(None,args))\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration:\n\n _list_keys = ['packages','ext_modules','data_files','include_dirs',\n 'libraries','headers','scripts']\n _dict_keys = ['package_dir']\n\n scipy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(1)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n \n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(os.path.join(self.local_path,package_path)):\n package_path = os.path.join(self.local_path,package_path)\n self.top_path = top_path\n\n self.list_keys = copy.copy(self._list_keys)\n self.dict_keys = copy.copy(self._dict_keys)\n\n for n in self.list_keys:\n setattr(self,n,copy.copy(attrs.get(n,[])))\n\n for n in self.dict_keys:\n setattr(self,n,copy.copy(attrs.get(n,{})))\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if type(a) is types.ListType:\n self.list_keys.append(n)\n elif type(a) is types.DictType:\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(os.path.join(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path \n return\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def __dict__(self):\n return self.todict()\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution \n return dist\n\n def get_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Return subpackage configuration.\n \"\"\"\n if subpackage_name is None:\n assert subpackage_path is not None\n subpackage_name = os.path.basename(subpackage_path)\n assert '.' not in subpackage_name,`subpackage_name`\n if subpackage_path is None:\n subpackage_path = os.path.join(self.local_path,subpackage_name)\n else:\n subpackage_path = self._fix_paths([subpackage_path])[0]\n\n setup_py = os.path.join(subpackage_path,'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n setup_py = os.path.join(subpackage_path,'setup.py')\n if not os.path.isfile(setup_py):\n print 'Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py),subpackage_name)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n info = (open(setup_py),setup_py,('.py','U',1))\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),*info)\n\n if not hasattr(setup_module,'configuration'):\n print 'Assuming default configuration '\\\n '(%s does not define configuration())' % (setup_module)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n args = (self.name,)\n if setup_module.configuration.func_code.co_argcount>1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n\n finally:\n del sys.path[0]\n\n return config\n\n def add_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n config = self.get_subpackage(subpackage_name,subpackage_path)\n\n if not config:\n print 'No configuration returned, assuming unavailable.'\n else:\n\n if isinstance(config,Configuration):\n print 'Appending %s configuration to %s' % (config.name,self.name)\n self.dict_append(**config.todict())\n else:\n print 'Appending %s configuration to %s' % (config.get('name'),self.name)\n self.dict_append(**config)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a subpackage', subpackage_name\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Add files under data_path to data_files list.\n \"\"\"\n for path in self.paths(data_path):\n filenames = []\n os.path.walk(path, _gsf_visit_func,filenames)\n if not os.path.isabs(path):\n self.add_data_files((path,filenames))\n else:\n self.add_data_files(*filenames)\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir suffix defaults\n to package dir.\n If path is not absolute then it's datadir suffix is\n package dir + dirname of the path.\n \"\"\"\n data_dict = {}\n for p in files:\n if type(p) is type(''):\n d = os.path.join(*(self.name.split('.')))\n file_list = self.paths(p)\n if not os.path.isabs(p):\n d = appendpath(d,os.path.dirname(p))\n elif type(p) is type(()):\n assert len(p)==2,`p`\n d = p[0]\n if type(p[1]) is type(''):\n file_list = self.paths(p[1])\n else:\n file_list = self.paths(*p[1])\n else:\n # function\n d = os.path.join(*(self.name.split('.')))\n file_list = [p]\n if not data_dict.has_key(d):\n data_dict[d] = file_list[:]\n else:\n data_dict[d].extend(file_list)\n\n dist = self.get_distribution()\n if dist is not None:\n dist.data_files.extend(data_dict.items())\n else:\n self.data_files.extend(data_dict.items())\n\n return \n \n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self._fix_paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if type(path) is type(''):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n assert type(path) in [type(()),type([])] and len(path)==2,`path`\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def _fix_paths(self,paths):\n new_paths = []\n for n in paths:\n if isinstance(n,str):\n if '*' in n or '?' in n:\n p = glob.glob(n)\n p2 = glob.glob(os.path.join(self.local_path,n))\n if p2:\n new_paths.extend(p2)\n elif p:\n new_paths.extend(p)\n else:\n new_paths.append(n)\n else:\n n2 = os.path.join(self.local_path,n)\n if os.path.exists(n2):\n new_paths.append(n2)\n else:\n new_paths.append(n)\n else:\n new_paths.append(n)\n return new_paths\n\n def paths(self,*paths):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n return self._fix_paths(paths)\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if type(extra_info) is type({}):\n extra_info = [extra_info]\n for info in extra_info:\n assert type(info) is type({}),`info`\n dict_append(ext_args,**info)\n\n for k in ext_args.keys():\n v = ext_args[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(os.path.join(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from scipy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add an extension', name\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n \n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name + '__OF__' + self.name\n build_info['sources'] = sources\n\n for k in build_info.keys():\n v = build_info[k]\n if k in ['sources','depends']:\n new_v = self._fix_paths(v)\n build_info[k] = new_v\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a library', name\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self._fix_paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n print 'Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?'))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %r\\n' % (k,a)\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if type(extlib) is type(()):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from scipy.distutils.core import Extension\n assert isinstance(extlib,Extension),`extlib`\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = os.path.join(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = os.path.join(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n print msg\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = os.path.join(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n print 'Creating %s (version=%r)' % (target,version)\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n \n import atexit\n def rm_file(f=target):\n try: os.remove(f); print 'removed',f\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(generate_svn_version_py)\n return\n\ndef get_cmd(cmdname,_cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError,\\\n 'setup distribution instance not initialized'\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_scipy_include_dirs():\n include_dirs = Configuration.scipy_include_dirs[:]\n if not include_dirs:\n import scipy.base as base\n include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))\n #from distutils.sysconfig import get_python_inc\n #prefix = []\n #for name in scipy.__file__.split(os.sep):\n # if name=='lib':\n # break\n # prefix.append(name)\n #include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n return include_dirs\n\n#########################\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n if os.path.join(absprefix[:len(d)],absprefix[len(d):])!=absprefix \\\n or os.path.join(path[:len(d)],path[len(d):])!=path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(os.path.join(prefix, subpath))\n\ndef generate_config_py(extension, build_dir):\n \"\"\" Generate /config.py file containing system_info\n information used during building the package.\n\n Usage:\\\n ext = Extension(dot_join(config['name'],'config'),\n sources=[generate_config_py])\n config['ext_modules'].append(ext)\n \"\"\"\n from scipy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n target = os.path.join(*([build_dir]+extension.name.split('.'))) + '.py'\n mkpath(os.path.dirname(target))\n f = open(target,'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k,i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k,i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n\ndef generate_svn_version_py(extension, build_dir):\n \"\"\" Generate __svn_version__.py file containing SVN\n revision number of a module.\n \n To use, add the following codelet to setup\n configuration(..) function\n\n ext = Extension(dot_join(config['name'],'__svn_version__'),\n sources=[generate_svn_version_py])\n ext.local_path = local_path\n config['ext_modules'].append(ext)\n\n \"\"\"\n from distutils import dep_util\n local_path = extension.local_path\n target = os.path.join(build_dir, '__svn_version__.py')\n entries = os.path.join(local_path,'.svn','entries')\n if os.path.isfile(entries):\n if not dep_util.newer(entries, target):\n return target\n elif os.path.isfile(target):\n return target\n\n revision = get_svn_revision(local_path)\n f = open(target,'w')\n f.write('revision=%s\\n' % (revision))\n f.close()\n return target\n", "methods": [ { "name": "allpath", "long_name": "allpath( name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "name" ], "start_line": 9, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 129, "parameters": [ "mod_name", "parent_path" ], "start_line": 14, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 38, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "cyg2win32", "long_name": "cyg2win32( path )", "filename": "misc_util.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "path" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_get_f90_modules", "long_name": "_get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "all_strings", "long_name": "all_strings( lst )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [ "lst" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 117, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 124, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 131, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_get_headers", "long_name": "_get_headers( directory_list )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "directory_list" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_get_directories", "long_name": "_get_directories( list_of_sources )", "filename": "misc_util.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 162, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_dependencies", "long_name": "get_dependencies( sources )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "sources" ], "start_line": 171, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "misc_util.py", "nloc": 12, "complexity": 6, "token_count": 112, "parameters": [ "directory" ], "start_line": 175, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "_gsf_visit_func", "long_name": "_gsf_visit_func( filenames , dirname , names )", "filename": "misc_util.py", "nloc": 13, "complexity": 7, "token_count": 103, "parameters": [ "filenames", "dirname", "names" ], "start_line": 190, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_ext_source_files", "long_name": "get_ext_source_files( ext )", "filename": "misc_util.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "ext" ], "start_line": 204, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "get_script_files", "long_name": "get_script_files( scripts )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "scripts" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_lib_source_files", "long_name": "get_lib_source_files( lib )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 108, "parameters": [ "lib" ], "start_line": 221, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_data_files", "long_name": "get_data_files( data )", "filename": "misc_util.py", "nloc": 17, "complexity": 8, "token_count": 105, "parameters": [ "data" ], "start_line": 235, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "args" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 256, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , ** attrs )", "filename": "misc_util.py", "nloc": 40, "complexity": 11, "token_count": 335, "parameters": [ "self", "package_name", "parent_name", "top_path", "package_path", "attrs" ], "start_line": 275, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 1 }, { "name": "todict", "long_name": "todict( self )", "filename": "misc_util.py", "nloc": 9, "complexity": 4, "token_count": 57, "parameters": [ "self" ], "start_line": 325, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__dict__", "long_name": "__dict__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_distribution", "long_name": "get_distribution( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 341, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_subpackage", "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 38, "complexity": 8, "token_count": 333, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 346, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "add_subpackage", "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 392, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "add_data_dir", "long_name": "add_data_dir( self , data_path )", "filename": "misc_util.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "data_path" ], "start_line": 413, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "add_data_files", "long_name": "add_data_files( self , * files )", "filename": "misc_util.py", "nloc": 28, "complexity": 8, "token_count": 247, "parameters": [ "self", "files" ], "start_line": 425, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "add_include_dirs", "long_name": "add_include_dirs( self , * paths )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "paths" ], "start_line": 465, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "add_headers", "long_name": "add_headers( self , * files )", "filename": "misc_util.py", "nloc": 14, "complexity": 7, "token_count": 143, "parameters": [ "self", "files" ], "start_line": 476, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_fix_paths", "long_name": "_fix_paths( self , paths )", "filename": "misc_util.py", "nloc": 22, "complexity": 8, "token_count": 136, "parameters": [ "self", "paths" ], "start_line": 497, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "paths", "long_name": "paths( self , * paths )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "paths" ], "start_line": 520, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 45, "complexity": 14, "token_count": 365, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , name , sources , ** build_info )", "filename": "misc_util.py", "nloc": 14, "complexity": 4, "token_count": 104, "parameters": [ "self", "name", "sources", "build_info" ], "start_line": 589, "end_line": 613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "add_scripts", "long_name": "add_scripts( self , * files )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "files" ], "start_line": 615, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "dict_append", "long_name": "dict_append( self , ** dict )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 138, "parameters": [ "self", "dict" ], "start_line": 626, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 642, "end_line": 651, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_config_cmd", "long_name": "get_config_cmd( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 2, "token_count": 63, "parameters": [ "self" ], "start_line": 653, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_build_temp_dir", "long_name": "get_build_temp_dir( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 664, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "have_f77c", "long_name": "have_f77c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 669, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "have_f90c", "long_name": "have_f90c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 682, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "append_to", "long_name": "append_to( self , extlib )", "filename": "misc_util.py", "nloc": 12, "complexity": 2, "token_count": 83, "parameters": [ "self", "extlib" ], "start_line": 695, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_get_svn_revision", "long_name": "_get_svn_revision( self , path )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 77, "parameters": [ "self", "path" ], "start_line": 710, "end_line": 721, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "misc_util.py", "nloc": 38, "complexity": 11, "token_count": 257, "parameters": [ "self" ], "start_line": 723, "end_line": 769, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target )", "filename": "misc_util.py", "nloc": 3, "complexity": 2, "token_count": 24, "parameters": [ "f" ], "start_line": 793, "end_line": 795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 3 }, { "name": "make_svn_version_py.generate_svn_version_py", "long_name": "make_svn_version_py.generate_svn_version_py( )", "filename": "misc_util.py", "nloc": 13, "complexity": 2, "token_count": 81, "parameters": [], "start_line": 782, "end_line": 798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 2 }, { "name": "make_svn_version_py", "long_name": "make_svn_version_py( self )", "filename": "misc_util.py", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 771, "end_line": 801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_cmd", "long_name": "get_cmd( cmdname , _cache = { } )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 65, "parameters": [ "cmdname", "_cache" ], "start_line": 803, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "get_scipy_include_dirs", "long_name": "get_scipy_include_dirs( )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [], "start_line": 815, "end_line": 827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 831, "end_line": 836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "misc_util.py", "nloc": 13, "complexity": 5, "token_count": 157, "parameters": [ "prefix", "path" ], "start_line": 838, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "generate_config_py", "long_name": "generate_config_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 28, "complexity": 2, "token_count": 145, "parameters": [ "extension", "build_dir" ], "start_line": 853, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "generate_svn_version_py", "long_name": "generate_svn_version_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 109, "parameters": [ "extension", "build_dir" ], "start_line": 891, "end_line": 918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "methods_before": [ { "name": "allpath", "long_name": "allpath( name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "name" ], "start_line": 9, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 129, "parameters": [ "mod_name", "parent_path" ], "start_line": 14, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 38, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "cyg2win32", "long_name": "cyg2win32( path )", "filename": "misc_util.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "path" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_get_f90_modules", "long_name": "_get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "all_strings", "long_name": "all_strings( lst )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [ "lst" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 117, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 124, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 131, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_get_headers", "long_name": "_get_headers( directory_list )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "directory_list" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_get_directories", "long_name": "_get_directories( list_of_sources )", "filename": "misc_util.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 162, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_dependencies", "long_name": "get_dependencies( sources )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "sources" ], "start_line": 171, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "misc_util.py", "nloc": 12, "complexity": 6, "token_count": 112, "parameters": [ "directory" ], "start_line": 175, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "_gsf_visit_func", "long_name": "_gsf_visit_func( filenames , dirname , names )", "filename": "misc_util.py", "nloc": 13, "complexity": 7, "token_count": 103, "parameters": [ "filenames", "dirname", "names" ], "start_line": 190, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_ext_source_files", "long_name": "get_ext_source_files( ext )", "filename": "misc_util.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "ext" ], "start_line": 204, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "get_script_files", "long_name": "get_script_files( scripts )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "scripts" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_lib_source_files", "long_name": "get_lib_source_files( lib )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 108, "parameters": [ "lib" ], "start_line": 221, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_data_files", "long_name": "get_data_files( data )", "filename": "misc_util.py", "nloc": 17, "complexity": 8, "token_count": 105, "parameters": [ "data" ], "start_line": 235, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "args" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 256, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , ** attrs )", "filename": "misc_util.py", "nloc": 40, "complexity": 11, "token_count": 335, "parameters": [ "self", "package_name", "parent_name", "top_path", "package_path", "attrs" ], "start_line": 275, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 1 }, { "name": "todict", "long_name": "todict( self )", "filename": "misc_util.py", "nloc": 9, "complexity": 4, "token_count": 57, "parameters": [ "self" ], "start_line": 325, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__dict__", "long_name": "__dict__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_distribution", "long_name": "get_distribution( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 341, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_subpackage", "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 38, "complexity": 8, "token_count": 333, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 346, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "add_subpackage", "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 392, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "add_data_dir", "long_name": "add_data_dir( self , data_path )", "filename": "misc_util.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "data_path" ], "start_line": 413, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "add_data_files", "long_name": "add_data_files( self , * files )", "filename": "misc_util.py", "nloc": 28, "complexity": 8, "token_count": 247, "parameters": [ "self", "files" ], "start_line": 425, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "add_include_dirs", "long_name": "add_include_dirs( self , * paths )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "paths" ], "start_line": 465, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "add_headers", "long_name": "add_headers( self , * files )", "filename": "misc_util.py", "nloc": 14, "complexity": 7, "token_count": 143, "parameters": [ "self", "files" ], "start_line": 476, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_fix_paths", "long_name": "_fix_paths( self , paths )", "filename": "misc_util.py", "nloc": 22, "complexity": 8, "token_count": 136, "parameters": [ "self", "paths" ], "start_line": 497, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "paths", "long_name": "paths( self , * paths )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "paths" ], "start_line": 520, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 45, "complexity": 14, "token_count": 365, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 588, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , name , sources , ** build_info )", "filename": "misc_util.py", "nloc": 14, "complexity": 4, "token_count": 104, "parameters": [ "self", "name", "sources", "build_info" ], "start_line": 590, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "add_scripts", "long_name": "add_scripts( self , * files )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "files" ], "start_line": 616, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "dict_append", "long_name": "dict_append( self , ** dict )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 138, "parameters": [ "self", "dict" ], "start_line": 627, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 643, "end_line": 652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_config_cmd", "long_name": "get_config_cmd( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 2, "token_count": 63, "parameters": [ "self" ], "start_line": 654, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_build_temp_dir", "long_name": "get_build_temp_dir( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 665, "end_line": 668, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "have_f77c", "long_name": "have_f77c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 670, "end_line": 681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "have_f90c", "long_name": "have_f90c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 683, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "append_to", "long_name": "append_to( self , extlib )", "filename": "misc_util.py", "nloc": 12, "complexity": 2, "token_count": 83, "parameters": [ "self", "extlib" ], "start_line": 696, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_get_svn_revision", "long_name": "_get_svn_revision( self , path )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 77, "parameters": [ "self", "path" ], "start_line": 711, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "misc_util.py", "nloc": 38, "complexity": 11, "token_count": 257, "parameters": [ "self" ], "start_line": 724, "end_line": 770, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target )", "filename": "misc_util.py", "nloc": 3, "complexity": 2, "token_count": 24, "parameters": [ "f" ], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 3 }, { "name": "make_svn_version_py.generate_svn_version_py", "long_name": "make_svn_version_py.generate_svn_version_py( )", "filename": "misc_util.py", "nloc": 13, "complexity": 2, "token_count": 81, "parameters": [], "start_line": 783, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 2 }, { "name": "make_svn_version_py", "long_name": "make_svn_version_py( self )", "filename": "misc_util.py", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 772, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_cmd", "long_name": "get_cmd( cmdname , _cache = { } )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 65, "parameters": [ "cmdname", "_cache" ], "start_line": 804, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "get_scipy_include_dirs", "long_name": "get_scipy_include_dirs( )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [], "start_line": 816, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 832, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "misc_util.py", "nloc": 13, "complexity": 5, "token_count": 157, "parameters": [ "prefix", "path" ], "start_line": 839, "end_line": 852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "generate_config_py", "long_name": "generate_config_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 28, "complexity": 2, "token_count": 145, "parameters": [ "extension", "build_dir" ], "start_line": 854, "end_line": 890, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "generate_svn_version_py", "long_name": "generate_svn_version_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 109, "parameters": [ "extension", "build_dir" ], "start_line": 892, "end_line": 919, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 45, "complexity": 14, "token_count": 365, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 588, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 } ], "nloc": 681, "complexity": 215, "token_count": 5035, "diff_parsed": { "added": [], "deleted": [ "" ] } } ] }, { "hash": "c3a9fe713e0009461e85a4dc989f7f86e14178fe", "msg": "Fixed some more bugs", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-05T09:00:20+00:00", "author_timezone": 0, "committer_date": "2005-10-05T09:00:20+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "2d40d9e98c57824edd7f9130d9036fb9115bc70d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 31, "insertions": 47, "lines": 78, "files": 3, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy/base/src/arraytypes.inc.src", "new_path": "scipy/base/src/arraytypes.inc.src", "filename": "arraytypes.inc.src", "extension": "src", "change_type": "MODIFY", "diff": "@@ -1571,7 +1571,6 @@ PyArray_DescrFromType(int type) {\n \t\treturn userdescrs[type-PyArray_USERDEF];\n \t} \n \telse {\n-\t\tfprintf(stderr, \"Getting Descr from character code...\\n\");\n \t\tswitch(type) {\n case PyArray_INTPLTR: return descrs[PyArray_INTP];\n \t\tcase PyArray_DOUBLELTR: return descrs[PyArray_DOUBLE];\n", "added_lines": 0, "deleted_lines": 1, "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n\n\n#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n#incr= ip++*196,ip+=2*42#\n*/\n\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;idescr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n\n\n#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n#incr= ip++*196,ip+=2*42#\n*/\n\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;ielsize;\n+\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n+\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n+\t\t\t}\n+\t\t}\n \t\tif (size < loop->bufsize) {\n \t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n \t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n \t\t\t\tntype.type_num = arg_types[i];\n+\t\t\t\tntype.itemsize = 0;\n \t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n \t\t\t\t\t\t &ntype, 0, 0,\n \t\t\t\t\t\t FORCECAST |\t\\\n@@ -948,7 +964,7 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n if (i < self->nin) {\n loop->cast[i] = \\\n \t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n-\t\t\t\tcntcast = descr->elsize;\n+\t\t\t\tcntcast += descr->elsize;\n \t\t\t}\n else {\n loop->cast[i] = descr->\\\n@@ -1024,9 +1040,9 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \t\t\tit->dims_m1[ldim] = 0;\n \t\t\tit->backstrides[ldim] = 0;\n \n-\t\t\t/* (won't use factors because we\n-\t\t\t don't use PyArray_ITER_GOTO1D) \n-\t\t\t so don't worry about resetting it) */\n+\t\t\t/* (won't fix factors because we\n+\t\t\t don't use PyArray_ITER_GOTO1D \n+\t\t\t so don't change them) */\n \n \n \t\t\t/* Set the steps to the strides in that dimension */\n@@ -1057,15 +1073,14 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n \t\tif (loop->buffer[0] == NULL) return -1;\n \t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n-\t\tfor (i=0; inumiter; i++) {\n+\t\tfor (i=0; inargs; i++) {\n \t\t\tif (i > 0)\n \t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n \t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n-\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n+\t\t\tif (loop->cast[i]) {\n \t\t\t\tloop->castbuf[i] = castptr + \n \t\t\t\t\tloop->bufsize*oldsize;\n #define _PyD PyArray_DescrFromType\n-\t\t\t\t\n \t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n #undef _PyD\n \t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n@@ -1221,7 +1236,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t Or if not contiguous, then a single-stride\n \t\t increment moves through the entire array. \n \t\t*/\n- /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n+ /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n \t\tloop->function((char **)loop->bufptr, &(loop->size), \n \t\t\t loop->steps, loop->funcdata);\n \t\tUFUNC_CHECK_ERROR();\n@@ -1247,15 +1262,12 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\tbreak;\n \tcase BUFFER_UFUNCLOOP: {\n \t\t/* Make local copies of all loop variables */\n-\t\t/* Optimizations: \n-\t\t 1) move data better into and out of the buffers \n+\t\t/* Optimizations needed:\n+\t\t 1) move data better into the buffer better\n \t\t --- not one at a time. \n-\t\t 2) don't call copyswap unless needed -- and\n-\t\t call it on the data in the buffer using\n-\t\t copyswapn.\n-\t\t */\n+\t\t*/\n \n-\t\tPyArray_CopySwapFunc *copyswap[MAX_ARGS];\n+\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n \t\tPyArrayIterObject **iters=loop->iters;\n \t\tint *swap=loop->swap;\n \t\tvoid **dptr=loop->dptr;\n@@ -1268,7 +1280,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\tintp *steps = loop->steps;\n \t\t\n \t\tfor (i=0; inargs; i++) {\n-\t\t\tcopyswap[i] = mps[i]->descr->copyswap;\n+\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n \t\t\tmpselsize[i] = mps[i]->itemsize;\n \t\t}\n \t\t/* Do generic buffered looping here (works for any kind of\n@@ -1281,15 +1293,13 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t c. cast any output buffers needing it.\n \t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n-\t\t */ \n+\t\t*/ \n \t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/\n \t\twhile (index < size) {\n \t\t\t/*copy input data */\n \t\t\tfor (i=0; inin; i++) {\n-\t\t\t\tcopyswap[i](dptr[i],\n-\t\t\t\t\t iters[i]->dataptr,\n-\t\t\t\t\t swap[i],\n-\t\t\t\t\t mpselsize[i]);\n+\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n+\t\t\t\t mpselsize[i]);\n \t\t\t\tdptr[i] += mpselsize[i];\n \t\t\t}\n \t\t\tbufcnt++;\n@@ -1298,6 +1308,11 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t (index == size)) {\n \t\t\t\t\n \t\t\t\tfor (i=0; inin; i++) {\n+\t\t\t\t\tif (swap[i]) {\n+\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n+\t\t\t\t\t\t\t bufcnt, 1, \n+\t\t\t\t\t\t\t mpselsize[i]);\n+\t\t\t\t\t}\n \t\t\t\t\tif (loop->cast[i]) {\n \t\t\t\t\t\tloop->cast[i](buffer[i],\n \t\t\t\t\t\t\t castbuf[i],\n@@ -1310,21 +1325,23 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t\t\t &bufcnt, \n \t\t\t\t\t steps, loop->funcdata);\n \n-\n \t\t\t\tUFUNC_CHECK_ERROR();\n-\t\t\t\t\n+\n \t\t\t\tfor (i=self->nin; inargs; i++) {\n-\t\t\t\t\tif (loop->cast[i]) \n+\t\t\t\t\tif (loop->cast[i]) {\n \t\t\t\t\t\tloop->cast[i](castbuf[i],\n \t\t\t\t\t\t\t buffer[i],\n \t\t\t\t\t\t\t bufcnt,\n \t\t\t\t\t\t\t NULL, NULL);\n- \n+\t\t\t\t\t}\n+\t\t\t\t\tif (swap[i]) {\n+\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n+\t\t\t\t\t\t\t bufcnt, 1, \n+\t\t\t\t\t\t\t mpselsize[i]);\n+\t\t\t\t\t}\n \t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n-\t\t\t\t\t\tcopyswap[i](iters[i]->dataptr,\n-\t\t\t\t\t\t\t dptr[i],\n-\t\t\t\t\t\t\t swap[i],\n-\t\t\t\t\t\t\t mpselsize[i]);\n+\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n+\t\t\t\t\t\t dptr[i], mpselsize[i]);\n \t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n \t\t\t\t\t\tdptr[i] += mpselsize[i];\n \t\t\t\t\t}\n", "added_lines": 46, "deleted_lines": 29, "source_code": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\t\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n loop->iters[i] = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t\tcntcast += descr->elsize;\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\tcntcast += mps[i]->itemsize;\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time. \n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = loop->buffer[i];\n\t\t\t\t\n\t\t\t} \n\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t}\n\t}\n\t}\t\n\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[self->nin+i]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[self->nin+i]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[self->nin+i]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\t\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ibufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n loop->iters[i] = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t\tcntcast = descr->elsize;\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\tcntcast += mps[i]->itemsize;\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't use factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D) \n\t\t\t so don't worry about resetting it) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n#define _PyD PyArray_DescrFromType\n\t\t\t\t\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations: \n\t\t 1) move data better into and out of the buffers \n\t\t --- not one at a time. \n\t\t 2) don't call copyswap unless needed -- and\n\t\t call it on the data in the buffer using\n\t\t copyswapn.\n\t\t */\n\n\t\tPyArray_CopySwapFunc *copyswap[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswap[i] = mps[i]->descr->copyswap;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t */ \n\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tcopyswap[i](dptr[i],\n\t\t\t\t\t iters[i]->dataptr,\n\t\t\t\t\t swap[i],\n\t\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\n\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) \n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n \n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\tcopyswap[i](iters[i]->dataptr,\n\t\t\t\t\t\t\t dptr[i],\n\t\t\t\t\t\t\t swap[i],\n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = loop->buffer[i];\n\t\t\t\t\n\t\t\t} \n\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t}\n\t}\n\t}\t\n\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[self->nin+i]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[self->nin+i]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[self->nin+i]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "methods": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 213, "complexity": 51, "token_count": 1639, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1097, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 296, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1104, "end_line": 1153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 107, "complexity": 22, "token_count": 747, "parameters": [ "self", "args", "mps" ], "start_line": 1221, "end_line": 1372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 152, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1375, "end_line": 1395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1398, "end_line": 1420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1429, "end_line": 1658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1670, "end_line": 1799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1803, "end_line": 1933, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 1955, "end_line": 2082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2091, "end_line": 2201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2208, "end_line": 2260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 39, "complexity": 11, "token_count": 311, "parameters": [ "self", "args" ], "start_line": 2263, "end_line": 2317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2325, "end_line": 2394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2398, "end_line": 2429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2432, "end_line": 2473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2476, "end_line": 2488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2491, "end_line": 2503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2507, "end_line": 2513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2516, "end_line": 2523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2535, "end_line": 2604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2608, "end_line": 2612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2615, "end_line": 2619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2622, "end_line": 2625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2645, "end_line": 2667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2672, "end_line": 2755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2760, "end_line": 2763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 177, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 783, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 213, "complexity": 51, "token_count": 1646, "parameters": [ "loop", "args", "mps" ], "start_line": 786, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 297, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1089, "end_line": 1138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 100, "complexity": 20, "token_count": 699, "parameters": [ "self", "args", "mps" ], "start_line": 1206, "end_line": 1355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 150, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1358, "end_line": 1378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1381, "end_line": 1403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1412, "end_line": 1641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1653, "end_line": 1782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1786, "end_line": 1916, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 1938, "end_line": 2065, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2074, "end_line": 2184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2191, "end_line": 2243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 39, "complexity": 11, "token_count": 311, "parameters": [ "self", "args" ], "start_line": 2246, "end_line": 2300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2308, "end_line": 2377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2381, "end_line": 2412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2415, "end_line": 2456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2459, "end_line": 2471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2474, "end_line": 2486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2490, "end_line": 2496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2499, "end_line": 2506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2518, "end_line": 2587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2591, "end_line": 2595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2598, "end_line": 2602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2605, "end_line": 2608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2628, "end_line": 2650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2655, "end_line": 2738, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2743, "end_line": 2746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 213, "complexity": 51, "token_count": 1639, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1097, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 296, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 107, "complexity": 22, "token_count": 747, "parameters": [ "self", "args", "mps" ], "start_line": 1221, "end_line": 1372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 152, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 } ], "nloc": 2078, "complexity": 425, "token_count": 15204, "diff_parsed": { "added": [ "\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};", "\t\t/* if the type of mps[i] is equivalent to arg_types[i] */", "\t\t/* then set arg_types[i] equal to type of", "\t\t mps[i] for later checking....", "\t\t*/", "\t\tif (PyArray_TYPE(mps[i]) != arg_types[i]) {", "\t\t\tntype.type_num = PyArray_TYPE(mps[i]);", "\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);", "\t\t\tatype.type_num = arg_types[i];", "\t\t\tatype.itemsize = \\", "\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;", "\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {", "\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);", "\t\t\t}", "\t\t}", "\t\t\t\tntype.itemsize = 0;", "\t\t\t\tcntcast += descr->elsize;", "\t\t\t/* (won't fix factors because we", "\t\t\t don't use PyArray_ITER_GOTO1D", "\t\t\t so don't change them) */", "\t\tfor (i=0; inargs; i++) {", "\t\t\tif (loop->cast[i]) {", " /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/", "\t\t/* Optimizations needed:", "\t\t 1) move data better into the buffer better", "\t\t*/", "\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];", "\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;", "\t\t*/", "\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,", "\t\t\t\t mpselsize[i]);", "\t\t\t\t\tif (swap[i]) {", "\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,", "\t\t\t\t\t\t\t bufcnt, 1,", "\t\t\t\t\t\t\t mpselsize[i]);", "\t\t\t\t\t}", "", "\t\t\t\t\tif (loop->cast[i]) {", "\t\t\t\t\t}", "\t\t\t\t\tif (swap[i]) {", "\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,", "\t\t\t\t\t\t\t bufcnt, 1,", "\t\t\t\t\t\t\t mpselsize[i]);", "\t\t\t\t\t}", "\t\t\t\t\t\tmemcpy(iters[i]->dataptr,", "\t\t\t\t\t\t dptr[i], mpselsize[i]);" ], "deleted": [ "\t\t\t\tcntcast = descr->elsize;", "\t\t\t/* (won't use factors because we", "\t\t\t don't use PyArray_ITER_GOTO1D)", "\t\t\t so don't worry about resetting it) */", "\t\tfor (i=0; inumiter; i++) {", "\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {", "", " /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/", "\t\t/* Optimizations:", "\t\t 1) move data better into and out of the buffers", "\t\t 2) don't call copyswap unless needed -- and", "\t\t call it on the data in the buffer using", "\t\t copyswapn.", "\t\t */", "\t\tPyArray_CopySwapFunc *copyswap[MAX_ARGS];", "\t\t\tcopyswap[i] = mps[i]->descr->copyswap;", "\t\t */", "\t\t\t\tcopyswap[i](dptr[i],", "\t\t\t\t\t iters[i]->dataptr,", "\t\t\t\t\t swap[i],", "\t\t\t\t\t mpselsize[i]);", "", "", "\t\t\t\t\tif (loop->cast[i])", "", "\t\t\t\t\t\tcopyswap[i](iters[i]->dataptr,", "\t\t\t\t\t\t\t dptr[i],", "\t\t\t\t\t\t\t swap[i],", "\t\t\t\t\t\t\t mpselsize[i]);" ] } }, { "old_path": "scipy/base/tests/test_twodim_base.py", "new_path": "scipy/base/tests/test_twodim_base.py", "filename": "test_twodim_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -21,7 +21,7 @@ def get_mat(n):\n \n class test_eye(unittest.TestCase):\n def check_basic(self):\n- assert_equal(eye(4),array([[1,0,0,0],\n+\tassert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]]))\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Test functions for matrix module\n\n\"\"\"\n\nimport unittest\n\nimport sys\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\n##################################################\n\n\ndef get_mat(n):\n data = arange(n)\n data = add.outer(data,data)\n return data\n\nclass test_eye(unittest.TestCase):\n def check_basic(self):\n\tassert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]]))\n assert_equal(eye(4,dtype='f'),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]],'f'))\n def check_diag(self):\n assert_equal(eye(4,k=1),array([[0,1,0,0],\n [0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,k=-1),array([[0,0,0,0],\n [1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]]))\n def check_2d(self):\n assert_equal(eye(4,3),array([[1,0,0],\n [0,1,0],\n [0,0,1],\n [0,0,0]]))\n assert_equal(eye(3,4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]])) \n def check_diag2d(self):\n assert_equal(eye(3,4,k=2),array([[0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,3,k=-2),array([[0,0,0],\n [0,0,0],\n [1,0,0],\n [0,1,0]]))\n\nclass test_diag(unittest.TestCase):\n def check_vector(self):\n vals = (100*arange(5)).astype('l')\n b = zeros((5,5))\n for k in range(5):\n b[k,k] = vals[k]\n assert_equal(diag(vals),b)\n b = zeros((7,7))\n c = b.copy()\n for k in range(5):\n b[k,k+2] = vals[k]\n c[k+2,k] = vals[k]\n assert_equal(diag(vals,k=2), b)\n assert_equal(diag(vals,k=-2), c)\n\n def check_matrix(self):\n vals = (100*get_mat(5)+1).astype('l')\n b = zeros((5,))\n for k in range(5):\n b[k] = vals[k,k]\n assert_equal(diag(vals),b)\n b = b*0\n for k in range(3):\n b[k] = vals[k,k+2]\n assert_equal(diag(vals,2),b[:3])\n for k in range(3):\n b[k] = vals[k+2,k]\n assert_equal(diag(vals,-2),b[:3])\n\nclass test_fliplr(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, fliplr, ones(4))\n a = get_mat(4)\n b = a[:,::-1]\n assert_equal(fliplr(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[2,1,0],\n [5,4,3]]\n assert_equal(fliplr(a),b)\n\nclass test_flipud(unittest.TestCase):\n def check_basic(self):\n a = get_mat(4)\n b = a[::-1,:]\n assert_equal(flipud(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[3,4,5],\n [0,1,2]]\n assert_equal(flipud(a),b)\n\nclass test_rot90(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, rot90, ones(4))\n\n a = [[0,1,2],\n [3,4,5]]\n b1 = [[2,5],\n [1,4],\n [0,3]]\n b2 = [[5,4,3],\n [2,1,0]]\n b3 = [[3,0],\n [4,1],\n [5,2]]\n b4 = [[0,1,2],\n [3,4,5]]\n\n for k in range(-3,13,4):\n assert_equal(rot90(a,k=k),b1)\n for k in range(-2,13,4):\n assert_equal(rot90(a,k=k),b2)\n for k in range(-1,13,4):\n assert_equal(rot90(a,k=k),b3)\n for k in range(0,13,4):\n assert_equal(rot90(a,k=k),b4)\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.twodim_base').run()\n", "source_code_before": "\"\"\" Test functions for matrix module\n\n\"\"\"\n\nimport unittest\n\nimport sys\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\n##################################################\n\n\ndef get_mat(n):\n data = arange(n)\n data = add.outer(data,data)\n return data\n\nclass test_eye(unittest.TestCase):\n def check_basic(self):\n assert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]]))\n assert_equal(eye(4,dtype='f'),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]],'f'))\n def check_diag(self):\n assert_equal(eye(4,k=1),array([[0,1,0,0],\n [0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,k=-1),array([[0,0,0,0],\n [1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]]))\n def check_2d(self):\n assert_equal(eye(4,3),array([[1,0,0],\n [0,1,0],\n [0,0,1],\n [0,0,0]]))\n assert_equal(eye(3,4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]])) \n def check_diag2d(self):\n assert_equal(eye(3,4,k=2),array([[0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,3,k=-2),array([[0,0,0],\n [0,0,0],\n [1,0,0],\n [0,1,0]]))\n\nclass test_diag(unittest.TestCase):\n def check_vector(self):\n vals = (100*arange(5)).astype('l')\n b = zeros((5,5))\n for k in range(5):\n b[k,k] = vals[k]\n assert_equal(diag(vals),b)\n b = zeros((7,7))\n c = b.copy()\n for k in range(5):\n b[k,k+2] = vals[k]\n c[k+2,k] = vals[k]\n assert_equal(diag(vals,k=2), b)\n assert_equal(diag(vals,k=-2), c)\n\n def check_matrix(self):\n vals = (100*get_mat(5)+1).astype('l')\n b = zeros((5,))\n for k in range(5):\n b[k] = vals[k,k]\n assert_equal(diag(vals),b)\n b = b*0\n for k in range(3):\n b[k] = vals[k,k+2]\n assert_equal(diag(vals,2),b[:3])\n for k in range(3):\n b[k] = vals[k+2,k]\n assert_equal(diag(vals,-2),b[:3])\n\nclass test_fliplr(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, fliplr, ones(4))\n a = get_mat(4)\n b = a[:,::-1]\n assert_equal(fliplr(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[2,1,0],\n [5,4,3]]\n assert_equal(fliplr(a),b)\n\nclass test_flipud(unittest.TestCase):\n def check_basic(self):\n a = get_mat(4)\n b = a[::-1,:]\n assert_equal(flipud(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[3,4,5],\n [0,1,2]]\n assert_equal(flipud(a),b)\n\nclass test_rot90(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, rot90, ones(4))\n\n a = [[0,1,2],\n [3,4,5]]\n b1 = [[2,5],\n [1,4],\n [0,3]]\n b2 = [[5,4,3],\n [2,1,0]]\n b3 = [[3,0],\n [4,1],\n [5,2]]\n b4 = [[0,1,2],\n [3,4,5]]\n\n for k in range(-3,13,4):\n assert_equal(rot90(a,k=k),b1)\n for k in range(-2,13,4):\n assert_equal(rot90(a,k=k),b2)\n for k in range(-1,13,4):\n assert_equal(rot90(a,k=k),b3)\n for k in range(0,13,4):\n assert_equal(rot90(a,k=k),b4)\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.twodim_base').run()\n", "methods": [ { "name": "get_mat", "long_name": "get_mat( n )", "filename": "test_twodim_base.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "n" ], "start_line": 17, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 9, "complexity": 1, "token_count": 115, "parameters": [ "self" ], "start_line": 23, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_diag", "long_name": "check_diag( self )", "filename": "test_twodim_base.py", "nloc": 9, "complexity": 1, "token_count": 118, "parameters": [ "self" ], "start_line": 32, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_2d", "long_name": "check_2d( self )", "filename": "test_twodim_base.py", "nloc": 8, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 41, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_diag2d", "long_name": "check_diag2d( self )", "filename": "test_twodim_base.py", "nloc": 8, "complexity": 1, "token_count": 104, "parameters": [ "self" ], "start_line": 49, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_vector", "long_name": "check_vector( self )", "filename": "test_twodim_base.py", "nloc": 13, "complexity": 3, "token_count": 136, "parameters": [ "self" ], "start_line": 59, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_matrix", "long_name": "check_matrix( self )", "filename": "test_twodim_base.py", "nloc": 13, "complexity": 4, "token_count": 137, "parameters": [ "self" ], "start_line": 73, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 10, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 88, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 9, "complexity": 1, "token_count": 77, "parameters": [ "self" ], "start_line": 100, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 22, "complexity": 5, "token_count": 220, "parameters": [ "self" ], "start_line": 111, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_mat", "long_name": "get_mat( n )", "filename": "test_twodim_base.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "n" ], "start_line": 17, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 9, "complexity": 1, "token_count": 115, "parameters": [ "self" ], "start_line": 23, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_diag", "long_name": "check_diag( self )", "filename": "test_twodim_base.py", "nloc": 9, "complexity": 1, "token_count": 118, "parameters": [ "self" ], "start_line": 32, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_2d", "long_name": "check_2d( self )", "filename": "test_twodim_base.py", "nloc": 8, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 41, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_diag2d", "long_name": "check_diag2d( self )", "filename": "test_twodim_base.py", "nloc": 8, "complexity": 1, "token_count": 104, "parameters": [ "self" ], "start_line": 49, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_vector", "long_name": "check_vector( self )", "filename": "test_twodim_base.py", "nloc": 13, "complexity": 3, "token_count": 136, "parameters": [ "self" ], "start_line": 59, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_matrix", "long_name": "check_matrix( self )", "filename": "test_twodim_base.py", "nloc": 13, "complexity": 4, "token_count": 137, "parameters": [ "self" ], "start_line": 73, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 10, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 88, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 9, "complexity": 1, "token_count": 77, "parameters": [ "self" ], "start_line": 100, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 22, "complexity": 5, "token_count": 220, "parameters": [ "self" ], "start_line": 111, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_twodim_base.py", "nloc": 9, "complexity": 1, "token_count": 115, "parameters": [ "self" ], "start_line": 23, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": 122, "complexity": 19, "token_count": 1218, "diff_parsed": { "added": [ "\tassert_equal(eye(4),array([[1,0,0,0]," ], "deleted": [ " assert_equal(eye(4),array([[1,0,0,0]," ] } } ] }, { "hash": "e3a57787b921f94f1303dae82405aec54d5ef41f", "msg": "Added feature that output arrays less than bufsize make temporaries...", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-05T10:35:21+00:00", "author_timezone": 0, "committer_date": "2005-10-05T10:35:21+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c3a9fe713e0009461e85a4dc989f7f86e14178fe" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 10, "insertions": 75, "lines": 85, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.14285714285714285, "modified_files": [ { "old_path": "scipy/base/src/arrayobject.c", "new_path": "scipy/base/src/arrayobject.c", "filename": "arrayobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -1164,8 +1164,10 @@ array_dealloc(PyArrayObject *self) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n \t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n+\t\t\t/* Don't need to DECREF -- because we are deleting\n+\t\t\t self already... */\n \t\t}\n-\t\t/* Other wise base is pointing to something that we need\n+\t\t/* In any case base is pointing to something that we need\n \t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n@@ -4905,6 +4907,7 @@ array_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags)\n \tint copy = 0;\n \tint arrflags;\n \tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n+\tchar *msg = \"Cannot copy-back to a read-only array.\";\n \t\n \tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n \tif (itemsize == 0) itemsize = arr->itemsize;\n@@ -4927,9 +4930,7 @@ array_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags)\n \t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n- PyErr_SetString(PyExc_ValueError,\n- \"Cannot copy-back to a read-\"\\\n- \"only array.\");\n+ PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n \t\t\tret = (PyArrayObject *)\\\n@@ -4965,8 +4966,19 @@ array_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags)\n \t\t behavior with Python scalars */\n \t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n \t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n+ if ((flags & UPDATEIFCOPY) && \\\n+ (!PyArray_ISWRITEABLE(arr))) {\n+ PyErr_SetString(PyExc_ValueError, msg);\n+ return NULL;\n+ }\n \t\t\tret = (PyArrayObject *)\\\n \t\t\t\tPyArray_CastToType(arr, typecode);\n+\t\t\tif (flags & UPDATEIFCOPY) {\n+\t\t\t\tret->flags |= UPDATEIFCOPY;\n+\t\t\t\tret->base = (PyObject *)arr;\n+ PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n+\t\t\t\tPy_INCREF(arr);\n+\t\t\t}\n \t\t}\n \t\telse {\n \t\t\tPyErr_SetString(PyExc_TypeError, \n", "added_lines": 16, "deleted_lines": 4, "source_code": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic int\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\tchar *msg = \"Cannot copy-back to a read-only array.\";\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "source_code_before": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic int\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t}\n\t\t/* Other wise base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError,\n \"Cannot copy-back to a read-\"\\\n \"only array.\");\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "methods": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1194, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1206, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1240, "end_line": 1270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1274, "end_line": 1282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1288, "end_line": 1338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1345, "end_line": 1390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1394, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1492, "end_line": 1526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1531, "end_line": 1581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1584, "end_line": 1643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 10, "token_count": 307, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1735, "end_line": 1787, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1795, "end_line": 1798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1817, "end_line": 1829, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1832, "end_line": 1847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1851, "end_line": 1860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1863, "end_line": 1874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1942, "end_line": 1975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1981, "end_line": 2020, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2023, "end_line": 2042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2046, "end_line": 2065, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2069, "end_line": 2080, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2083, "end_line": 2094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2097, "end_line": 2109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2112, "end_line": 2115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2118, "end_line": 2121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2124, "end_line": 2127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2130, "end_line": 2133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2136, "end_line": 2139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2142, "end_line": 2145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2148, "end_line": 2151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2154, "end_line": 2157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2160, "end_line": 2163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2166, "end_line": 2169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2172, "end_line": 2175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2178, "end_line": 2181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2184, "end_line": 2187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2190, "end_line": 2193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2196, "end_line": 2199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2202, "end_line": 2205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2208, "end_line": 2211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2214, "end_line": 2217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2220, "end_line": 2223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2226, "end_line": 2229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2232, "end_line": 2235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2238, "end_line": 2241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2244, "end_line": 2247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2250, "end_line": 2253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2256, "end_line": 2259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2262, "end_line": 2265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2268, "end_line": 2271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2274, "end_line": 2278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2281, "end_line": 2285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2289, "end_line": 2307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2310, "end_line": 2325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2329, "end_line": 2355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2358, "end_line": 2383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2386, "end_line": 2408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2411, "end_line": 2433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2436, "end_line": 2458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2461, "end_line": 2465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2526, "end_line": 2564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2568, "end_line": 2589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2592, "end_line": 2597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2618, "end_line": 2665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2668, "end_line": 2704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2710, "end_line": 2727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2730, "end_line": 2742, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2745, "end_line": 2757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2761, "end_line": 2838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2841, "end_line": 2870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2876, "end_line": 2892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2897, "end_line": 2920, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2926, "end_line": 2942, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2946, "end_line": 2962, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2966, "end_line": 2982, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2985, "end_line": 3018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3022, "end_line": 3044, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3051, "end_line": 3066, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3086, "end_line": 3110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3114, "end_line": 3258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3263, "end_line": 3368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3372, "end_line": 3389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3393, "end_line": 3508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3515, "end_line": 3518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3521, "end_line": 3531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3604, "end_line": 3607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3611, "end_line": 3645, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3649, "end_line": 3652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3655, "end_line": 3688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3692, "end_line": 3699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3702, "end_line": 3710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3714, "end_line": 3728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3731, "end_line": 3775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3779, "end_line": 3782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3785, "end_line": 3792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3796, "end_line": 3803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3806, "end_line": 3826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3829, "end_line": 3851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3854, "end_line": 3857, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3861, "end_line": 3864, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3876, "end_line": 3934, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3939, "end_line": 3949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3953, "end_line": 3978, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3982, "end_line": 4014, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4017, "end_line": 4050, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4053, "end_line": 4090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4093, "end_line": 4096, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4099, "end_line": 4151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4327, "end_line": 4352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4355, "end_line": 4377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4384, "end_line": 4410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4413, "end_line": 4433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 118, "complexity": 27, "token_count": 637, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4436, "end_line": 4569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4572, "end_line": 4595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4599, "end_line": 4622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4626, "end_line": 4683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4687, "end_line": 4694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4700, "end_line": 4790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4796, "end_line": 4807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4810, "end_line": 4845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4852, "end_line": 4898, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4901, "end_line": 4991, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 4995, "end_line": 5100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5103, "end_line": 5197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5200, "end_line": 5221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5225, "end_line": 5287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5290, "end_line": 5295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5298, "end_line": 5304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5358, "end_line": 5388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5398, "end_line": 5414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5420, "end_line": 5425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5428, "end_line": 5434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5437, "end_line": 5443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5449, "end_line": 5520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5523, "end_line": 5547, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5557, "end_line": 5594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5599, "end_line": 5609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5612, "end_line": 5617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5620, "end_line": 5625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5629, "end_line": 5632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5636, "end_line": 5684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5687, "end_line": 5739, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5743, "end_line": 5862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5866, "end_line": 5898, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5901, "end_line": 5942, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5946, "end_line": 6068, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6081, "end_line": 6122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6127, "end_line": 6131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6196, "end_line": 6257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6265, "end_line": 6280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6286, "end_line": 6355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6359, "end_line": 6395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6401, "end_line": 6445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6463, "end_line": 6599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6605, "end_line": 6674, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6677, "end_line": 6810, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6816, "end_line": 6846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6852, "end_line": 6863, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6866, "end_line": 6875, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6878, "end_line": 6896, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1192, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1204, "end_line": 1228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1231, "end_line": 1234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1238, "end_line": 1268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1272, "end_line": 1280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1286, "end_line": 1336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1343, "end_line": 1388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1392, "end_line": 1487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1490, "end_line": 1524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1529, "end_line": 1579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1582, "end_line": 1641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 10, "token_count": 307, "parameters": [ "self", "op" ], "start_line": 1662, "end_line": 1720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1733, "end_line": 1785, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1793, "end_line": 1796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1815, "end_line": 1827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1830, "end_line": 1845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1849, "end_line": 1858, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1861, "end_line": 1872, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1940, "end_line": 1973, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1979, "end_line": 2018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2021, "end_line": 2040, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2044, "end_line": 2063, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2067, "end_line": 2078, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2081, "end_line": 2092, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2095, "end_line": 2107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2110, "end_line": 2113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2116, "end_line": 2119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2122, "end_line": 2125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2128, "end_line": 2131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2134, "end_line": 2137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2140, "end_line": 2143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2146, "end_line": 2149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2152, "end_line": 2155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2158, "end_line": 2161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2164, "end_line": 2167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2170, "end_line": 2173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2176, "end_line": 2179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2182, "end_line": 2185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2188, "end_line": 2191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2194, "end_line": 2197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2200, "end_line": 2203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2206, "end_line": 2209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2212, "end_line": 2215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2218, "end_line": 2221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2224, "end_line": 2227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2230, "end_line": 2233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2236, "end_line": 2239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2242, "end_line": 2245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2248, "end_line": 2251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2254, "end_line": 2257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2260, "end_line": 2263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2266, "end_line": 2269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2272, "end_line": 2276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2279, "end_line": 2283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2287, "end_line": 2305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2308, "end_line": 2323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2327, "end_line": 2353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2356, "end_line": 2381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2384, "end_line": 2406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2409, "end_line": 2431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2434, "end_line": 2456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2459, "end_line": 2463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2524, "end_line": 2562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2566, "end_line": 2587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2590, "end_line": 2595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2616, "end_line": 2663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2666, "end_line": 2702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2708, "end_line": 2725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2728, "end_line": 2740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2743, "end_line": 2755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2759, "end_line": 2836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2839, "end_line": 2868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2874, "end_line": 2890, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2895, "end_line": 2918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2924, "end_line": 2940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2944, "end_line": 2960, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2964, "end_line": 2980, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2983, "end_line": 3016, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3020, "end_line": 3042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3049, "end_line": 3064, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3084, "end_line": 3108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3112, "end_line": 3256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3261, "end_line": 3366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3370, "end_line": 3387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3391, "end_line": 3506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3513, "end_line": 3516, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3519, "end_line": 3529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3602, "end_line": 3605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3609, "end_line": 3643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3647, "end_line": 3650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3653, "end_line": 3686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3690, "end_line": 3697, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3700, "end_line": 3708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3712, "end_line": 3726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3729, "end_line": 3773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3777, "end_line": 3780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3783, "end_line": 3790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3794, "end_line": 3801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3804, "end_line": 3824, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3827, "end_line": 3849, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3852, "end_line": 3855, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3859, "end_line": 3862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3874, "end_line": 3932, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3937, "end_line": 3947, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3951, "end_line": 3976, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3980, "end_line": 4012, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4015, "end_line": 4048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4051, "end_line": 4088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4091, "end_line": 4094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4097, "end_line": 4149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4325, "end_line": 4350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4353, "end_line": 4375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4382, "end_line": 4408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4411, "end_line": 4431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 118, "complexity": 27, "token_count": 637, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4434, "end_line": 4567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4570, "end_line": 4593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4597, "end_line": 4620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4624, "end_line": 4681, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4685, "end_line": 4692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4698, "end_line": 4788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4794, "end_line": 4805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4808, "end_line": 4843, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4850, "end_line": 4896, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 67, "complexity": 23, "token_count": 437, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4899, "end_line": 4979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 4983, "end_line": 5088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5091, "end_line": 5185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5188, "end_line": 5209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5213, "end_line": 5275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5278, "end_line": 5283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5286, "end_line": 5292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5346, "end_line": 5376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5386, "end_line": 5402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5408, "end_line": 5413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5416, "end_line": 5422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5425, "end_line": 5431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5437, "end_line": 5508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5511, "end_line": 5535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5545, "end_line": 5582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5587, "end_line": 5597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5600, "end_line": 5605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5608, "end_line": 5613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5617, "end_line": 5620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5624, "end_line": 5672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5675, "end_line": 5727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5731, "end_line": 5850, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5854, "end_line": 5886, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5889, "end_line": 5930, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5934, "end_line": 6056, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6069, "end_line": 6110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6115, "end_line": 6119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6184, "end_line": 6245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6253, "end_line": 6268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6274, "end_line": 6343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6347, "end_line": 6383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6389, "end_line": 6433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6451, "end_line": 6587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6593, "end_line": 6662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6665, "end_line": 6798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6804, "end_line": 6834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6840, "end_line": 6851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6854, "end_line": 6863, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6866, "end_line": 6884, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4901, "end_line": 4991, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 } ], "nloc": 5452, "complexity": 1194, "token_count": 32568, "diff_parsed": { "added": [ "\t\t\t/* Don't need to DECREF -- because we are deleting", "\t\t\t self already... */", "\t\t/* In any case base is pointing to something that we need", "\tchar *msg = \"Cannot copy-back to a read-only array.\";", " PyErr_SetString(PyExc_ValueError, msg);", " if ((flags & UPDATEIFCOPY) && \\", " (!PyArray_ISWRITEABLE(arr))) {", " PyErr_SetString(PyExc_ValueError, msg);", " return NULL;", " }", "\t\t\tif (flags & UPDATEIFCOPY) {", "\t\t\t\tret->flags |= UPDATEIFCOPY;", "\t\t\t\tret->base = (PyObject *)arr;", " PyArray_FLAGS(ret->base) &= ~WRITEABLE;", "\t\t\t\tPy_INCREF(arr);", "\t\t\t}" ], "deleted": [ "\t\t/* Other wise base is pointing to something that we need", " PyErr_SetString(PyExc_ValueError,", " \"Cannot copy-back to a read-\"\\", " \"only array.\");" ] } }, { "old_path": "scipy/base/src/ufuncobject.c", "new_path": "scipy/base/src/ufuncobject.c", "filename": "ufuncobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -678,7 +678,7 @@ select_types(PyUFuncObject *self, int *arg_types,\n \n \t*data = self->data[i];\n \t*function = self->functions[i];\n-\t\n+\n \treturn 0;\n }\n \n@@ -908,6 +908,7 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \t\t\t\tPyErr_SetString(PyExc_TypeError, \n \t\t\t\t\t\t\"return arrays must be \"\\\n \t\t\t\t\t\t\"of ArrayType\");\n+\t\t\t\tPy_DECREF(mps[i]);\n \t\t\t\treturn -1;\n \t\t\t}\n }\n@@ -915,11 +916,13 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n+\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n+\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n@@ -927,6 +930,8 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n+\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n+\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n@@ -937,9 +942,46 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n if (mps[i] == NULL) return -1;\n }\n \n- loop->iters[i] = (PyArrayIterObject *)\\\n+\t\t/* reset types for outputs that are equivalent \n+\t\t -- no sense casting uselessly\n+\t\t*/\n+\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n+\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n+\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n+\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n+\t\t\tatype.type_num = arg_types[i];\n+\t\t\tatype.itemsize = \\\n+\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n+\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n+\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n+\t\t\t}\t\t\t\n+\t\t}\n+\n+\t\t/* still not the same -- or will we have to use buffers?*/\n+\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n+\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n+\t\t\tif (loop->size < loop->bufsize) {\n+\t\t\t\tPyObject *new;\n+\t\t\t\t/* Copy the array to a temporary copy \n+\t\t\t\t and set the UPDATEIFCOPY flag\n+\t\t\t\t*/\n+\t\t\t\tntype.type_num = arg_types[i];\n+\t\t\t\tntype.itemsize = 0;\n+\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n+\t\t\t\t\t\t &ntype, 0, 0,\n+\t\t\t\t\t\t FORCECAST | \n+\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n+\t\t\t\t\t\t UPDATEIFCOPY);\n+\t\t\t\tif (new == NULL) return -1;\n+\t\t\t\tPy_DECREF(mps[i]);\n+\t\t\t\tmps[i] = (PyArrayObject *)new;\n+\t\t\t}\n+\t\t}\n+\n+ loop->iters[i] = (PyArrayIterObject *)\t\t\\\n \t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n+\t\t\n }\n \n \n@@ -1294,7 +1336,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n \t\t*/ \n-\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/\n+\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n \t\twhile (index < size) {\n \t\t\t/*copy input data */\n \t\t\tfor (i=0; inin; i++) {\n@@ -2290,18 +2332,29 @@ ufunc_generic_call(PyUFuncObject *self, PyObject *args)\n \t\n \t/* wrap outputs */\n \tfor (i=0; inout; i++) {\n+\t\tint j=self->nin+i;\n+\t\t/* check to see if any UPDATEIFCOPY flags are set \n+\t\t which meant that a temporary output was generated \n+\t\t*/\n+\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n+\t\t\tPyObject *old = mps[j]->base;\n+\t\t\tPy_INCREF(old); /* we want to hang on to this */\n+\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n+\t\t\t\t\t back into old */\n+\t\t\tmps[j] = (PyArrayObject *)old;\n+\t\t}\n \t\tif (obj != NULL) {\n \t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n-\t\t\t\t\t\t \"O\", mps[self->nin+i]);\n+\t\t\t\t\t\t \"O\", mps[j]);\n \t\t\tif (res == NULL) PyErr_Clear();\n \t\t\telse if (res == Py_None) Py_DECREF(res);\n \t\t\telse {\n-\t\t\t\tPy_DECREF(mps[self->nin+i]);\n+\t\t\t\tPy_DECREF(mps[j]);\n \t\t\t\tretobj[i] = res;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n-\t\tretobj[i] = PyArray_Return(mps[self->nin+i]);\n+\t\tretobj[i] = PyArray_Return(mps[j]);\n \t}\n \t\n \tif (self->nout == 1) { \n", "added_lines": 59, "deleted_lines": 6, "source_code": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n\t\t\tatype.type_num = arg_types[i];\n\t\t\tatype.itemsize = \\\n\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\t\t\t\n\t\t}\n\n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\tif (loop->size < loop->bufsize) {\n\t\t\t\tPyObject *new;\n\t\t\t\t/* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t*/\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | \n\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n\t\t\t\t\t\t UPDATEIFCOPY);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t\t\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t\tcntcast += descr->elsize;\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\tcntcast += mps[i]->itemsize;\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time. \n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = loop->buffer[i];\n\t\t\t\t\n\t\t\t} \n\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t}\n\t}\n\t}\t\n\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\t\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n loop->iters[i] = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t\tcntcast += descr->elsize;\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\tcntcast += mps[i]->itemsize;\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time. \n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = loop->buffer[i];\n\t\t\t\t\n\t\t\t} \n\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t}\n\t}\n\t}\t\n\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[self->nin+i]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[self->nin+i]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[self->nin+i]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "methods": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 244, "complexity": 57, "token_count": 1891, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 338, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1146, "end_line": 1195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 22, "token_count": 758, "parameters": [ "self", "args", "mps" ], "start_line": 1263, "end_line": 1414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 152, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1417, "end_line": 1437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1440, "end_line": 1462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1471, "end_line": 1700, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1712, "end_line": 1841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1845, "end_line": 1975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 1997, "end_line": 2124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2133, "end_line": 2243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2250, "end_line": 2302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2305, "end_line": 2370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2378, "end_line": 2447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2451, "end_line": 2482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2485, "end_line": 2526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2529, "end_line": 2541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2544, "end_line": 2556, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2560, "end_line": 2566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2569, "end_line": 2576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2588, "end_line": 2657, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2661, "end_line": 2665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2668, "end_line": 2672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2675, "end_line": 2678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2698, "end_line": 2720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2725, "end_line": 2808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2813, "end_line": 2816, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 213, "complexity": 51, "token_count": 1639, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1097, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 296, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1104, "end_line": 1153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 107, "complexity": 22, "token_count": 747, "parameters": [ "self", "args", "mps" ], "start_line": 1221, "end_line": 1372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 152, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1375, "end_line": 1395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1398, "end_line": 1420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1429, "end_line": 1658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1670, "end_line": 1799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1803, "end_line": 1933, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 1955, "end_line": 2082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2091, "end_line": 2201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2208, "end_line": 2260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 39, "complexity": 11, "token_count": 311, "parameters": [ "self", "args" ], "start_line": 2263, "end_line": 2317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2325, "end_line": 2394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2398, "end_line": 2429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2432, "end_line": 2473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2476, "end_line": 2488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2491, "end_line": 2503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2507, "end_line": 2513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2516, "end_line": 2523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2535, "end_line": 2604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2608, "end_line": 2612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2615, "end_line": 2619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2622, "end_line": 2625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2645, "end_line": 2667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2672, "end_line": 2755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2760, "end_line": 2763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 244, "complexity": 57, "token_count": 1891, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 338, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2305, "end_line": 2370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 22, "token_count": 758, "parameters": [ "self", "args", "mps" ], "start_line": 1263, "end_line": 1414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 152, "top_nesting_level": 0 } ], "nloc": 2117, "complexity": 432, "token_count": 15512, "diff_parsed": { "added": [ "", "\t\t\t\tPy_DECREF(mps[i]);", "\t\t\tPy_DECREF(mps[i]);", "\t\t\tPy_DECREF(mps[i]);", "\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};", "", "\t\t/* reset types for outputs that are equivalent", "\t\t -- no sense casting uselessly", "\t\t*/", "\t\tif (mps[i]->descr->type_num != arg_types[i]) {", "\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};", "\t\t\tntype.type_num = PyArray_TYPE(mps[i]);", "\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);", "\t\t\tatype.type_num = arg_types[i];", "\t\t\tatype.itemsize = \\", "\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;", "\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {", "\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);", "\t\t\t}", "\t\t}", "", "\t\t/* still not the same -- or will we have to use buffers?*/", "\t\tif (mps[i]->descr->type_num != arg_types[i] ||", "\t\t !PyArray_ISBEHAVED_RO(mps[i])) {", "\t\t\tif (loop->size < loop->bufsize) {", "\t\t\t\tPyObject *new;", "\t\t\t\t/* Copy the array to a temporary copy", "\t\t\t\t and set the UPDATEIFCOPY flag", "\t\t\t\t*/", "\t\t\t\tntype.type_num = arg_types[i];", "\t\t\t\tntype.itemsize = 0;", "\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i],", "\t\t\t\t\t\t &ntype, 0, 0,", "\t\t\t\t\t\t FORCECAST |", "\t\t\t\t\t\t BEHAVED_FLAGS_RO |", "\t\t\t\t\t\t UPDATEIFCOPY);", "\t\t\t\tif (new == NULL) return -1;", "\t\t\t\tPy_DECREF(mps[i]);", "\t\t\t\tmps[i] = (PyArrayObject *)new;", "\t\t\t}", "\t\t}", "", " loop->iters[i] = (PyArrayIterObject *)\t\t\\", "", "\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);", "\t\tint j=self->nin+i;", "\t\t/* check to see if any UPDATEIFCOPY flags are set", "\t\t which meant that a temporary output was generated", "\t\t*/", "\t\tif (mps[j]->flags & UPDATEIFCOPY) {", "\t\t\tPyObject *old = mps[j]->base;", "\t\t\tPy_INCREF(old); /* we want to hang on to this */", "\t\t\tPy_DECREF(mps[j]); /* should trigger the copy", "\t\t\t\t\t back into old */", "\t\t\tmps[j] = (PyArrayObject *)old;", "\t\t}", "\t\t\t\t\t\t \"O\", mps[j]);", "\t\t\t\tPy_DECREF(mps[j]);", "\t\tretobj[i] = PyArray_Return(mps[j]);" ], "deleted": [ "", " loop->iters[i] = (PyArrayIterObject *)\\", "\t\t/* fprintf(stderr, \"BUFFER...%d\\n\", loop->size);*/", "\t\t\t\t\t\t \"O\", mps[self->nin+i]);", "\t\t\t\tPy_DECREF(mps[self->nin+i]);", "\t\tretobj[i] = PyArray_Return(mps[self->nin+i]);" ] } } ] }, { "hash": "b3b692136487acd9f39e33b8d8f584a2c5383d02", "msg": "r88@Blasphemy: kern | 2005-10-04 07:03:42 -0700\n Some fixes to code and tests", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-05T11:13:17+00:00", "author_timezone": 0, "committer_date": "2005-10-05T11:13:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e3a57787b921f94f1303dae82405aec54d5ef41f" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 15, "insertions": 25, "lines": 40, "files": 4, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy/base/tests/test_shape_base.py", "new_path": "scipy/base/tests/test_shape_base.py", "filename": "test_shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,15 +8,15 @@\n from scipy.base import *\n restore_path()\n \n-class test_apply_along_axis(ScipyTestCase):\n- def check_simple(self):\n- a = ones((20,10),'d')\n- assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n- def check_simple101(self,level=11):\n- # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n- # when enabled and shape(a)[1]>100. See Issue 202.\n- a = ones((10,101),'d')\n- assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n+#class test_apply_along_axis(ScipyTestCase):\n+# def check_simple(self):\n+# a = ones((20,10),'d')\n+# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n+# def check_simple101(self,level=11):\n+# # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n+# # when enabled and shape(a)[1]>100. See Issue 202.\n+# a = ones((10,101),'d')\n+# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n \n class test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n", "added_lines": 9, "deleted_lines": 9, "source_code": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base; reload(scipy.base)\nreload(scipy.base.shape_base)\nfrom scipy.base import *\nrestore_path()\n\n#class test_apply_along_axis(ScipyTestCase):\n# def check_simple(self):\n# a = ones((20,10),'d')\n# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n# def check_simple101(self,level=11):\n# # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n# # when enabled and shape(a)[1]>100. See Issue 202.\n# a = ones((10,101),'d')\n# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n\nclass test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(unittest.TestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(unittest.TestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.shape_base').run()\n", "source_code_before": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base; reload(scipy.base)\nreload(scipy.base.shape_base)\nfrom scipy.base import *\nrestore_path()\n\nclass test_apply_along_axis(ScipyTestCase):\n def check_simple(self):\n a = ones((20,10),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n def check_simple101(self,level=11):\n # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n # when enabled and shape(a)[1]>100. See Issue 202.\n a = ones((10,101),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n\nclass test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(unittest.TestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(unittest.TestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.shape_base').run()\n", "methods": [ { "name": "check_integer_0_split", "long_name": "check_integer_0_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 22, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split", "long_name": "check_integer_split( self )", "filename": "test_shape_base.py", "nloc": 43, "complexity": 1, "token_count": 637, "parameters": [ "self" ], "start_line": 29, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_rows", "long_name": "check_integer_split_2D_rows( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_cols", "long_name": "check_integer_split_2D_cols( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 96, "parameters": [ "self" ], "start_line": 87, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_default", "long_name": "check_integer_split_2D_default( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 65, "parameters": [ "self" ], "start_line": 94, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_index_split_simple", "long_name": "check_index_split_simple( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_low_bound", "long_name": "check_index_split_low_bound( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_high_bound", "long_name": "check_index_split_high_bound( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 116, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_equal_split", "long_name": "check_equal_split( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_unequal_split", "long_name": "check_unequal_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 135, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 159, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r1array", "long_name": "check_r1array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 175, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 185, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 190, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r2array", "long_name": "check_r2array( self )", "filename": "test_shape_base.py", "nloc": 4, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 62, "parameters": [ "self" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 209, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 214, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 232, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 244, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 249, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 254, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 259, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 266, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 271, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 276, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 281, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 300, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 305, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 315, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 332, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 9, "complexity": 1, "token_count": 138, "parameters": [ "self" ], "start_line": 340, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 103, "parameters": [ "self" ], "start_line": 351, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 12, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_simple101", "long_name": "check_simple101( self , level = 11 )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 48, "parameters": [ "self", "level" ], "start_line": 15, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_0_split", "long_name": "check_integer_0_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 22, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split", "long_name": "check_integer_split( self )", "filename": "test_shape_base.py", "nloc": 43, "complexity": 1, "token_count": 637, "parameters": [ "self" ], "start_line": 29, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_rows", "long_name": "check_integer_split_2D_rows( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_cols", "long_name": "check_integer_split_2D_cols( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 96, "parameters": [ "self" ], "start_line": 87, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_default", "long_name": "check_integer_split_2D_default( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 65, "parameters": [ "self" ], "start_line": 94, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_index_split_simple", "long_name": "check_index_split_simple( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_low_bound", "long_name": "check_index_split_low_bound( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_high_bound", "long_name": "check_index_split_high_bound( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 116, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_equal_split", "long_name": "check_equal_split( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_unequal_split", "long_name": "check_unequal_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 135, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 159, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r1array", "long_name": "check_r1array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 175, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 185, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 190, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r2array", "long_name": "check_r2array( self )", "filename": "test_shape_base.py", "nloc": 4, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 62, "parameters": [ "self" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 209, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 214, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 232, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 244, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 249, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 254, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 259, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 266, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 271, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 276, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 281, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 300, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 305, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 315, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 332, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 9, "complexity": 1, "token_count": 138, "parameters": [ "self" ], "start_line": 340, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 103, "parameters": [ "self" ], "start_line": 351, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 12, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_simple101", "long_name": "check_simple101( self , level = 11 )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 48, "parameters": [ "self", "level" ], "start_line": 15, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 319, "complexity": 50, "token_count": 3673, "diff_parsed": { "added": [ "#class test_apply_along_axis(ScipyTestCase):", "# def check_simple(self):", "# a = ones((20,10),'d')", "# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))", "# def check_simple101(self,level=11):", "# # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)", "# # when enabled and shape(a)[1]>100. See Issue 202.", "# a = ones((10,101),'d')", "# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))" ], "deleted": [ "class test_apply_along_axis(ScipyTestCase):", " def check_simple(self):", " a = ones((20,10),'d')", " assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))", " def check_simple101(self,level=11):", " # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)", " # when enabled and shape(a)[1]>100. See Issue 202.", " a = ones((10,101),'d')", " assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))" ] } }, { "old_path": "scipy/base/tests/test_type_check.py", "new_path": "scipy/base/tests/test_type_check.py", "filename": "test_type_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -33,11 +33,11 @@ def check_default_2(self):\n assert_equal(mintypecode('fD'),'D')\n assert_equal(mintypecode('df'),'d')\n assert_equal(mintypecode('dd'),'d')\n- assert_equal(mintypecode('dF',savespace=1),'F')\n+ #assert_equal(mintypecode('dF',savespace=1),'F')\n assert_equal(mintypecode('dF'),'D')\n assert_equal(mintypecode('dD'),'D')\n assert_equal(mintypecode('Ff'),'F')\n- assert_equal(mintypecode('Fd',savespace=1),'F')\n+ #assert_equal(mintypecode('Fd',savespace=1),'F')\n assert_equal(mintypecode('Fd'),'D')\n assert_equal(mintypecode('FF'),'F')\n assert_equal(mintypecode('FD'),'D')\n@@ -48,7 +48,7 @@ def check_default_2(self):\n \n def check_default_3(self):\n assert_equal(mintypecode('fdF'),'D')\n- assert_equal(mintypecode('fdF',savespace=1),'F')\n+ #assert_equal(mintypecode('fdF',savespace=1),'F')\n assert_equal(mintypecode('fdD'),'D')\n assert_equal(mintypecode('fFD'),'D')\n assert_equal(mintypecode('dFD'),'D')\n@@ -57,7 +57,7 @@ def check_default_3(self):\n assert_equal(mintypecode('ifF'),'F')\n assert_equal(mintypecode('ifD'),'D')\n assert_equal(mintypecode('idF'),'D')\n- assert_equal(mintypecode('idF',savespace=1),'F')\n+ #assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \n class test_isscalar(unittest.TestCase):\n", "added_lines": 4, "deleted_lines": 4, "source_code": "\nimport unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base);reload(scipy.base.type_check)\nfrom scipy.base import *\ndel sys.path[0]\n\ndef assert_all(x):\n assert(all(x)), x\n \nclass test_mintypecode(ScipyTestCase):\n\n def check_default_1(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype),'d')\n assert_equal(mintypecode('f'),'f')\n assert_equal(mintypecode('d'),'d')\n assert_equal(mintypecode('F'),'F')\n assert_equal(mintypecode('D'),'D')\n\n def check_default_2(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype+'f'),'f')\n assert_equal(mintypecode(itype+'d'),'d')\n assert_equal(mintypecode(itype+'F'),'F')\n assert_equal(mintypecode(itype+'D'),'D')\n assert_equal(mintypecode('ff'),'f')\n assert_equal(mintypecode('fd'),'d')\n assert_equal(mintypecode('fF'),'F')\n assert_equal(mintypecode('fD'),'D')\n assert_equal(mintypecode('df'),'d')\n assert_equal(mintypecode('dd'),'d')\n #assert_equal(mintypecode('dF',savespace=1),'F')\n assert_equal(mintypecode('dF'),'D')\n assert_equal(mintypecode('dD'),'D')\n assert_equal(mintypecode('Ff'),'F')\n #assert_equal(mintypecode('Fd',savespace=1),'F')\n assert_equal(mintypecode('Fd'),'D')\n assert_equal(mintypecode('FF'),'F')\n assert_equal(mintypecode('FD'),'D')\n assert_equal(mintypecode('Df'),'D')\n assert_equal(mintypecode('Dd'),'D')\n assert_equal(mintypecode('DF'),'D')\n assert_equal(mintypecode('DD'),'D')\n\n def check_default_3(self):\n assert_equal(mintypecode('fdF'),'D')\n #assert_equal(mintypecode('fdF',savespace=1),'F')\n assert_equal(mintypecode('fdD'),'D')\n assert_equal(mintypecode('fFD'),'D')\n assert_equal(mintypecode('dFD'),'D')\n\n assert_equal(mintypecode('ifd'),'d')\n assert_equal(mintypecode('ifF'),'F')\n assert_equal(mintypecode('ifD'),'D')\n assert_equal(mintypecode('idF'),'D')\n #assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \nclass test_isscalar(unittest.TestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(unittest.TestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(unittest.TestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert_all(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert_all(isnan(1) == 0)\n def check_complex(self):\n assert_all(isnan(1+1j) == 0)\n def check_complex1(self):\n assert_all(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert_all(isfinite(1) == 1)\n def check_complex(self):\n assert_all(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert_all(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert_all(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert_all(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert_all(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert_all(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isinf(log(-1.)) == 0)\n # assert_all(isnan(log(-1.)) == 1)\n\nclass test_isposinf(unittest.TestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(unittest.TestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(unittest.TestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))\n assert(vals[1] == 0)\n assert_all(vals[2] > 1e10) and assert_all(isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert_all(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert_all(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert_all(vals.imag > 1e10) and assert_all(isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert_all(isfinite(vals)) \n #assert_all(vals.imag > 1e10) and assert_all(isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) \n\n\nclass test_real_if_close(unittest.TestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert_all(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert_all(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert_all(isrealobj(b))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", "source_code_before": "\nimport unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base);reload(scipy.base.type_check)\nfrom scipy.base import *\ndel sys.path[0]\n\ndef assert_all(x):\n assert(all(x)), x\n \nclass test_mintypecode(ScipyTestCase):\n\n def check_default_1(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype),'d')\n assert_equal(mintypecode('f'),'f')\n assert_equal(mintypecode('d'),'d')\n assert_equal(mintypecode('F'),'F')\n assert_equal(mintypecode('D'),'D')\n\n def check_default_2(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype+'f'),'f')\n assert_equal(mintypecode(itype+'d'),'d')\n assert_equal(mintypecode(itype+'F'),'F')\n assert_equal(mintypecode(itype+'D'),'D')\n assert_equal(mintypecode('ff'),'f')\n assert_equal(mintypecode('fd'),'d')\n assert_equal(mintypecode('fF'),'F')\n assert_equal(mintypecode('fD'),'D')\n assert_equal(mintypecode('df'),'d')\n assert_equal(mintypecode('dd'),'d')\n assert_equal(mintypecode('dF',savespace=1),'F')\n assert_equal(mintypecode('dF'),'D')\n assert_equal(mintypecode('dD'),'D')\n assert_equal(mintypecode('Ff'),'F')\n assert_equal(mintypecode('Fd',savespace=1),'F')\n assert_equal(mintypecode('Fd'),'D')\n assert_equal(mintypecode('FF'),'F')\n assert_equal(mintypecode('FD'),'D')\n assert_equal(mintypecode('Df'),'D')\n assert_equal(mintypecode('Dd'),'D')\n assert_equal(mintypecode('DF'),'D')\n assert_equal(mintypecode('DD'),'D')\n\n def check_default_3(self):\n assert_equal(mintypecode('fdF'),'D')\n assert_equal(mintypecode('fdF',savespace=1),'F')\n assert_equal(mintypecode('fdD'),'D')\n assert_equal(mintypecode('fFD'),'D')\n assert_equal(mintypecode('dFD'),'D')\n\n assert_equal(mintypecode('ifd'),'d')\n assert_equal(mintypecode('ifF'),'F')\n assert_equal(mintypecode('ifD'),'D')\n assert_equal(mintypecode('idF'),'D')\n assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \nclass test_isscalar(unittest.TestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(unittest.TestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(unittest.TestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert_all(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert_all(isnan(1) == 0)\n def check_complex(self):\n assert_all(isnan(1+1j) == 0)\n def check_complex1(self):\n assert_all(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert_all(isfinite(1) == 1)\n def check_complex(self):\n assert_all(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert_all(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert_all(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert_all(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert_all(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert_all(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isinf(log(-1.)) == 0)\n # assert_all(isnan(log(-1.)) == 1)\n\nclass test_isposinf(unittest.TestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(unittest.TestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(unittest.TestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))\n assert(vals[1] == 0)\n assert_all(vals[2] > 1e10) and assert_all(isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert_all(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert_all(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert_all(vals.imag > 1e10) and assert_all(isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert_all(isfinite(vals)) \n #assert_all(vals.imag > 1e10) and assert_all(isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) \n\n\nclass test_real_if_close(unittest.TestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert_all(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert_all(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert_all(isrealobj(b))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", "methods": [ { "name": "assert_all", "long_name": "assert_all( x )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 11, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_default_1", "long_name": "check_default_1( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 2, "token_count": 55, "parameters": [ "self" ], "start_line": 16, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_default_2", "long_name": "check_default_2( self )", "filename": "test_type_check.py", "nloc": 22, "complexity": 2, "token_count": 198, "parameters": [ "self" ], "start_line": 24, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_default_3", "long_name": "check_default_3( self )", "filename": "test_type_check.py", "nloc": 10, "complexity": 1, "token_count": 86, "parameters": [ "self" ], "start_line": 49, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 64, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 77, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 91, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 95, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 105, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 125, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 133, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 139, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 145, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 159, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 161, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 169, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_posinf_scalar", "long_name": "check_posinf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 171, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 173, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf_scalar", "long_name": "check_neginf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 177, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 191, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 198, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 203, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_good", "long_name": "check_complex_good( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 206, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_bad", "long_name": "check_complex_bad( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "self" ], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_bad2", "long_name": "check_complex_bad2( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 215, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 9, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 228, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "methods_before": [ { "name": "assert_all", "long_name": "assert_all( x )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 11, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_default_1", "long_name": "check_default_1( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 2, "token_count": 55, "parameters": [ "self" ], "start_line": 16, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_default_2", "long_name": "check_default_2( self )", "filename": "test_type_check.py", "nloc": 24, "complexity": 2, "token_count": 224, "parameters": [ "self" ], "start_line": 24, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_default_3", "long_name": "check_default_3( self )", "filename": "test_type_check.py", "nloc": 12, "complexity": 1, "token_count": 112, "parameters": [ "self" ], "start_line": 49, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 64, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 77, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 91, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 95, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 105, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 125, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 133, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 139, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 145, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 159, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 161, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 169, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_posinf_scalar", "long_name": "check_posinf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 171, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 173, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf_scalar", "long_name": "check_neginf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 177, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 191, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 198, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 203, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_good", "long_name": "check_complex_good( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 206, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_bad", "long_name": "check_complex_bad( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "self" ], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_bad2", "long_name": "check_complex_bad2( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 215, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 9, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 228, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "check_default_2", "long_name": "check_default_2( self )", "filename": "test_type_check.py", "nloc": 22, "complexity": 2, "token_count": 198, "parameters": [ "self" ], "start_line": 24, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_default_3", "long_name": "check_default_3( self )", "filename": "test_type_check.py", "nloc": 10, "complexity": 1, "token_count": 86, "parameters": [ "self" ], "start_line": 49, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 } ], "nloc": 196, "complexity": 48, "token_count": 1816, "diff_parsed": { "added": [ " #assert_equal(mintypecode('dF',savespace=1),'F')", " #assert_equal(mintypecode('Fd',savespace=1),'F')", " #assert_equal(mintypecode('fdF',savespace=1),'F')", " #assert_equal(mintypecode('idF',savespace=1),'F')" ], "deleted": [ " assert_equal(mintypecode('dF',savespace=1),'F')", " assert_equal(mintypecode('Fd',savespace=1),'F')", " assert_equal(mintypecode('fdF',savespace=1),'F')", " assert_equal(mintypecode('idF',savespace=1),'F')" ] } }, { "old_path": "scipy/base/type_check.py", "new_path": "scipy/base/type_check.py", "filename": "type_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -30,7 +30,7 @@ def mintypecode(typechars,typeset='GDFgdf',default='d'):\n applied.\n \"\"\"\n typecodes = [(type(t) is type('') and t) or asarray(t).dtypechar\\\n- for t in typecodes]\n+ for t in typechars]\n intersection = [t for t in typecodes if t in typeset]\n if not intersection:\n return default\n@@ -93,8 +93,15 @@ def nan_to_num(x):\n t = obj2dtype(type(x))\n if issubclass(t, _nx.complexfloating):\n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n+ elif issubclass(t, _nx.integer):\n+ y = array(x)\n else: \n y = array(x)\n+ if not y.shape:\n+ y = array([x])\n+ scalar = True\n+ else:\n+ scalar = False\n are_inf = isposinf(y)\n are_neg_inf = isneginf(y)\n are_nan = isnan(y)\n@@ -102,6 +109,8 @@ def nan_to_num(x):\n y[are_nan] = 0\n y[are_inf] = maxf\n y[are_neg_inf] = minf\n+ if scalar:\n+ y = y[0]\n return y\n \n #-----------------------------------------------------------------------------\n@@ -113,7 +122,7 @@ def real_if_close(a,tol=100):\n if tol > 1:\n import getlimits\n f = getlimits.finfo(a.dtype)\n- tol = f.epsilon * tol\n+ tol = f.eps * tol\n if _nx.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n", "added_lines": 11, "deleted_lines": 2, "source_code": "## Automatically adapted for scipy Sep 19, 2005 by convertcode.py\n\nimport types\nimport numeric as _nx\nfrom numeric import ndarray, asarray, array, isinf, isnan, isfinite, signbit, \\\n ufunc, ScalarType, obj2dtype\nfrom ufunclike import isneginf, isposinf\nimport umath\n\n__all__ = ['iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar',\n 'isreal','nan_to_num','real','real_if_close',\n 'typename','asfarray','mintypecode']\n\n_typecodes_by_elsize = 'GDFgdfQqLlIiHhBb?'\n\ndef mintypecode(typechars,typeset='GDFgdf',default='d'):\n \"\"\" Return a minimum data type character from typeset that\n handles all typechars given\n\n The returned type character must be the smallest size such that\n an array of the returned type can handle the data from an array of\n type t for each t in typechars (or if typechars is an array,\n then its dtypechar).\n\n If the typechars does not intersect with the typeset, then default\n is returned.\n\n If t in typechars is not a string then t=asarray(t).dtypechar is\n applied.\n \"\"\"\n typecodes = [(type(t) is type('') and t) or asarray(t).dtypechar\\\n for t in typechars]\n intersection = [t for t in typecodes if t in typeset]\n if not intersection:\n return default\n if 'F' in intersection and 'd' in intersection:\n return 'D'\n l = []\n for t in intersection:\n i = _typecodes_by_elsize.index(t)\n l.append((i,t))\n l.sort()\n return l[0][1]\n\ndef asfarray(a, dtype=_nx.float_):\n \"\"\"asfarray(a,dtype=None) returns a as a float array.\"\"\"\n dtype = _nx.obj2dtype(dtype)\n if not issubclass(dtype, _nx.inexact):\n dtype = _nx.float_\n a = asarray(a,dtype=dtype)\n return a\n \ndef isscalar(num):\n if isinstance(num, _nx.generic):\n return True\n else:\n return type(num) in ScalarType\n\ndef real(val):\n return asarray(val).real\n\ndef imag(val):\n return asarray(val).imag\n\ndef iscomplex(x):\n return imag(x) != _nx.zeros_like(x)\n\ndef isreal(x):\n return imag(x) == _nx.zeros_like(x)\n\ndef iscomplexobj(x):\n return issubclass( asarray(x).dtype, _nx.complexfloating)\n\ndef isrealobj(x):\n return not issubclass( asarray(x).dtype, _nx.complexfloating)\n\n#-----------------------------------------------------------------------------\n\ndef _getmaxmin(t):\n import getlimits\n f = getlimits.finfo(t)\n return f.max, f.min\n \ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> limits.double_max\n # -Inf -> limits.double_min\n try:\n t = x.dtype\n except AttributeError:\n t = obj2dtype(type(x))\n if issubclass(t, _nx.complexfloating):\n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n elif issubclass(t, _nx.integer):\n y = array(x)\n else: \n y = array(x)\n if not y.shape:\n y = array([x])\n scalar = True\n else:\n scalar = False\n are_inf = isposinf(y)\n are_neg_inf = isneginf(y)\n are_nan = isnan(y)\n maxf, minf = _getmaxmin(y.dtype)\n y[are_nan] = 0\n y[are_inf] = maxf\n y[are_neg_inf] = minf\n if scalar:\n y = y[0]\n return y\n\n#-----------------------------------------------------------------------------\n\ndef real_if_close(a,tol=100):\n a = asarray(a)\n if a.dtypechar not in 'FDG':\n return a\n if tol > 1:\n import getlimits\n f = getlimits.finfo(a.dtype)\n tol = f.eps * tol\n if _nx.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n\n\n#-----------------------------------------------------------------------------\n\n_namefromtype = {'S1' : 'character',\n '?' : 'bool',\n 'b' : 'signed char',\n 'B' : 'unsigned char',\n 'h' : 'short',\n 'H' : 'unsigned short',\n 'i' : 'integer',\n 'I' : 'unsigned integer',\n 'l' : 'long integer',\n 'L' : 'unsigned long integer',\n 'q' : 'long long integer',\n 'Q' : 'unsigned long long integer',\n 'f' : 'single precision',\n 'd' : 'double precision',\n 'g' : 'long precision',\n 'F' : 'complex single precision',\n 'D' : 'complex double precision',\n 'G' : 'complex long double precision',\n 'S' : 'string',\n 'U' : 'unicode',\n 'V' : 'void',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english description for the given data type character.\n \"\"\"\n return _namefromtype[char]\n\n#-----------------------------------------------------------------------------\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'g':0, 'F': 1, 'D': 1, 'G':1}\narray_precision = {'i': 1, 'l': 1,\n 'f': 0, 'd': 1, 'g':2,\n 'F': 0, 'D': 1, 'G':2}\narray_type = [['f', 'd', 'g'], ['F', 'D', 'G']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.dtypechar\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\nif __name__ == '__main__':\n print \"Nothing...\"\n", "source_code_before": "## Automatically adapted for scipy Sep 19, 2005 by convertcode.py\n\nimport types\nimport numeric as _nx\nfrom numeric import ndarray, asarray, array, isinf, isnan, isfinite, signbit, \\\n ufunc, ScalarType, obj2dtype\nfrom ufunclike import isneginf, isposinf\nimport umath\n\n__all__ = ['iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar',\n 'isreal','nan_to_num','real','real_if_close',\n 'typename','asfarray','mintypecode']\n\n_typecodes_by_elsize = 'GDFgdfQqLlIiHhBb?'\n\ndef mintypecode(typechars,typeset='GDFgdf',default='d'):\n \"\"\" Return a minimum data type character from typeset that\n handles all typechars given\n\n The returned type character must be the smallest size such that\n an array of the returned type can handle the data from an array of\n type t for each t in typechars (or if typechars is an array,\n then its dtypechar).\n\n If the typechars does not intersect with the typeset, then default\n is returned.\n\n If t in typechars is not a string then t=asarray(t).dtypechar is\n applied.\n \"\"\"\n typecodes = [(type(t) is type('') and t) or asarray(t).dtypechar\\\n for t in typecodes]\n intersection = [t for t in typecodes if t in typeset]\n if not intersection:\n return default\n if 'F' in intersection and 'd' in intersection:\n return 'D'\n l = []\n for t in intersection:\n i = _typecodes_by_elsize.index(t)\n l.append((i,t))\n l.sort()\n return l[0][1]\n\ndef asfarray(a, dtype=_nx.float_):\n \"\"\"asfarray(a,dtype=None) returns a as a float array.\"\"\"\n dtype = _nx.obj2dtype(dtype)\n if not issubclass(dtype, _nx.inexact):\n dtype = _nx.float_\n a = asarray(a,dtype=dtype)\n return a\n \ndef isscalar(num):\n if isinstance(num, _nx.generic):\n return True\n else:\n return type(num) in ScalarType\n\ndef real(val):\n return asarray(val).real\n\ndef imag(val):\n return asarray(val).imag\n\ndef iscomplex(x):\n return imag(x) != _nx.zeros_like(x)\n\ndef isreal(x):\n return imag(x) == _nx.zeros_like(x)\n\ndef iscomplexobj(x):\n return issubclass( asarray(x).dtype, _nx.complexfloating)\n\ndef isrealobj(x):\n return not issubclass( asarray(x).dtype, _nx.complexfloating)\n\n#-----------------------------------------------------------------------------\n\ndef _getmaxmin(t):\n import getlimits\n f = getlimits.finfo(t)\n return f.max, f.min\n \ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> limits.double_max\n # -Inf -> limits.double_min\n try:\n t = x.dtype\n except AttributeError:\n t = obj2dtype(type(x))\n if issubclass(t, _nx.complexfloating):\n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n y = array(x)\n are_inf = isposinf(y)\n are_neg_inf = isneginf(y)\n are_nan = isnan(y)\n maxf, minf = _getmaxmin(y.dtype)\n y[are_nan] = 0\n y[are_inf] = maxf\n y[are_neg_inf] = minf\n return y\n\n#-----------------------------------------------------------------------------\n\ndef real_if_close(a,tol=100):\n a = asarray(a)\n if a.dtypechar not in 'FDG':\n return a\n if tol > 1:\n import getlimits\n f = getlimits.finfo(a.dtype)\n tol = f.epsilon * tol\n if _nx.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n\n\n#-----------------------------------------------------------------------------\n\n_namefromtype = {'S1' : 'character',\n '?' : 'bool',\n 'b' : 'signed char',\n 'B' : 'unsigned char',\n 'h' : 'short',\n 'H' : 'unsigned short',\n 'i' : 'integer',\n 'I' : 'unsigned integer',\n 'l' : 'long integer',\n 'L' : 'unsigned long integer',\n 'q' : 'long long integer',\n 'Q' : 'unsigned long long integer',\n 'f' : 'single precision',\n 'd' : 'double precision',\n 'g' : 'long precision',\n 'F' : 'complex single precision',\n 'D' : 'complex double precision',\n 'G' : 'complex long double precision',\n 'S' : 'string',\n 'U' : 'unicode',\n 'V' : 'void',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english description for the given data type character.\n \"\"\"\n return _namefromtype[char]\n\n#-----------------------------------------------------------------------------\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'g':0, 'F': 1, 'D': 1, 'G':1}\narray_precision = {'i': 1, 'l': 1,\n 'f': 0, 'd': 1, 'g':2,\n 'F': 0, 'D': 1, 'G':2}\narray_type = [['f', 'd', 'g'], ['F', 'D', 'G']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.dtypechar\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\nif __name__ == '__main__':\n print \"Nothing...\"\n", "methods": [ { "name": "mintypecode", "long_name": "mintypecode( typechars , typeset = 'GDFgdf' , default = 'd' )", "filename": "type_check.py", "nloc": 14, "complexity": 10, "token_count": 113, "parameters": [ "typechars", "typeset", "default" ], "start_line": 17, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "asfarray", "long_name": "asfarray( a , dtype = _nx . float_ )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "a", "dtype" ], "start_line": 46, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "isscalar", "long_name": "isscalar( num )", "filename": "type_check.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "num" ], "start_line": 54, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "real", "long_name": "real( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "val" ], "start_line": 60, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "imag", "long_name": "imag( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "val" ], "start_line": 63, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplex", "long_name": "iscomplex( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "x" ], "start_line": 66, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isreal", "long_name": "isreal( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "x" ], "start_line": 69, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplexobj", "long_name": "iscomplexobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "x" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isrealobj", "long_name": "isrealobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "x" ], "start_line": 75, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "_getmaxmin", "long_name": "_getmaxmin( t )", "filename": "type_check.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "t" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 26, "complexity": 6, "token_count": 154, "parameters": [ "x" ], "start_line": 85, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "real_if_close", "long_name": "real_if_close( a , tol = 100 )", "filename": "type_check.py", "nloc": 11, "complexity": 4, "token_count": 72, "parameters": [ "a", "tol" ], "start_line": 118, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "typename", "long_name": "typename( char )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "char" ], "start_line": 157, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "common_type", "long_name": "common_type( * arrays )", "filename": "type_check.py", "nloc": 8, "complexity": 2, "token_count": 52, "parameters": [ "arrays" ], "start_line": 170, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "mintypecode", "long_name": "mintypecode( typechars , typeset = 'GDFgdf' , default = 'd' )", "filename": "type_check.py", "nloc": 14, "complexity": 10, "token_count": 113, "parameters": [ "typechars", "typeset", "default" ], "start_line": 17, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "asfarray", "long_name": "asfarray( a , dtype = _nx . float_ )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "a", "dtype" ], "start_line": 46, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "isscalar", "long_name": "isscalar( num )", "filename": "type_check.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "num" ], "start_line": 54, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "real", "long_name": "real( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "val" ], "start_line": 60, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "imag", "long_name": "imag( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "val" ], "start_line": 63, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplex", "long_name": "iscomplex( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "x" ], "start_line": 66, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isreal", "long_name": "isreal( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "x" ], "start_line": 69, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplexobj", "long_name": "iscomplexobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "x" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isrealobj", "long_name": "isrealobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "x" ], "start_line": 75, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "_getmaxmin", "long_name": "_getmaxmin( t )", "filename": "type_check.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "t" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 17, "complexity": 3, "token_count": 107, "parameters": [ "x" ], "start_line": 85, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "real_if_close", "long_name": "real_if_close( a , tol = 100 )", "filename": "type_check.py", "nloc": 11, "complexity": 4, "token_count": 72, "parameters": [ "a", "tol" ], "start_line": 109, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "typename", "long_name": "typename( char )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "char" ], "start_line": 148, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "common_type", "long_name": "common_type( * arrays )", "filename": "type_check.py", "nloc": 8, "complexity": 2, "token_count": 52, "parameters": [ "arrays" ], "start_line": 161, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "real_if_close", "long_name": "real_if_close( a , tol = 100 )", "filename": "type_check.py", "nloc": 11, "complexity": 4, "token_count": 72, "parameters": [ "a", "tol" ], "start_line": 118, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 26, "complexity": 6, "token_count": 154, "parameters": [ "x" ], "start_line": 85, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "mintypecode", "long_name": "mintypecode( typechars , typeset = 'GDFgdf' , default = 'd' )", "filename": "type_check.py", "nloc": 14, "complexity": 10, "token_count": 113, "parameters": [ "typechars", "typeset", "default" ], "start_line": 17, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "nloc": 129, "complexity": 34, "token_count": 864, "diff_parsed": { "added": [ " for t in typechars]", " elif issubclass(t, _nx.integer):", " y = array(x)", " if not y.shape:", " y = array([x])", " scalar = True", " else:", " scalar = False", " if scalar:", " y = y[0]", " tol = f.eps * tol" ], "deleted": [ " for t in typecodes]", " tol = f.epsilon * tol" ] } }, { "old_path": "scipy/base/ufunclike.py", "new_path": "scipy/base/ufunclike.py", "filename": "ufunclike.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,7 @@\n \n import numeric as _nx\n from numeric import asarray, empty, empty_like, isinf, signbit\n+import umath\n \n __all__ = ['fix','mod','isneginf','isposinf','sign']\n \n", "added_lines": 1, "deleted_lines": 0, "source_code": "\nimport numeric as _nx\nfrom numeric import asarray, empty, empty_like, isinf, signbit\nimport umath\n\n__all__ = ['fix','mod','isneginf','isposinf','sign']\n\ndef fix(x, y=None):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = asarray(x) \n if y is None:\n y = _nx.floor(x)\n else:\n _nx.floor(x,y)\n y[x<0] = y[x<0]+1\n return y\n\ndef mod(x,y,z=None):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n x = asarray(x)\n y = asarray(y) \n if z is None:\n z = empty_like(x)\n tmp = _nx.floor(x*1.0/y)\n return _nx.subtract(x, y*tmp, z)\n\ndef isposinf(x, y=None):\n if y is None:\n y = empty(x.shape, dtype='?')\n umath.logical_and(isinf(x), ~signbit(x), y)\n return y\n \ndef isneginf(x, y=None):\n if y is None:\n y = empty(x.shape, dtype='?')\n umath.logical_and(isinf(x), signbit(x), y)\n return y\n\ndef sign(x, y=None):\n \"\"\"sign(x) gives an array with shape of x with elexents defined by sign\n function: where x is less than 0 return -1, where x greater than 0, a=1,\n elsewhere a=0.\n \"\"\"\n x = asarray(x) \n if y is None:\n y = empty(x.shape, dtype=_nx.int_)\n y[x<0] = -1\n y[x>0] = 1\n y[x==0] = 0\n return y\n\n", "source_code_before": "\nimport numeric as _nx\nfrom numeric import asarray, empty, empty_like, isinf, signbit\n\n__all__ = ['fix','mod','isneginf','isposinf','sign']\n\ndef fix(x, y=None):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = asarray(x) \n if y is None:\n y = _nx.floor(x)\n else:\n _nx.floor(x,y)\n y[x<0] = y[x<0]+1\n return y\n\ndef mod(x,y,z=None):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n x = asarray(x)\n y = asarray(y) \n if z is None:\n z = empty_like(x)\n tmp = _nx.floor(x*1.0/y)\n return _nx.subtract(x, y*tmp, z)\n\ndef isposinf(x, y=None):\n if y is None:\n y = empty(x.shape, dtype='?')\n umath.logical_and(isinf(x), ~signbit(x), y)\n return y\n \ndef isneginf(x, y=None):\n if y is None:\n y = empty(x.shape, dtype='?')\n umath.logical_and(isinf(x), signbit(x), y)\n return y\n\ndef sign(x, y=None):\n \"\"\"sign(x) gives an array with shape of x with elexents defined by sign\n function: where x is less than 0 return -1, where x greater than 0, a=1,\n elsewhere a=0.\n \"\"\"\n x = asarray(x) \n if y is None:\n y = empty(x.shape, dtype=_nx.int_)\n y[x<0] = -1\n y[x>0] = 1\n y[x==0] = 0\n return y\n\n", "methods": [ { "name": "fix", "long_name": "fix( x , y = None )", "filename": "ufunclike.py", "nloc": 8, "complexity": 2, "token_count": 56, "parameters": [ "x", "y" ], "start_line": 8, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y , z = None )", "filename": "ufunclike.py", "nloc": 7, "complexity": 2, "token_count": 62, "parameters": [ "x", "y", "z" ], "start_line": 19, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "isposinf", "long_name": "isposinf( x , y = None )", "filename": "ufunclike.py", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "x", "y" ], "start_line": 32, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "isneginf", "long_name": "isneginf( x , y = None )", "filename": "ufunclike.py", "nloc": 5, "complexity": 2, "token_count": 44, "parameters": [ "x", "y" ], "start_line": 38, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sign", "long_name": "sign( x , y = None )", "filename": "ufunclike.py", "nloc": 8, "complexity": 2, "token_count": 62, "parameters": [ "x", "y" ], "start_line": 44, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "methods_before": [ { "name": "fix", "long_name": "fix( x , y = None )", "filename": "ufunclike.py", "nloc": 8, "complexity": 2, "token_count": 56, "parameters": [ "x", "y" ], "start_line": 7, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y , z = None )", "filename": "ufunclike.py", "nloc": 7, "complexity": 2, "token_count": 62, "parameters": [ "x", "y", "z" ], "start_line": 18, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "isposinf", "long_name": "isposinf( x , y = None )", "filename": "ufunclike.py", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "x", "y" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "isneginf", "long_name": "isneginf( x , y = None )", "filename": "ufunclike.py", "nloc": 5, "complexity": 2, "token_count": 44, "parameters": [ "x", "y" ], "start_line": 37, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sign", "long_name": "sign( x , y = None )", "filename": "ufunclike.py", "nloc": 8, "complexity": 2, "token_count": 62, "parameters": [ "x", "y" ], "start_line": 43, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 37, "complexity": 10, "token_count": 305, "diff_parsed": { "added": [ "import umath" ], "deleted": [] } } ] }, { "hash": "e35b804e62090078176b50514a04a31fa0e74f0d", "msg": "r104@Blasphemy: kern | 2005-10-05 04:20:16 -0700\n Fix apply_along_axis", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-05T11:20:28+00:00", "author_timezone": 0, "committer_date": "2005-10-05T11:20:28+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b3b692136487acd9f39e33b8d8f584a2c5383d02" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 5, "insertions": 5, "lines": 10, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/base/shape_base.py", "new_path": "scipy/base/shape_base.py", "filename": "shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -28,7 +28,7 @@ def apply_along_axis(func1d,axis,arr,*args):\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape).take(indlist)\n i.put(indlist, ind)\n- res = func1d(arr[tuple(i)],*args)\n+ res = func1d(arr[tuple(i.tolist())],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n@@ -44,7 +44,7 @@ def apply_along_axis(func1d,axis,arr,*args):\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n- res = func1d(arr[tuple(i)],*args)\n+ res = func1d(arr[tuple(i.tolist())],*args)\n outarr[ind] = res\n k += 1\n return outarr\n@@ -54,7 +54,7 @@ def apply_along_axis(func1d,axis,arr,*args):\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n- outarr[tuple(i)] = res\n+ outarr[tuple(i.tolist())] = res\n k = 1\n while k < Ntot:\n # increment the index\n@@ -65,8 +65,8 @@ def apply_along_axis(func1d,axis,arr,*args):\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n- res = func1d(arr[tuple(i)],*args)\n- outarr[tuple(i)] = res\n+ res = func1d(arr[tuple(i.tolist())],*args)\n+ outarr[tuple(i.tolist())] = res\n k += 1\n return outarr\n \n", "added_lines": 5, "deleted_lines": 5, "source_code": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i.tolist())] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n outarr[tuple(i.tolist())] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "source_code_before": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i)],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i)] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i)],*args)\n outarr[tuple(i)] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 424, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "methods_before": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 404, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 424, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 } ], "nloc": 196, "complexity": 57, "token_count": 1466, "diff_parsed": { "added": [ " res = func1d(arr[tuple(i.tolist())],*args)", " res = func1d(arr[tuple(i.tolist())],*args)", " outarr[tuple(i.tolist())] = res", " res = func1d(arr[tuple(i.tolist())],*args)", " outarr[tuple(i.tolist())] = res" ], "deleted": [ " res = func1d(arr[tuple(i)],*args)", " res = func1d(arr[tuple(i)],*args)", " outarr[tuple(i)] = res", " res = func1d(arr[tuple(i)],*args)", " outarr[tuple(i)] = res" ] } } ] }, { "hash": "2444393193efdfce40ce944ace154eb6c9083da0", "msg": "r107@Blasphemy: kern | 2005-10-05 04:21:41 -0700\n Activate apply_along_axis test", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-05T11:21:51+00:00", "author_timezone": 0, "committer_date": "2005-10-05T11:21:51+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e35b804e62090078176b50514a04a31fa0e74f0d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 9, "insertions": 9, "lines": 18, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy/base/tests/test_shape_base.py", "new_path": "scipy/base/tests/test_shape_base.py", "filename": "test_shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,15 +8,15 @@\n from scipy.base import *\n restore_path()\n \n-#class test_apply_along_axis(ScipyTestCase):\n-# def check_simple(self):\n-# a = ones((20,10),'d')\n-# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n-# def check_simple101(self,level=11):\n-# # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n-# # when enabled and shape(a)[1]>100. See Issue 202.\n-# a = ones((10,101),'d')\n-# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n+class test_apply_along_axis(ScipyTestCase):\n+ def check_simple(self):\n+ a = ones((20,10),'d')\n+ assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n+ def check_simple101(self,level=11):\n+ # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n+ # when enabled and shape(a)[1]>100. See Issue 202.\n+ a = ones((10,101),'d')\n+ assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n \n class test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n", "added_lines": 9, "deleted_lines": 9, "source_code": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base; reload(scipy.base)\nreload(scipy.base.shape_base)\nfrom scipy.base import *\nrestore_path()\n\nclass test_apply_along_axis(ScipyTestCase):\n def check_simple(self):\n a = ones((20,10),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n def check_simple101(self,level=11):\n # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n # when enabled and shape(a)[1]>100. See Issue 202.\n a = ones((10,101),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n\nclass test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(unittest.TestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(unittest.TestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.shape_base').run()\n", "source_code_before": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base; reload(scipy.base)\nreload(scipy.base.shape_base)\nfrom scipy.base import *\nrestore_path()\n\n#class test_apply_along_axis(ScipyTestCase):\n# def check_simple(self):\n# a = ones((20,10),'d')\n# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n# def check_simple101(self,level=11):\n# # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n# # when enabled and shape(a)[1]>100. See Issue 202.\n# a = ones((10,101),'d')\n# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n\nclass test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(unittest.TestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(unittest.TestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.shape_base').run()\n", "methods": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 12, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_simple101", "long_name": "check_simple101( self , level = 11 )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 48, "parameters": [ "self", "level" ], "start_line": 15, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_0_split", "long_name": "check_integer_0_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 22, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split", "long_name": "check_integer_split( self )", "filename": "test_shape_base.py", "nloc": 43, "complexity": 1, "token_count": 637, "parameters": [ "self" ], "start_line": 29, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_rows", "long_name": "check_integer_split_2D_rows( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_cols", "long_name": "check_integer_split_2D_cols( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 96, "parameters": [ "self" ], "start_line": 87, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_default", "long_name": "check_integer_split_2D_default( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 65, "parameters": [ "self" ], "start_line": 94, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_index_split_simple", "long_name": "check_index_split_simple( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_low_bound", "long_name": "check_index_split_low_bound( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_high_bound", "long_name": "check_index_split_high_bound( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 116, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_equal_split", "long_name": "check_equal_split( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_unequal_split", "long_name": "check_unequal_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 135, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 159, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r1array", "long_name": "check_r1array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 175, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 185, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 190, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r2array", "long_name": "check_r2array( self )", "filename": "test_shape_base.py", "nloc": 4, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 62, "parameters": [ "self" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 209, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 214, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 232, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 244, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 249, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 254, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 259, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 266, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 271, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 276, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 281, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 300, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 305, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 315, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 332, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 9, "complexity": 1, "token_count": 138, "parameters": [ "self" ], "start_line": 340, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 103, "parameters": [ "self" ], "start_line": 351, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_integer_0_split", "long_name": "check_integer_0_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 22, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split", "long_name": "check_integer_split( self )", "filename": "test_shape_base.py", "nloc": 43, "complexity": 1, "token_count": 637, "parameters": [ "self" ], "start_line": 29, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_rows", "long_name": "check_integer_split_2D_rows( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_cols", "long_name": "check_integer_split_2D_cols( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 96, "parameters": [ "self" ], "start_line": 87, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_default", "long_name": "check_integer_split_2D_default( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 65, "parameters": [ "self" ], "start_line": 94, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_index_split_simple", "long_name": "check_index_split_simple( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_low_bound", "long_name": "check_index_split_low_bound( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_high_bound", "long_name": "check_index_split_high_bound( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 116, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_equal_split", "long_name": "check_equal_split( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_unequal_split", "long_name": "check_unequal_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 135, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 159, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r1array", "long_name": "check_r1array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 175, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 185, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 190, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r2array", "long_name": "check_r2array( self )", "filename": "test_shape_base.py", "nloc": 4, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 62, "parameters": [ "self" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 209, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 214, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 232, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 244, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 249, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 254, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 259, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 266, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 271, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 276, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 281, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 300, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 305, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 315, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 332, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 9, "complexity": 1, "token_count": 138, "parameters": [ "self" ], "start_line": 340, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 103, "parameters": [ "self" ], "start_line": 351, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 12, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_simple101", "long_name": "check_simple101( self , level = 11 )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 1, "token_count": 48, "parameters": [ "self", "level" ], "start_line": 15, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 326, "complexity": 52, "token_count": 3773, "diff_parsed": { "added": [ "class test_apply_along_axis(ScipyTestCase):", " def check_simple(self):", " a = ones((20,10),'d')", " assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))", " def check_simple101(self,level=11):", " # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)", " # when enabled and shape(a)[1]>100. See Issue 202.", " a = ones((10,101),'d')", " assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))" ], "deleted": [ "#class test_apply_along_axis(ScipyTestCase):", "# def check_simple(self):", "# a = ones((20,10),'d')", "# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))", "# def check_simple101(self,level=11):", "# # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)", "# # when enabled and shape(a)[1]>100. See Issue 202.", "# a = ones((10,101),'d')", "# assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))" ] } } ] }, { "hash": "9ce3555349dac29e1ff450d978bf3c0973ebeb45", "msg": "Fixed remaining problems with casting buffer sizes..", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-05T19:57:28+00:00", "author_timezone": 0, "committer_date": "2005-10-05T19:57:28+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "2444393193efdfce40ce944ace154eb6c9083da0" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 15, "insertions": 38, "lines": 53, "files": 4, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy/base/_internal.py", "new_path": "scipy/base/_internal.py", "filename": "_internal.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,9 +3,9 @@\n \n _defflags = _flagdict.keys()\n \n-_setable = ['WRITEABLE', 'NOTSWAPPED', 'UPDATEIFCOPY', 'ALIGNED',\n- 'W','N','U','A']\n-_setable2 = ['write','swap','uic','align']*2\n+_setable = ['WRITEABLE', 'NOTSWAPPED', 'SWAPPED', 'UPDATEIFCOPY', 'ALIGNED',\n+ 'W','N','S','U','A']\n+_setable2 = ['write','swap','swap','uic','align']*2\n _firstltr = {'W':'WRITEABLE',\n 'N':'NOTSWAPPED',\n 'A':'ALIGNED',\n@@ -77,7 +77,7 @@ def __setitem__(self, item, val):\n for k, name in enumerate(_setable):\n if item == name:\n kwds[_setable2[k]] = val\n- if (item == 'NOTSWAPPED'):\n+ if (item == 'NOTSWAPPED' or item == 'N'):\n kwds['swap'] = not val\n \n # now actually update array flags\n", "added_lines": 4, "deleted_lines": 4, "source_code": "\nfrom multiarray import _flagdict\n\n_defflags = _flagdict.keys()\n\n_setable = ['WRITEABLE', 'NOTSWAPPED', 'SWAPPED', 'UPDATEIFCOPY', 'ALIGNED',\n 'W','N','S','U','A']\n_setable2 = ['write','swap','swap','uic','align']*2\n_firstltr = {'W':'WRITEABLE',\n 'N':'NOTSWAPPED',\n 'A':'ALIGNED',\n 'C':'CONTIGUOUS',\n 'F':'FORTRAN',\n 'O':'OWNDATA',\n 'U':'UPDATEIFCOPY'}\n\n_anum = _flagdict['ALIGNED']\n_nnum = _flagdict['NOTSWAPPED']\n_wnum = _flagdict['WRITEABLE']\n_cnum = _flagdict['CONTIGUOUS']\n_fnum = _flagdict['FORTRAN']\n\nclass flagsobj(dict):\n def __init__(self, arr, flags):\n self._arr = arr\n self._flagnum = flags\n for k in _defflags:\n num = _flagdict[k]\n dict.__setitem__(self, k, flags & num == num)\n\n def __getitem__(self, key):\n if not isinstance(key, str):\n raise KeyError, \"Unknown flag %s\" % key\n if len(key) == 1:\n try:\n return dict.__getitem__(self, _firstltr[key])\n except:\n if (key == 'B'):\n num = _anum + _nnum + _wnum\n return self._flagnum & num == num\n elif (key == 'S'):\n return not (self._flagnum & _nnum == _nnum)\n else:\n try:\n return dict.__getitem__(self, key)\n except: # special cases\n if (key == 'FNC'):\n return (self._flagnum & _fnum == _fnum) and not \\\n (self._flagnum & _cnum == _cnum)\n\t if (key == 'FORC'):\n\t\t return (self._flagnum & _fnum == _fnum) or \\\n (self._flagnum & _cnum == _cnum)\n if (key == 'SWAPPED'):\n return not (self._flagnum & _nnum == _nnum)\n if (key == 'BEHAVED'):\n num = _anum + _nnum + _wnum\n return self._flagnum & num == num\n if (key in ['BEHAVED_RO', 'BRO']):\n num = _anum + _nnum\n return self._flagnum & num == num\n if (key in ['CARRAY','CA']):\n num = _anum + _nnum + _wnum + _cnum\n return self._flagnum & num == num\n if (key in ['FARRAY','FA']):\n num = _anum + _nnum + _wnum + _fnum\n return (self._flagnum & num == num) and not \\\n (self._flagnum & _cnum == _cnum)\n raise KeyError, \"Unknown flag: %s\" % key\n \n def __setitem__(self, item, val):\n val = not not val # convert to boolean\n if item not in _setable:\n raise KeyError, \"Cannot set flag\", item\n dict.__setitem__(self, item, val) # Does this matter?\n\n kwds = {}\n for k, name in enumerate(_setable):\n if item == name:\n kwds[_setable2[k]] = val\n if (item == 'NOTSWAPPED' or item == 'N'):\n kwds['swap'] = not val\n\n # now actually update array flags\n self._arr.setflags(**kwds)\n \n", "source_code_before": "\nfrom multiarray import _flagdict\n\n_defflags = _flagdict.keys()\n\n_setable = ['WRITEABLE', 'NOTSWAPPED', 'UPDATEIFCOPY', 'ALIGNED',\n 'W','N','U','A']\n_setable2 = ['write','swap','uic','align']*2\n_firstltr = {'W':'WRITEABLE',\n 'N':'NOTSWAPPED',\n 'A':'ALIGNED',\n 'C':'CONTIGUOUS',\n 'F':'FORTRAN',\n 'O':'OWNDATA',\n 'U':'UPDATEIFCOPY'}\n\n_anum = _flagdict['ALIGNED']\n_nnum = _flagdict['NOTSWAPPED']\n_wnum = _flagdict['WRITEABLE']\n_cnum = _flagdict['CONTIGUOUS']\n_fnum = _flagdict['FORTRAN']\n\nclass flagsobj(dict):\n def __init__(self, arr, flags):\n self._arr = arr\n self._flagnum = flags\n for k in _defflags:\n num = _flagdict[k]\n dict.__setitem__(self, k, flags & num == num)\n\n def __getitem__(self, key):\n if not isinstance(key, str):\n raise KeyError, \"Unknown flag %s\" % key\n if len(key) == 1:\n try:\n return dict.__getitem__(self, _firstltr[key])\n except:\n if (key == 'B'):\n num = _anum + _nnum + _wnum\n return self._flagnum & num == num\n elif (key == 'S'):\n return not (self._flagnum & _nnum == _nnum)\n else:\n try:\n return dict.__getitem__(self, key)\n except: # special cases\n if (key == 'FNC'):\n return (self._flagnum & _fnum == _fnum) and not \\\n (self._flagnum & _cnum == _cnum)\n\t if (key == 'FORC'):\n\t\t return (self._flagnum & _fnum == _fnum) or \\\n (self._flagnum & _cnum == _cnum)\n if (key == 'SWAPPED'):\n return not (self._flagnum & _nnum == _nnum)\n if (key == 'BEHAVED'):\n num = _anum + _nnum + _wnum\n return self._flagnum & num == num\n if (key in ['BEHAVED_RO', 'BRO']):\n num = _anum + _nnum\n return self._flagnum & num == num\n if (key in ['CARRAY','CA']):\n num = _anum + _nnum + _wnum + _cnum\n return self._flagnum & num == num\n if (key in ['FARRAY','FA']):\n num = _anum + _nnum + _wnum + _fnum\n return (self._flagnum & num == num) and not \\\n (self._flagnum & _cnum == _cnum)\n raise KeyError, \"Unknown flag: %s\" % key\n \n def __setitem__(self, item, val):\n val = not not val # convert to boolean\n if item not in _setable:\n raise KeyError, \"Cannot set flag\", item\n dict.__setitem__(self, item, val) # Does this matter?\n\n kwds = {}\n for k, name in enumerate(_setable):\n if item == name:\n kwds[_setable2[k]] = val\n if (item == 'NOTSWAPPED'):\n kwds['swap'] = not val\n\n # now actually update array flags\n self._arr.setflags(**kwds)\n \n", "methods": [ { "name": "__init__", "long_name": "__init__( self , arr , flags )", "filename": "_internal.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "arr", "flags" ], "start_line": 24, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "_internal.py", "nloc": 38, "complexity": 17, "token_count": 298, "parameters": [ "self", "key" ], "start_line": 31, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , item , val )", "filename": "_internal.py", "nloc": 12, "complexity": 6, "token_count": 91, "parameters": [ "self", "item", "val" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , arr , flags )", "filename": "_internal.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "arr", "flags" ], "start_line": 24, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "_internal.py", "nloc": 38, "complexity": 17, "token_count": 298, "parameters": [ "self", "key" ], "start_line": 31, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , item , val )", "filename": "_internal.py", "nloc": 12, "complexity": 5, "token_count": 87, "parameters": [ "self", "item", "val" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "__setitem__", "long_name": "__setitem__( self , item , val )", "filename": "_internal.py", "nloc": 12, "complexity": 6, "token_count": 91, "parameters": [ "self", "item", "val" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 } ], "nloc": 74, "complexity": 25, "token_count": 552, "diff_parsed": { "added": [ "_setable = ['WRITEABLE', 'NOTSWAPPED', 'SWAPPED', 'UPDATEIFCOPY', 'ALIGNED',", " 'W','N','S','U','A']", "_setable2 = ['write','swap','swap','uic','align']*2", " if (item == 'NOTSWAPPED' or item == 'N'):" ], "deleted": [ "_setable = ['WRITEABLE', 'NOTSWAPPED', 'UPDATEIFCOPY', 'ALIGNED',", " 'W','N','U','A']", "_setable2 = ['write','swap','uic','align']*2", " if (item == 'NOTSWAPPED'):" ] } }, { "old_path": "scipy/base/src/arraytypes.inc.src", "new_path": "scipy/base/src/arraytypes.inc.src", "filename": "arraytypes.inc.src", "extension": "src", "change_type": "MODIFY", "diff": "@@ -381,6 +381,8 @@ static void\n @from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n \t PyArrayObject *aop) {\n \tregister intp i; \n+\t/* fprintf(stderr, \"Casting %d items from %p (@from@) to %p (@to@)\\n\",\n+\t n, ip, op); */\n \tfor(i=0;idescr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n\n\n#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n#incr= ip++*196,ip+=2*42#\n*/\n\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\t/* fprintf(stderr, \"Casting %d items from %p (@from@) to %p (@to@)\\n\",\n\t n, ip, op); */\n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;idescr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n\n\n#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n#incr= ip++*196,ip+=2*42#\n*/\n\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;ielsize;\n \t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n \t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n-\t\t\t}\t\t\t\n+\t\t\t}\n \t\t}\n \n \t\t/* still not the same -- or will we have to use buffers?*/\n@@ -977,11 +978,10 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \t\t\t\tmps[i] = (PyArrayObject *)new;\n \t\t\t}\n \t\t}\n-\n+\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n \t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n-\t\t\n }\n \n \n@@ -1003,15 +1003,14 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \n loop->meth = BUFFER_UFUNCLOOP;\n \t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n+\t\t\tcntcast += descr->elsize;\n if (i < self->nin) {\n loop->cast[i] = \\\n \t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n-\t\t\t\tcntcast += descr->elsize;\n \t\t\t}\n else {\n loop->cast[i] = descr->\\\n \t\t\t\t\tcast[mps[i]->descr->type_num];\n-\t\t\t\tcntcast += mps[i]->itemsize;\n \t\t\t}\n \n }\n@@ -1113,15 +1112,18 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \t\tchar *castptr;\n \t\tint oldsize=0;\n \t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n+\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n \t\tif (loop->buffer[0] == NULL) return -1;\n \t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n \t\tfor (i=0; inargs; i++) {\n \t\t\tif (i > 0)\n \t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n \t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n+\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n \t\t\tif (loop->cast[i]) {\n \t\t\t\tloop->castbuf[i] = castptr + \n \t\t\t\t\tloop->bufsize*oldsize;\n+\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n #define _PyD PyArray_DescrFromType\n \t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n #undef _PyD\n@@ -1320,10 +1322,12 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\tvoid **buffer = loop->buffer;\n \t\tvoid **castbuf = loop->castbuf;\n \t\tintp *steps = loop->steps;\n+\t\tBool pyobject[MAX_ARGS];\n \t\t\n \t\tfor (i=0; inargs; i++) {\n \t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n \t\t\tmpselsize[i] = mps[i]->itemsize;\n+\t\t\tpyobject[i] = (mps[i]->descr->type_num == PyArray_OBJECT);\n \t\t}\n \t\t/* Do generic buffered looping here (works for any kind of\n \t\t arrays): Everything uses a buffer. \n@@ -1337,12 +1341,23 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n 3. goto next position\n \t\t*/ \n \t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n+\t\t/*\n+\t\tfor (i=0; inargs; i++) {\n+\t\t\tfprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n+\t\t\t\titers[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n+\t\t}\n+\t\t*/\n \t\twhile (index < size) {\n \t\t\t/*copy input data */\n \t\t\tfor (i=0; inin; i++) {\n+\t\t\t\tif (pyobject[i]) {\n+\t\t\t\t\tPy_INCREF(*((PyObject **)iters[i]->dataptr));\n+\t\t\t\t}\n+\t\t\t\t/*\t\t\t\tfprintf(stderr, \"index = %d, i=%d, writing to %p\\n\", index, i, dptr[i]); */\n \t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n \t\t\t\t mpselsize[i]);\n \t\t\t\tdptr[i] += mpselsize[i];\n+\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n \t\t\t}\n \t\t\tbufcnt++;\n \t\t\tindex++; \n@@ -1351,6 +1366,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t\t\n \t\t\t\tfor (i=0; inin; i++) {\n \t\t\t\t\tif (swap[i]) {\n+\t\t\t\t\t\t/* fprintf(stderr, \"swapping...\\n\");*/\n \t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n \t\t\t\t\t\t\t bufcnt, 1, \n \t\t\t\t\t\t\t mpselsize[i]);\n@@ -1377,11 +1393,17 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t\t\t\t\t NULL, NULL);\n \t\t\t\t\t}\n \t\t\t\t\tif (swap[i]) {\n+\t\t\t\t\t\t/* fprintf(stderr, \"swapping back...\\n\"); */\n \t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n \t\t\t\t\t\t\t bufcnt, 1, \n \t\t\t\t\t\t\t mpselsize[i]);\n \t\t\t\t\t}\n \t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n+\t\t\t\t\t\t/* fprintf(stderr, \"temp=%d, i=%d; reading from %p\\n\", temp, i, dptr[i]);*/\n+\t\t\t\t\t\tif (pyobject[i]) {\n+\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)iters[i]->dataptr));\n+\t\t\t\t\t\t\tPy_INCREF(*((PyObject **)dptr[i]));\n+\t\t\t\t\t\t}\n \t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n \t\t\t\t\t\t dptr[i], mpselsize[i]);\n \t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n@@ -1390,17 +1412,13 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t\t\t}\n \t\t\t\tbufcnt = 0;\n \t\t\t\tfor (i=0; inargs; i++) \n-\t\t\t\t\tdptr[i] = loop->buffer[i];\n+\t\t\t\t\tdptr[i] = buffer[i];\n \t\t\t\t\n \t\t\t} \n-\n-\t\t\tfor (i=0; inin; i++) {\n-\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n-\t\t\t}\n \t\t}\n \t}\n \t}\t\n-\n+\t\n \tEND_THREADS\n \t\n Py_DECREF(loop);\n", "added_lines": 29, "deleted_lines": 11, "source_code": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n\t\t\tatype.type_num = arg_types[i];\n\t\t\tatype.itemsize = \\\n\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\tif (loop->size < loop->bufsize) {\n\t\t\t\tPyObject *new;\n\t\t\t\t/* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t*/\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | \n\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n\t\t\t\t\t\t UPDATEIFCOPY);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\tcntcast += descr->elsize;\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time. \n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tBool pyobject[MAX_ARGS];\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t\tpyobject[i] = (mps[i]->descr->type_num == PyArray_OBJECT);\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t\tfprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t\titers[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t}\n\t\t\t\t/*\t\t\t\tfprintf(stderr, \"index = %d, i=%d, writing to %p\\n\", index, i, dptr[i]); */\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping...\\n\");*/\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping back...\\n\"); */\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\t/* fprintf(stderr, \"temp=%d, i=%d; reading from %p\\n\", temp, i, dptr[i]);*/\n\t\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t\t\t\tPy_INCREF(*((PyObject **)dptr[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = buffer[i];\n\t\t\t\t\n\t\t\t} \n\t\t}\n\t}\n\t}\t\n\t\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n\t\t\tatype.type_num = arg_types[i];\n\t\t\tatype.itemsize = \\\n\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\t\t\t\n\t\t}\n\n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\tif (loop->size < loop->bufsize) {\n\t\t\t\tPyObject *new;\n\t\t\t\t/* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t*/\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | \n\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n\t\t\t\t\t\t UPDATEIFCOPY);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t\t\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t\tcntcast += descr->elsize;\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\tcntcast += mps[i]->itemsize;\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time. \n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = loop->buffer[i];\n\t\t\t\t\n\t\t\t} \n\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t}\n\t}\n\t}\t\n\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "methods": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 243, "complexity": 57, "token_count": 1882, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 340, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1148, "end_line": 1197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 115, "complexity": 23, "token_count": 830, "parameters": [ "self", "args", "mps" ], "start_line": 1265, "end_line": 1432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1435, "end_line": 1455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1458, "end_line": 1480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1489, "end_line": 1718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1730, "end_line": 1859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1863, "end_line": 1993, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 2015, "end_line": 2142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2151, "end_line": 2261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2268, "end_line": 2320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2323, "end_line": 2388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2396, "end_line": 2465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2469, "end_line": 2500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2503, "end_line": 2544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2547, "end_line": 2559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2562, "end_line": 2574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2578, "end_line": 2584, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2587, "end_line": 2594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2606, "end_line": 2675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2679, "end_line": 2683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2686, "end_line": 2690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2693, "end_line": 2696, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2716, "end_line": 2738, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2743, "end_line": 2826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2831, "end_line": 2834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 244, "complexity": 57, "token_count": 1891, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 338, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1146, "end_line": 1195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 22, "token_count": 758, "parameters": [ "self", "args", "mps" ], "start_line": 1263, "end_line": 1414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 152, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1417, "end_line": 1437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1440, "end_line": 1462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1471, "end_line": 1700, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1712, "end_line": 1841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1845, "end_line": 1975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 1997, "end_line": 2124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2133, "end_line": 2243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2250, "end_line": 2302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2305, "end_line": 2370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2378, "end_line": 2447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2451, "end_line": 2482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2485, "end_line": 2526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2529, "end_line": 2541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2544, "end_line": 2556, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2560, "end_line": 2566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2569, "end_line": 2576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2588, "end_line": 2657, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2661, "end_line": 2665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2668, "end_line": 2672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2675, "end_line": 2678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2698, "end_line": 2720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2725, "end_line": 2808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2813, "end_line": 2816, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 115, "complexity": 23, "token_count": 830, "parameters": [ "self", "args", "mps" ], "start_line": 1265, "end_line": 1432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 243, "complexity": 57, "token_count": 1882, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 340, "top_nesting_level": 0 } ], "nloc": 2123, "complexity": 433, "token_count": 15575, "diff_parsed": { "added": [ "", "\t\t\t}", "", "\t\t\tcntcast += descr->elsize;", "\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */", "\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */", "\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */", "\t\tBool pyobject[MAX_ARGS];", "\t\t\tpyobject[i] = (mps[i]->descr->type_num == PyArray_OBJECT);", "\t\t/*", "\t\tfor (i=0; inargs; i++) {", "\t\t\tfprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i,", "\t\t\t\titers[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));", "\t\t}", "\t\t*/", "\t\t\t\tif (pyobject[i]) {", "\t\t\t\t\tPy_INCREF(*((PyObject **)iters[i]->dataptr));", "\t\t\t\t}", "\t\t\t\t/*\t\t\t\tfprintf(stderr, \"index = %d, i=%d, writing to %p\\n\", index, i, dptr[i]); */", "\t\t\t\tPyArray_ITER_NEXT(iters[i]);", "\t\t\t\t\t\t/* fprintf(stderr, \"swapping...\\n\");*/", "\t\t\t\t\t\t/* fprintf(stderr, \"swapping back...\\n\"); */", "\t\t\t\t\t\t/* fprintf(stderr, \"temp=%d, i=%d; reading from %p\\n\", temp, i, dptr[i]);*/", "\t\t\t\t\t\tif (pyobject[i]) {", "\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)iters[i]->dataptr));", "\t\t\t\t\t\t\tPy_INCREF(*((PyObject **)dptr[i]));", "\t\t\t\t\t\t}", "\t\t\t\t\tdptr[i] = buffer[i];", "" ], "deleted": [ "\t\t\t}", "", "", "\t\t\t\tcntcast += descr->elsize;", "\t\t\t\tcntcast += mps[i]->itemsize;", "\t\t\t\t\tdptr[i] = loop->buffer[i];", "", "\t\t\tfor (i=0; inin; i++) {", "\t\t\t\tPyArray_ITER_NEXT(iters[i]);", "\t\t\t}", "" ] } }, { "old_path": "scipy/base/src/umathmodule.c.src", "new_path": "scipy/base/src/umathmodule.c.src", "filename": "umathmodule.c.src", "extension": "src", "change_type": "MODIFY", "diff": "@@ -850,6 +850,9 @@ static void\n \tregister intp i;\n \tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n \tchar *i1=args[0], *i2=args[1], *op=args[2];\n+\t/* fprintf(stderr, \"Multiplying %d elements of type @typ@\\n\", n);\n+\tfprintf(stderr, \"args= %p, %p, %p\\n\", i1, i2, op);\n+\tfprintf(stderr, \"steps=%d, %d, %d\\n\", is1, is2, os); */\n \tfor(i=0; i\n\n\n/* A whole slew of basic math functions are provided originally by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n#ifndef M_PI\n#define M_PI 3.14159265358979323846264338328\n#endif\n\n#ifndef HAVE_INVERSE_HYPERBOLIC\nstatic double acosh(double x)\n{\n\treturn log(x + sqrt((x-1.0)*(x+1.0)));\n}\n\nstatic double asinh(double xx)\n{\n\tdouble x;\n\tint sign;\n\tif (xx < 0.0) {\n\t\tsign = -1;\n\t\tx = -xx;\n\t}\n\telse {\n\t\tsign = 1;\n\t\tx = xx;\n\t}\n\treturn sign*log(x + sqrt(x*x+1.0));\n}\n\nstatic double atanh(double x)\n{\n\treturn 0.5*log((1.0+x)/(1.0-x));\n}\n#endif\n\n#if !defined(HAVE_INVERSE_HYPERBOLIC_FLOAT)\nstatic float acoshf(float x)\n{\n return (float)acosh((double)(x));\n}\n\nstatic float asinhf(float x)\n{\n return (float)asinh((double)(x));\n}\n\nstatic float atanhf(float x)\n{\n return (float)atanh((double)(x));\n}\n#endif\n\n#ifdef HAVE_HYPOT\n#if !defined(NeXT) && !defined(_MSC_VER)\nextern double hypot(double, double);\n#endif\n#else\ndouble hypot(double x, double y)\n{\n\tdouble yx;\n\n\tx = fabs(x);\n\ty = fabs(y);\n\tif (x < y) {\n\t\tdouble temp = x;\n\t\tx = y;\n\t\ty = temp;\n\t}\n\tif (x == 0.)\n\t\treturn 0.;\n\telse {\n\t\tyx = y/x;\n\t\treturn x*sqrt(1.+yx*yx);\n\t}\n}\n#endif\n\n\n\n/* Define isnan, isinf, isfinite, signbit if needed */\n/* Use fpclassify if possible */\n/* isnan, isinf --\n these will use macros and then fpclassify if available before\n defaulting to a dumb convert-to-double version...\n\n isfinite -- define a macro if not already available\n signbit -- if macro available use it, otherwise define a function\n and a dumb convert-to-double version for other types.\n*/\n\n#if defined(fpclassify)\n\n#if !defined(isnan)\n#define isnan(x) (fpclassify(x) == FP_NAN)\n#endif\n#if !defined(isinf)\n#define isinf(x) (fpclassify(x) == FP_INFINITE)\n#endif\n\n#else /* check to see if already have a function like this */\n\n#if !defined(HAVE_ISNAN)\n\n#if !defined(isnan)\n#include \"_isnan.c\"\n#endif\n\n#if !defined(isinf)\n#define isinf(x) (!isnan((x)) && isnan((x)-(x)))\n#endif\n\n#endif /* HAVE_ISNAN */\n#endif /* !defined(isnan) */\n\n\n/* Define signbit if needed */\n#if !defined(signbit)\n#include \"_signbit.c\"\n#endif\n\n\n/* Now defined the extended type macros */\n\n/* We assume that isnan and isinf are defined in the same \n way: as functions, with extended functions, or macros\n*/\n\n#if !defined(isnan)\n\n#if !defined(HAVE_LONGDOUBLE_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanl(x) isnan((double)(x)))\n#define isinfl(x) (!isnanl((x)) && isnanl((x)-(x)))\n#endif\n\n#if !defined(HAVE_FLOAT_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanf(x) isnan((double)(x)))\n#define isinff(x) (!isnanlf((x)) && isnanf((x)-(x))\n#endif\n\n#else /* !defined(isnan) */\n\n#define isnanl(x) isnan(x)\n#define isnanf(x) isnan(x)\n#define isinfl(x) isinf(x)\n#define isinff(x) isinf(x)\n\n#endif /* !defined(isnan) */\n\n\n\n#if !defined(signbit)\n#define signbitl(x) ((longdouble) signbit((double)(x)))\n#define signbitf(x) ((float) signbit((double) (x)))\n#else\n#define signbitl(x) signbit(x)\n#define signbitf(x) signbit(x)\n#endif\n\n#if !defined(isfinite)\n#define isfinite(x) (!(isinf(x) || isnan(x)))\n#endif\n#define isfinitef(x) (!(isinff(x) || isnanf(x)))\n#define isfinitel(x) (!(isinfl(x) || isnanl(x)))\n\n\n/* First, the C functions that do the real work */\n\n/* if C99 extensions not availble\n\nthen define dummy functions that use the double versions for\n\nsin, cos, tan\nsinh, cosh, tanh, \nfabs, floor, ceil, fmod, sqrt, log10, log, exp, fabs\nasin, acos, atan, \nasinh, acosh, atanh\n\nhypot, atan2, pow\n\n*/\n\n/**begin repeat\n\n#kind=(sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,sqrt,log10,log,exp,asin,acos,atan,asinh,acosh,atanh)*2#\n#typ=longdouble*19, float*19#\n#c=l*19,f*19#\n#TYPE=LONGDOUBLE*19, FLOAT*19#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x) {\n\treturn (@typ@) @kind@((double)x);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n\n#kind=(atan2,hypot,pow,fmod)*2#\n#typ=longdouble*4, float*4#\n#c=l*4,f*4#\n#TYPE=LONGDOUBLE*4,FLOAT*4#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x, @typ@ y) {\n\treturn (@typ@) @kind@((double)x, (double) y);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n#kind=modf*2#\n#typ=longdouble, float#\n#c=l,f#\n#TYPE=LONGDOUBLE, FLOAT#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ modf@c@(@typ@ x, @typ@ *iptr) {\n double nx, niptr, y;\n nx = (double) x;\n y = modf(nx, &niptr);\n *iptr = (@typ@) niptr;\n return (@typ@) y;\n}\n#endif\n/**end repeat**/\n\n\n\n/* Don't pass structures between functions (only pointers) because how\n structures are passed is compiler dependent and could cause\n segfaults if ufuncobject.c is compiled with a different compiler\n than an extension that makes use of the UFUNC API\n*/\n\n/**begin repeat\n\n#typ=float, double, longdouble#\n#c=f,,l#\n*/\n\n/* constants */\nstatic c@typ@ nc_1@c@ = {1., 0.};\nstatic c@typ@ nc_half@c@ = {0.5, 0.};\nstatic c@typ@ nc_i@c@ = {0., 1.};\nstatic c@typ@ nc_i2@c@ = {0., 0.5};\n/*\nstatic c@typ@ nc_mi@c@ = {0., -1.};\nstatic c@typ@ nc_pi2@c@ = {M_PI/2., 0.};\n*/\n\nstatic void\nnc_sum@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real + b->real;\n\tr->imag = a->imag + b->imag;\n\treturn;\n}\n\nstatic void\nnc_diff@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real - b->real;\n\tr->imag = a->imag - b->imag;\n\treturn;\n}\n\nstatic void\nnc_neg@c@(c@typ@ *a, c@typ@ *r)\n{\n\tr->real = -a->real;\n\tr->imag = -a->imag;\n\treturn;\n}\n\nstatic void\nnc_prod@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\tr->real = ar*br - ai*bi;\n\tr->imag = ar*bi + ai*br;\n\treturn;\n}\n\nstatic void\nnc_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = (ar*br + ai*bi)/d;\n\tr->imag = (ai*br - ar*bi)/d;\n\treturn;\n}\n\nstatic void\nnc_floor_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = floor@c@((ar*br + ai*bi)/d);\n\tr->imag = 0;\n\treturn;\n}\n\nstatic void \nnc_sqrt@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ s,d;\n\tif (x->real == 0. && x->imag == 0.)\n\t\t*r = *x;\n\telse {\n\t\ts = sqrt@c@(0.5*(fabs@c@(x->real) + hypot@c@(x->real,x->imag)));\n\t\td = 0.5*x->imag/s;\n\t\tif (x->real > 0.) {\n\t\t\tr->real = s;\n\t\t\tr->imag = d;\n\t\t}\n\t\telse if (x->imag >= 0.) {\n\t\t\tr->real = d;\n\t\t\tr->imag = s;\n\t\t}\n\t\telse {\n\t\t\tr->real = -d;\n\t\t\tr->imag = -s;\n\t\t}\n\t}\n\treturn;\n}\n\nstatic void \nnc_log@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ l = hypot@c@(x->real,x->imag);\n\tr->imag = atan2@c@(x->imag, x->real);\n\tr->real = log@c@(l);\n\treturn;\n}\n\nstatic void \nnc_exp@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ a = exp@c@(x->real);\n\tr->real = a*cos@c@(x->imag);\n\tr->imag = a*sin@c@(x->imag);\n\treturn;\n}\n\nstatic void\nnc_pow@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\t\n\tif (br == 0. && bi == 0.) {\n\t\tr->real = 1.;\n\t\tr->imag = 0.;\n\t}\n\telse if (ar == 0. && ai == 0.) {\n\t\tr->real = 0.;\n\t\tr->imag = 0.;\n\t}\n\telse {\n\t\tnc_log@c@(a, r);\n\t\tnc_prod@c@(r, b, r);\n\t\tnc_exp@c@(r, r);\n\t}\n\treturn;\n}\n\n\nstatic void \nnc_prodi@c@(c@typ@ *x, c@typ@ *r)\n{\n\tr->real = -x->imag;\n\tr->imag = x->real;\n\treturn;\n}\n\n\nstatic void \nnc_acos@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x,x,r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn; \n\t/* return nc_neg(nc_prodi(nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))))));\n\t*/\n}\n\nstatic void \nnc_acosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\treturn;\n\t/*\n\t return nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))));\n\t*/\n}\n\nstatic void \nnc_asin@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(x, pa);\n\tnc_sum@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/* \n\t return nc_neg(nc_prodi(nc_log(nc_sum(nc_prod(nc_i,x),\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x)))))));\n\t*/\n}\n\n\nstatic void \nnc_asinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_sum@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_diff@c@(r, x, r);\n\tnc_log@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/*\n\t return nc_neg(nc_log(nc_diff(nc_sqrt(nc_sum(nc_1,nc_prod(x,x))),x)));\n\t*/\n}\n\nstatic void \nnc_atan@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_i@c@, x, pa);\n\tnc_sum@c@(&nc_i@c@, x, r);\n\tnc_quot@c@(r, pa, r);\n\tnc_log@c@(r,r);\n\tnc_prod@c@(&nc_i2@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_i2,nc_log(nc_quot(nc_sum(nc_i,x),nc_diff(nc_i,x))));\n\t*/\n}\n\nstatic void \nnc_atanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_1@c@, x, r);\n\tnc_sum@c@(&nc_1@c@, x, pa);\n\tnc_quot@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prod@c@(&nc_half@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_half,nc_log(nc_quot(nc_sum(nc_1,x),nc_diff(nc_1,x))));\n\t*/\n}\n\nstatic void\nnc_cos@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos@c@(xr)*cosh@c@(xi);\n\tr->imag = -sin@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void \nnc_cosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos(xi)*cosh(xr);\n\tr->imag = sin(xi)*sinh(xr);\n\treturn;\n}\n\n\n#define M_LOG10_E 0.434294481903251827651128918916605082294397\n\nstatic void \nnc_log10@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_log@c@(x, r);\n\tr->real *= M_LOG10_E;\n\tr->imag *= M_LOG10_E;\n\treturn;\n}\n\nstatic void \nnc_sin@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = sin@c@(xr)*cosh@c@(xi);\n\tr->imag = cos@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void\nnc_sinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag; \n\tr->real = cos@c@(xi)*sinh@c@(xr);\n\tr->imag = sin@c@(xi)*cosh@c@(xr);\n\treturn;\n}\n\nstatic void \nnc_tan@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ sr,cr,shi,chi;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsr = sin@c@(xr);\n\tcr = cos@c@(xr);\n\tshi = sinh(xi);\n\tchi = cosh(xi);\n\trs = sr*chi;\n\tis = cr*shi;\n\trc = cr*chi;\n\tic = -sr*shi;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\nstatic void \nnc_tanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ si,ci,shr,chr;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsi = sin@c@(xi);\n\tci = cos@c@(xi);\n\tshr = sinh@c@(xr);\n\tchr = cosh@c@(xr);\n\trs = ci*shr;\n\tis = si*chr;\n\trc = ci*chr;\n\tic = si*shr;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#TYPE=(BOOL, BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*2#\n#OP=||, +*13, ^, -*13#\n#kind=add*14, subtract*14#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*2#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else\n\tah = al = bh = bl = 0;\n#endif\n\n /* 128-bit product: z*2**64 + (x+y)*2**32 + w */\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n\t/* *c = ((x + y)<<32) + w; */\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>32) || (y>>32) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 32);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>64) || (y>>64) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 64);\n#else\n\treturn 0;\n#endif\n\t\n}\n\nstatic int slonglong_overflow(longlong a0, longlong b0)\n{\n\tulonglong a, b;\n ulonglong ah, al, bh, bl, w, x, y, z;\n\n /* Convert to non-negative quantities */\n\tif (a0 < 0) { a = -a0; } else { a = a0; }\n\tif (b0 < 0) { b = -b0; } else { b = b0; }\n\n\n#if SIZEOF_LONGLONG == 64\n\tah = (a >> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else \n\tah = al = bh = bl = 0;\n#endif\n\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n /* \n\t ulonglong c = ((x + y)<<32) + w;\n\t if ((a0 < 0) ^ (b0 < 0))\n\t *c = -c;\n\t else \n\t *c = c\n\t */\n\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>31) || (y>>31) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 31);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>63) || (y>>63) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 63);\n#else\n\treturn 0;\n#endif\n}\n\n/** end direct numarray code **/\n\nstatic void\nBOOL_multiply(char **args, intp *dimensions, intp *steps, void *func) {\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nULONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tulonglong temp;\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\telse if (temp < MIN_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nLONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tlonglong temp;\n\tfor (i=0; i*17, >=*17, <*17, <=*17#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#\n#kind= greater*17, greater_equal*17, less*17, less_equal*17#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i>*10#\n#kind=remainder*10, bitwise_and*10, bitwise_or*10, bitwise_xor*10, left_shift*10, right_shift*10#\n\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i*17, <*17#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*2#\n#kind= maximum*17, minimum*17#\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i\n\n\n/* A whole slew of basic math functions are provided originally by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n#ifndef M_PI\n#define M_PI 3.14159265358979323846264338328\n#endif\n\n#ifndef HAVE_INVERSE_HYPERBOLIC\nstatic double acosh(double x)\n{\n\treturn log(x + sqrt((x-1.0)*(x+1.0)));\n}\n\nstatic double asinh(double xx)\n{\n\tdouble x;\n\tint sign;\n\tif (xx < 0.0) {\n\t\tsign = -1;\n\t\tx = -xx;\n\t}\n\telse {\n\t\tsign = 1;\n\t\tx = xx;\n\t}\n\treturn sign*log(x + sqrt(x*x+1.0));\n}\n\nstatic double atanh(double x)\n{\n\treturn 0.5*log((1.0+x)/(1.0-x));\n}\n#endif\n\n#if !defined(HAVE_INVERSE_HYPERBOLIC_FLOAT)\nstatic float acoshf(float x)\n{\n return (float)acosh((double)(x));\n}\n\nstatic float asinhf(float x)\n{\n return (float)asinh((double)(x));\n}\n\nstatic float atanhf(float x)\n{\n return (float)atanh((double)(x));\n}\n#endif\n\n#ifdef HAVE_HYPOT\n#if !defined(NeXT) && !defined(_MSC_VER)\nextern double hypot(double, double);\n#endif\n#else\ndouble hypot(double x, double y)\n{\n\tdouble yx;\n\n\tx = fabs(x);\n\ty = fabs(y);\n\tif (x < y) {\n\t\tdouble temp = x;\n\t\tx = y;\n\t\ty = temp;\n\t}\n\tif (x == 0.)\n\t\treturn 0.;\n\telse {\n\t\tyx = y/x;\n\t\treturn x*sqrt(1.+yx*yx);\n\t}\n}\n#endif\n\n\n\n/* Define isnan, isinf, isfinite, signbit if needed */\n/* Use fpclassify if possible */\n/* isnan, isinf --\n these will use macros and then fpclassify if available before\n defaulting to a dumb convert-to-double version...\n\n isfinite -- define a macro if not already available\n signbit -- if macro available use it, otherwise define a function\n and a dumb convert-to-double version for other types.\n*/\n\n#if defined(fpclassify)\n\n#if !defined(isnan)\n#define isnan(x) (fpclassify(x) == FP_NAN)\n#endif\n#if !defined(isinf)\n#define isinf(x) (fpclassify(x) == FP_INFINITE)\n#endif\n\n#else /* check to see if already have a function like this */\n\n#if !defined(HAVE_ISNAN)\n\n#if !defined(isnan)\n#include \"_isnan.c\"\n#endif\n\n#if !defined(isinf)\n#define isinf(x) (!isnan((x)) && isnan((x)-(x)))\n#endif\n\n#endif /* HAVE_ISNAN */\n#endif /* !defined(isnan) */\n\n\n/* Define signbit if needed */\n#if !defined(signbit)\n#include \"_signbit.c\"\n#endif\n\n\n/* Now defined the extended type macros */\n\n/* We assume that isnan and isinf are defined in the same \n way: as functions, with extended functions, or macros\n*/\n\n#if !defined(isnan)\n\n#if !defined(HAVE_LONGDOUBLE_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanl(x) isnan((double)(x)))\n#define isinfl(x) (!isnanl((x)) && isnanl((x)-(x)))\n#endif\n\n#if !defined(HAVE_FLOAT_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanf(x) isnan((double)(x)))\n#define isinff(x) (!isnanlf((x)) && isnanf((x)-(x))\n#endif\n\n#else /* !defined(isnan) */\n\n#define isnanl(x) isnan(x)\n#define isnanf(x) isnan(x)\n#define isinfl(x) isinf(x)\n#define isinff(x) isinf(x)\n\n#endif /* !defined(isnan) */\n\n\n\n#if !defined(signbit)\n#define signbitl(x) ((longdouble) signbit((double)(x)))\n#define signbitf(x) ((float) signbit((double) (x)))\n#else\n#define signbitl(x) signbit(x)\n#define signbitf(x) signbit(x)\n#endif\n\n#if !defined(isfinite)\n#define isfinite(x) (!(isinf(x) || isnan(x)))\n#endif\n#define isfinitef(x) (!(isinff(x) || isnanf(x)))\n#define isfinitel(x) (!(isinfl(x) || isnanl(x)))\n\n\n/* First, the C functions that do the real work */\n\n/* if C99 extensions not availble\n\nthen define dummy functions that use the double versions for\n\nsin, cos, tan\nsinh, cosh, tanh, \nfabs, floor, ceil, fmod, sqrt, log10, log, exp, fabs\nasin, acos, atan, \nasinh, acosh, atanh\n\nhypot, atan2, pow\n\n*/\n\n/**begin repeat\n\n#kind=(sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,sqrt,log10,log,exp,asin,acos,atan,asinh,acosh,atanh)*2#\n#typ=longdouble*19, float*19#\n#c=l*19,f*19#\n#TYPE=LONGDOUBLE*19, FLOAT*19#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x) {\n\treturn (@typ@) @kind@((double)x);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n\n#kind=(atan2,hypot,pow,fmod)*2#\n#typ=longdouble*4, float*4#\n#c=l*4,f*4#\n#TYPE=LONGDOUBLE*4,FLOAT*4#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x, @typ@ y) {\n\treturn (@typ@) @kind@((double)x, (double) y);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n#kind=modf*2#\n#typ=longdouble, float#\n#c=l,f#\n#TYPE=LONGDOUBLE, FLOAT#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ modf@c@(@typ@ x, @typ@ *iptr) {\n double nx, niptr, y;\n nx = (double) x;\n y = modf(nx, &niptr);\n *iptr = (@typ@) niptr;\n return (@typ@) y;\n}\n#endif\n/**end repeat**/\n\n\n\n/* Don't pass structures between functions (only pointers) because how\n structures are passed is compiler dependent and could cause\n segfaults if ufuncobject.c is compiled with a different compiler\n than an extension that makes use of the UFUNC API\n*/\n\n/**begin repeat\n\n#typ=float, double, longdouble#\n#c=f,,l#\n*/\n\n/* constants */\nstatic c@typ@ nc_1@c@ = {1., 0.};\nstatic c@typ@ nc_half@c@ = {0.5, 0.};\nstatic c@typ@ nc_i@c@ = {0., 1.};\nstatic c@typ@ nc_i2@c@ = {0., 0.5};\n/*\nstatic c@typ@ nc_mi@c@ = {0., -1.};\nstatic c@typ@ nc_pi2@c@ = {M_PI/2., 0.};\n*/\n\nstatic void\nnc_sum@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real + b->real;\n\tr->imag = a->imag + b->imag;\n\treturn;\n}\n\nstatic void\nnc_diff@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real - b->real;\n\tr->imag = a->imag - b->imag;\n\treturn;\n}\n\nstatic void\nnc_neg@c@(c@typ@ *a, c@typ@ *r)\n{\n\tr->real = -a->real;\n\tr->imag = -a->imag;\n\treturn;\n}\n\nstatic void\nnc_prod@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\tr->real = ar*br - ai*bi;\n\tr->imag = ar*bi + ai*br;\n\treturn;\n}\n\nstatic void\nnc_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = (ar*br + ai*bi)/d;\n\tr->imag = (ai*br - ar*bi)/d;\n\treturn;\n}\n\nstatic void\nnc_floor_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = floor@c@((ar*br + ai*bi)/d);\n\tr->imag = 0;\n\treturn;\n}\n\nstatic void \nnc_sqrt@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ s,d;\n\tif (x->real == 0. && x->imag == 0.)\n\t\t*r = *x;\n\telse {\n\t\ts = sqrt@c@(0.5*(fabs@c@(x->real) + hypot@c@(x->real,x->imag)));\n\t\td = 0.5*x->imag/s;\n\t\tif (x->real > 0.) {\n\t\t\tr->real = s;\n\t\t\tr->imag = d;\n\t\t}\n\t\telse if (x->imag >= 0.) {\n\t\t\tr->real = d;\n\t\t\tr->imag = s;\n\t\t}\n\t\telse {\n\t\t\tr->real = -d;\n\t\t\tr->imag = -s;\n\t\t}\n\t}\n\treturn;\n}\n\nstatic void \nnc_log@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ l = hypot@c@(x->real,x->imag);\n\tr->imag = atan2@c@(x->imag, x->real);\n\tr->real = log@c@(l);\n\treturn;\n}\n\nstatic void \nnc_exp@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ a = exp@c@(x->real);\n\tr->real = a*cos@c@(x->imag);\n\tr->imag = a*sin@c@(x->imag);\n\treturn;\n}\n\nstatic void\nnc_pow@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\t\n\tif (br == 0. && bi == 0.) {\n\t\tr->real = 1.;\n\t\tr->imag = 0.;\n\t}\n\telse if (ar == 0. && ai == 0.) {\n\t\tr->real = 0.;\n\t\tr->imag = 0.;\n\t}\n\telse {\n\t\tnc_log@c@(a, r);\n\t\tnc_prod@c@(r, b, r);\n\t\tnc_exp@c@(r, r);\n\t}\n\treturn;\n}\n\n\nstatic void \nnc_prodi@c@(c@typ@ *x, c@typ@ *r)\n{\n\tr->real = -x->imag;\n\tr->imag = x->real;\n\treturn;\n}\n\n\nstatic void \nnc_acos@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x,x,r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn; \n\t/* return nc_neg(nc_prodi(nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))))));\n\t*/\n}\n\nstatic void \nnc_acosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\treturn;\n\t/*\n\t return nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))));\n\t*/\n}\n\nstatic void \nnc_asin@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(x, pa);\n\tnc_sum@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/* \n\t return nc_neg(nc_prodi(nc_log(nc_sum(nc_prod(nc_i,x),\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x)))))));\n\t*/\n}\n\n\nstatic void \nnc_asinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_sum@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_diff@c@(r, x, r);\n\tnc_log@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/*\n\t return nc_neg(nc_log(nc_diff(nc_sqrt(nc_sum(nc_1,nc_prod(x,x))),x)));\n\t*/\n}\n\nstatic void \nnc_atan@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_i@c@, x, pa);\n\tnc_sum@c@(&nc_i@c@, x, r);\n\tnc_quot@c@(r, pa, r);\n\tnc_log@c@(r,r);\n\tnc_prod@c@(&nc_i2@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_i2,nc_log(nc_quot(nc_sum(nc_i,x),nc_diff(nc_i,x))));\n\t*/\n}\n\nstatic void \nnc_atanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_1@c@, x, r);\n\tnc_sum@c@(&nc_1@c@, x, pa);\n\tnc_quot@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prod@c@(&nc_half@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_half,nc_log(nc_quot(nc_sum(nc_1,x),nc_diff(nc_1,x))));\n\t*/\n}\n\nstatic void\nnc_cos@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos@c@(xr)*cosh@c@(xi);\n\tr->imag = -sin@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void \nnc_cosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos(xi)*cosh(xr);\n\tr->imag = sin(xi)*sinh(xr);\n\treturn;\n}\n\n\n#define M_LOG10_E 0.434294481903251827651128918916605082294397\n\nstatic void \nnc_log10@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_log@c@(x, r);\n\tr->real *= M_LOG10_E;\n\tr->imag *= M_LOG10_E;\n\treturn;\n}\n\nstatic void \nnc_sin@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = sin@c@(xr)*cosh@c@(xi);\n\tr->imag = cos@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void\nnc_sinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag; \n\tr->real = cos@c@(xi)*sinh@c@(xr);\n\tr->imag = sin@c@(xi)*cosh@c@(xr);\n\treturn;\n}\n\nstatic void \nnc_tan@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ sr,cr,shi,chi;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsr = sin@c@(xr);\n\tcr = cos@c@(xr);\n\tshi = sinh(xi);\n\tchi = cosh(xi);\n\trs = sr*chi;\n\tis = cr*shi;\n\trc = cr*chi;\n\tic = -sr*shi;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\nstatic void \nnc_tanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ si,ci,shr,chr;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsi = sin@c@(xi);\n\tci = cos@c@(xi);\n\tshr = sinh@c@(xr);\n\tchr = cosh@c@(xr);\n\trs = ci*shr;\n\tis = si*chr;\n\trc = ci*chr;\n\tic = si*shr;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#TYPE=(BOOL, BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*2#\n#OP=||, +*13, ^, -*13#\n#kind=add*14, subtract*14#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*2#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else\n\tah = al = bh = bl = 0;\n#endif\n\n /* 128-bit product: z*2**64 + (x+y)*2**32 + w */\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n\t/* *c = ((x + y)<<32) + w; */\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>32) || (y>>32) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 32);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>64) || (y>>64) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 64);\n#else\n\treturn 0;\n#endif\n\t\n}\n\nstatic int slonglong_overflow(longlong a0, longlong b0)\n{\n\tulonglong a, b;\n ulonglong ah, al, bh, bl, w, x, y, z;\n\n /* Convert to non-negative quantities */\n\tif (a0 < 0) { a = -a0; } else { a = a0; }\n\tif (b0 < 0) { b = -b0; } else { b = b0; }\n\n\n#if SIZEOF_LONGLONG == 64\n\tah = (a >> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else \n\tah = al = bh = bl = 0;\n#endif\n\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n /* \n\t ulonglong c = ((x + y)<<32) + w;\n\t if ((a0 < 0) ^ (b0 < 0))\n\t *c = -c;\n\t else \n\t *c = c\n\t */\n\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>31) || (y>>31) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 31);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>63) || (y>>63) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 63);\n#else\n\treturn 0;\n#endif\n}\n\n/** end direct numarray code **/\n\nstatic void\nBOOL_multiply(char **args, intp *dimensions, intp *steps, void *func) {\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nULONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tulonglong temp;\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\telse if (temp < MIN_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nLONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tlonglong temp;\n\tfor (i=0; i*17, >=*17, <*17, <=*17#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#\n#kind= greater*17, greater_equal*17, less*17, less_equal*17#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i>*10#\n#kind=remainder*10, bitwise_and*10, bitwise_or*10, bitwise_xor*10, left_shift*10, right_shift*10#\n\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i*17, <*17#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*2#\n#kind= maximum*17, minimum*17#\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; iob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_BOOL;\n\t\tchksize = sizeof(Bool);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\tchar *msg = \"Cannot copy-back to a read-only array.\";\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "source_code_before": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic int\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\tchar *msg = \"Cannot copy-back to a read-only array.\";\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "methods": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1194, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1206, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1240, "end_line": 1270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1274, "end_line": 1282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1288, "end_line": 1338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1345, "end_line": 1390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1394, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1492, "end_line": 1526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1531, "end_line": 1581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1584, "end_line": 1643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 10, "token_count": 307, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1735, "end_line": 1787, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1795, "end_line": 1798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1817, "end_line": 1829, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1832, "end_line": 1847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1851, "end_line": 1860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1863, "end_line": 1874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1942, "end_line": 1975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1981, "end_line": 2020, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2023, "end_line": 2042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2046, "end_line": 2065, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2069, "end_line": 2080, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2083, "end_line": 2094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2097, "end_line": 2109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2112, "end_line": 2115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2118, "end_line": 2121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2124, "end_line": 2127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2130, "end_line": 2133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2136, "end_line": 2139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2142, "end_line": 2145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2148, "end_line": 2151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2154, "end_line": 2157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2160, "end_line": 2163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2166, "end_line": 2169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2172, "end_line": 2175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2178, "end_line": 2181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2184, "end_line": 2187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2190, "end_line": 2193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2196, "end_line": 2199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2202, "end_line": 2205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2208, "end_line": 2211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2214, "end_line": 2217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2220, "end_line": 2223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2226, "end_line": 2229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2232, "end_line": 2235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2238, "end_line": 2241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2244, "end_line": 2247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2250, "end_line": 2253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2256, "end_line": 2259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2262, "end_line": 2265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2268, "end_line": 2271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2274, "end_line": 2278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2281, "end_line": 2285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2289, "end_line": 2307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2310, "end_line": 2325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2329, "end_line": 2355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2358, "end_line": 2383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2386, "end_line": 2408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2411, "end_line": 2433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2436, "end_line": 2458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2461, "end_line": 2465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2526, "end_line": 2564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2568, "end_line": 2589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2592, "end_line": 2597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2618, "end_line": 2665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2668, "end_line": 2704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2710, "end_line": 2727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2730, "end_line": 2742, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2745, "end_line": 2757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2761, "end_line": 2838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2841, "end_line": 2870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2876, "end_line": 2892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2897, "end_line": 2920, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2926, "end_line": 2942, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2946, "end_line": 2962, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2966, "end_line": 2982, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2985, "end_line": 3018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3022, "end_line": 3044, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3051, "end_line": 3066, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3086, "end_line": 3110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3114, "end_line": 3258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3263, "end_line": 3368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3372, "end_line": 3389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3393, "end_line": 3508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3515, "end_line": 3518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3521, "end_line": 3531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3604, "end_line": 3607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3611, "end_line": 3645, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3649, "end_line": 3652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3655, "end_line": 3688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3692, "end_line": 3699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3702, "end_line": 3710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3714, "end_line": 3728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3731, "end_line": 3775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3779, "end_line": 3782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3785, "end_line": 3792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3796, "end_line": 3803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3806, "end_line": 3826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3829, "end_line": 3851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3854, "end_line": 3857, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3861, "end_line": 3864, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3876, "end_line": 3934, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3939, "end_line": 3949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3953, "end_line": 3978, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3982, "end_line": 4014, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4017, "end_line": 4050, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4053, "end_line": 4090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4093, "end_line": 4096, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4099, "end_line": 4151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4327, "end_line": 4352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4355, "end_line": 4377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4384, "end_line": 4410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4413, "end_line": 4433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 123, "complexity": 28, "token_count": 661, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4436, "end_line": 4574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4577, "end_line": 4600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4604, "end_line": 4627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4631, "end_line": 4688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4692, "end_line": 4699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4705, "end_line": 4795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4801, "end_line": 4812, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4815, "end_line": 4850, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4857, "end_line": 4903, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4906, "end_line": 4996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 5000, "end_line": 5105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5108, "end_line": 5202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5205, "end_line": 5226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5230, "end_line": 5292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5295, "end_line": 5300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5303, "end_line": 5309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5363, "end_line": 5393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5403, "end_line": 5419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5425, "end_line": 5430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5433, "end_line": 5439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5442, "end_line": 5448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5454, "end_line": 5525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5528, "end_line": 5552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5562, "end_line": 5599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5604, "end_line": 5614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5617, "end_line": 5622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5625, "end_line": 5630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5634, "end_line": 5637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5641, "end_line": 5689, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5692, "end_line": 5744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5748, "end_line": 5867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5871, "end_line": 5903, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5906, "end_line": 5947, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5951, "end_line": 6073, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6086, "end_line": 6127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6132, "end_line": 6136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6201, "end_line": 6262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6270, "end_line": 6285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6291, "end_line": 6360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6364, "end_line": 6400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6406, "end_line": 6450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6468, "end_line": 6604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6610, "end_line": 6679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6682, "end_line": 6815, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6821, "end_line": 6851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6857, "end_line": 6868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6871, "end_line": 6880, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6883, "end_line": 6901, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1194, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1206, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1240, "end_line": 1270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1274, "end_line": 1282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1288, "end_line": 1338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1345, "end_line": 1390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1394, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1492, "end_line": 1526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1531, "end_line": 1581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1584, "end_line": 1643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 10, "token_count": 307, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1735, "end_line": 1787, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1795, "end_line": 1798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1817, "end_line": 1829, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1832, "end_line": 1847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1851, "end_line": 1860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1863, "end_line": 1874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1942, "end_line": 1975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1981, "end_line": 2020, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2023, "end_line": 2042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2046, "end_line": 2065, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2069, "end_line": 2080, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2083, "end_line": 2094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2097, "end_line": 2109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2112, "end_line": 2115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2118, "end_line": 2121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2124, "end_line": 2127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2130, "end_line": 2133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2136, "end_line": 2139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2142, "end_line": 2145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2148, "end_line": 2151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2154, "end_line": 2157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2160, "end_line": 2163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2166, "end_line": 2169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2172, "end_line": 2175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2178, "end_line": 2181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2184, "end_line": 2187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2190, "end_line": 2193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2196, "end_line": 2199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2202, "end_line": 2205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2208, "end_line": 2211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2214, "end_line": 2217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2220, "end_line": 2223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2226, "end_line": 2229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2232, "end_line": 2235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2238, "end_line": 2241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2244, "end_line": 2247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2250, "end_line": 2253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2256, "end_line": 2259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2262, "end_line": 2265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2268, "end_line": 2271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2274, "end_line": 2278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2281, "end_line": 2285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2289, "end_line": 2307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2310, "end_line": 2325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2329, "end_line": 2355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2358, "end_line": 2383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2386, "end_line": 2408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2411, "end_line": 2433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2436, "end_line": 2458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2461, "end_line": 2465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2526, "end_line": 2564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2568, "end_line": 2589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2592, "end_line": 2597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2618, "end_line": 2665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2668, "end_line": 2704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2710, "end_line": 2727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2730, "end_line": 2742, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2745, "end_line": 2757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2761, "end_line": 2838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2841, "end_line": 2870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2876, "end_line": 2892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2897, "end_line": 2920, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2926, "end_line": 2942, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2946, "end_line": 2962, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2966, "end_line": 2982, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2985, "end_line": 3018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3022, "end_line": 3044, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3051, "end_line": 3066, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3086, "end_line": 3110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3114, "end_line": 3258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3263, "end_line": 3368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3372, "end_line": 3389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3393, "end_line": 3508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3515, "end_line": 3518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3521, "end_line": 3531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3604, "end_line": 3607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3611, "end_line": 3645, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3649, "end_line": 3652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3655, "end_line": 3688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3692, "end_line": 3699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3702, "end_line": 3710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3714, "end_line": 3728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3731, "end_line": 3775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3779, "end_line": 3782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3785, "end_line": 3792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3796, "end_line": 3803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3806, "end_line": 3826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3829, "end_line": 3851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3854, "end_line": 3857, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3861, "end_line": 3864, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3876, "end_line": 3934, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3939, "end_line": 3949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3953, "end_line": 3978, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3982, "end_line": 4014, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4017, "end_line": 4050, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4053, "end_line": 4090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4093, "end_line": 4096, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4099, "end_line": 4151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4327, "end_line": 4352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4355, "end_line": 4377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4384, "end_line": 4410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4413, "end_line": 4433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 118, "complexity": 27, "token_count": 637, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4436, "end_line": 4569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4572, "end_line": 4595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4599, "end_line": 4622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4626, "end_line": 4683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4687, "end_line": 4694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4700, "end_line": 4790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4796, "end_line": 4807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4810, "end_line": 4845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4852, "end_line": 4898, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4901, "end_line": 4991, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 4995, "end_line": 5100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5103, "end_line": 5197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5200, "end_line": 5221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5225, "end_line": 5287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5290, "end_line": 5295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5298, "end_line": 5304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5358, "end_line": 5388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5398, "end_line": 5414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5420, "end_line": 5425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5428, "end_line": 5434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5437, "end_line": 5443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5449, "end_line": 5520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5523, "end_line": 5547, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5557, "end_line": 5594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5599, "end_line": 5609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5612, "end_line": 5617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5620, "end_line": 5625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5629, "end_line": 5632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5636, "end_line": 5684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5687, "end_line": 5739, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5743, "end_line": 5862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5866, "end_line": 5898, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5901, "end_line": 5942, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5946, "end_line": 6068, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6081, "end_line": 6122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6127, "end_line": 6131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6196, "end_line": 6257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6265, "end_line": 6280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6286, "end_line": 6355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6359, "end_line": 6395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6401, "end_line": 6445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6463, "end_line": 6599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6605, "end_line": 6674, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6677, "end_line": 6810, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6816, "end_line": 6846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6852, "end_line": 6863, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6866, "end_line": 6875, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6878, "end_line": 6896, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 123, "complexity": 28, "token_count": 661, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4436, "end_line": 4574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 } ], "nloc": 5457, "complexity": 1195, "token_count": 32592, "diff_parsed": { "added": [ "\tif (PyBool_Check(op)) {", "\t\tchktype = PyArray_BOOL;", "\t\tchksize = sizeof(Bool);", "\t\tgoto finish;", "\t}", " else if (PyInt_Check(op)) {" ], "deleted": [ " if (PyInt_Check(op)) {" ] } }, { "old_path": "scipy/base/src/arraytypes.inc.src", "new_path": "scipy/base/src/arraytypes.inc.src", "filename": "arraytypes.inc.src", "extension": "src", "change_type": "MODIFY", "diff": "@@ -368,34 +368,70 @@ VOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n \n \n /**begin repeat\n-\n-\n-#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n-#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n-#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n-#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n-#incr= ip++*196,ip+=2*42#\n+#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n+#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n+#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n+#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n+#incr= ip++*166,ip+=2*42#\n */\n-\n static void \n @from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n \t PyArrayObject *aop) {\n \tregister intp i; \n-\t/* fprintf(stderr, \"Casting %d items from %p (@from@) to %p (@to@)\\n\",\n-\t n, ip, op); */\n \tfor(i=0;idescr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*166,ip+=2*42#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;idescr->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->itemsize);\n return @func1@((@typ1@)t1);\n\t}\n}\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->itemsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_CheckScalar(op)) \n op2 = ((PyArrayObject *)op)->descr->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n else { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->itemsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_LONGDOUBLE, sizeof(longdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->itemsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, PyArray_CLONGDOUBLE, sizeof(clongdouble), \n !PyArray_ISNOTSWAPPED(ap));\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->itemsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->itemsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->itemsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->itemsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->itemsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->itemsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->itemsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->itemsize,len));\n\tif (ap->itemsize > len) {\n\t\tmemset(ov + len, 0, (ap->itemsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_getitem\");\n\n\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\n\targs = Py_BuildValue(\"OO\",u, ap);\n\tPy_DECREF(u);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL;\n int itemsize=ap->itemsize;\n\tint res;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_setitem\");\n\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tPyErr_Clear();\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\targs = Py_BuildValue(\"OOO\",u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n\n\n#to=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*17#\n#from=BOOL*14,BYTE*14,UBYTE*14,SHORT*14,USHORT*14,INT*14,UINT*14,LONG*14,ULONG*14,LONGLONG*14,ULONGLONG*14,FLOAT*14,DOUBLE*14,LONGDOUBLE*14,CFLOAT*14,CDOUBLE*14,CLONGDOUBLE*14#\n#totyp=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*17#\n#fromtyp=Bool*14,byte*14, ubyte*14, short*14, ushort*14, int*14, uint*14, long*14, ulong*14, longlong*14, ulonglong*14, float*14, double*14, longdouble*14, float*14, double*14, longdouble*14#\n#incr= ip++*196,ip+=2*42#\n*/\n\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\t/* fprintf(stderr, \"Casting %d items from %p (@from@) to %p (@to@)\\n\",\n\t n, ip, op); */\n\tfor(i=0;iitemsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;iitemsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->itemsize;\n\tint oskip=@oskip@;\n\tfor(i=0; iitemsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jitemsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; iitemsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; iitemsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; iitemsize;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\treturn t1 < t2 ? -1 : t1 == t2 ? 0 : 1;\n }\n}\n\n/**end repeat**/\n\n/* compare imaginary part first, then complex if equal imaginary */\n/**begin repeat \n#fname=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= float, double, longdouble#\n*/\n\nstatic int\n@fname@_compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap) \n{\n @type@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n\t\tif (*ip1 == *ip2) {\n\t\t\treturn ip1[1]itemsize >> 1;\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n\t\t/* copy to local, aligned variable */\n copy_and_swap(&t1, ip1, size, 1, 0, swap);\n\t\tcopy_and_swap(&t2, ip2, size, 1, 0, swap);\n\t\tif (t1 == t2) {\n\t\t\tcopy_and_swap(&t1, ip1+1, size, 1, 0, swap);\n\t\t\tcopy_and_swap(&t2, ip2+1, size, 1, 0, swap);\n\t\t\treturn (t1 < t2 ? -1 : (t1 == t2 ? 0 : 1));\n\t\t}\n\t\telse {\n\t\t\treturn t1 < t2 ? -1 : 1;\n\t\t}\n }\n}\n /**end repeat**/\n\nstatic int \nOBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap) \n{ \n\treturn PyObject_Compare(*ip1, *ip2);\n}\n\nstatic int \nSTRING_compare(char *ip1, char *ip2, PyArrayObject *ap)\n{\n\treturn strncmp(ip1, ip2, ap->itemsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->itemsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->itemsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->itemsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#name=BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n#out= Bool, intp, uintp, intp, uintp, intp, uintp, intp, uintp, longlong, ulonglong, float, double, longdouble#\n*/\n\nstatic void\n@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n\t void *ignore)\n{\n\t@out@ tmp=(@out@)0.0;\n\tint i;\n\tfor(i=0;iob_type->tp_as_number->nb_@name@(m1, newarr);\n+\t\t\t\t\tPy_DECREF(newarr);\n+\t\t\t\t}\n+\t\t\t}\n \t\t\tPy_DECREF(arr);\n \t\t}\n \t\treturn ret;\n@@ -218,6 +228,16 @@ gentype_@name@(PyObject *m1, PyObject *m2)\n \t\t\t\t\t\t \"toscalar\");\n \t\t\tPy_DECREF(tup);\n \t\t\tret = PyNumber_@PYNAME@(arr,m2);\n+\t\t\tif (ret==NULL) {\n+\t\t\t\tPyObject *newarr;\n+\t\t\t\tPyErr_Clear();\n+\t\t\t\t/* Convert object to Array and try again */\n+\t\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);\n+\t\t\t\tif (newarr!=NULL) {\n+\t\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(newarr, m2);\n+\t\t\t\t\tPy_DECREF(newarr);\n+\t\t\t\t}\n+\t\t\t}\n \t\t\tPy_DECREF(arr);\n \t\t}\n \t\treturn ret;\n", "added_lines": 20, "deleted_lines": 0, "source_code": "/* -*- c -*- */\n\n/**begin repeat\n\n#name=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object,#\n#type=Bool, signed char, short, int, long, longlong, unsigned char, unsigned short, unsigned int, unsigned long, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, PyObject *,char#\n*/\ntypedef struct {\n\tPyObject_HEAD;\n\t@type@ obval;\n} Py@name@ScalarObject;\n\n/**end repeat**/\n\n/* Inheritance established later when tp_bases is set (or tp_base for \n single inheritance) */\n\n/**begin repeat\n\n#name=numeric, integer, signedinteger, unsignedinteger, inexact, floating, complexfloating, flexible, \ncharacter#\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character#\n*/\n\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n\n#define PyStringScalarObject PyStringObject\n#define PyUnicodeScalarObject PyUnicodeObject\n\ntypedef struct {\n\tPyObject_VAR_HEAD;\n\tchar *obval;\n} PyVoidScalarObject;\n\n/* 0-dim array from array-scalar object */\n\nstatic PyObject *\nPyArray_FromScalar(PyObject *scalar, PyArray_Typecode *outcode)\n{\n\tPyArray_Typecode typecode;\n\tPyObject *r;\n\tchar *memptr;\n\tPyObject *ret;\n\n\t/* convert to 0-dim array of scalar typecode */\n\tPyArray_TypecodeFromScalar(scalar, &typecode);\n\tr = PyArray_New(&PyArray_Type, 0, NULL, typecode.type_num,\n\t\t\tNULL, NULL, typecode.itemsize, 0, NULL);\n\tif (r==NULL) return NULL;\n\n\tswitch(typecode.type_num) {\n\tcase PyArray_STRING:\n\t\tmemptr = PyString_AS_STRING(scalar);\n\t\tbreak;\n\tcase PyArray_UNICODE:\n\t\tmemptr = (char *)PyUnicode_AS_DATA(scalar);\n\t\tbreak;\n\tcase PyArray_VOID:\n\t\tmemptr = (((PyVoidScalarObject *)scalar)->obval);\n\t\tbreak;\n\tdefault:\n\t\tmemptr = &(((PyScalarObject *)scalar)->obval);\n\t\tbreak;\n\t}\n\n\tmemcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r));\n\tif (PyArray_ISOBJECT(r)) {\n\t\tPy_INCREF(*((PyObject **)memptr));\n\t}\n\t\n\tif (outcode == NULL || \\\n\t outcode->type_num == PyArray_NOTYPE ||\t\\\n\t outcode->type_num == PyArray_TYPE(r))\n\t\treturn r;\n\n\t/* cast if necessary to desired output typecode */\n\tret = PyArray_CastToType((PyArrayObject *)r, outcode);\n\tPy_DECREF(r);\n\treturn ret;\n}\n\n\nstatic void\ngentype_dealloc(PyObject *v) \n{\n\tv->ob_type->tp_free(v);\n}\n\n\nstatic PyObject *\ngentype_power(PyObject *m1, PyObject *m2, PyObject *m3)\n{\n\tPyObject *arr, *ret, *arg2;\n\tchar *msg=\"unsupported operand type(s) for ** or pow()\";\n\t\n\tif (!PyArray_IsScalar(m1,Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m2,Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(m1, arr,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(arr, m2,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=arg2=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\targ2 = PyArray_FromScalar(m2, NULL);\t\n\tif (arr == NULL || arg2 == NULL) {\n\t\tPy_XDECREF(arr); Py_XDECREF(arg2); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_power(arr, arg2, Py_None);\n\tPy_DECREF(arr);\n\tPy_DECREF(arg2);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_generic_method(PyObject *self, PyObject *args, PyObject *kwds, \n\t\t char *str)\n{\n\tPyObject *arr, *meth, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tmeth = PyObject_GetAttrString(arr, str);\n\tif (kwds == NULL) \n\t\tret = PyObject_CallObject(meth, args);\n\telse\n\t\tret = PyObject_Call(meth, args, kwds);\n\tPy_DECREF(meth);\n\tPy_DECREF(arr);\n\treturn PyArray_Return((PyArrayObject *)ret);\n}\n\n/**begin repeat\n\n#name=add, subtract, divide, remainder, divmod, lshift, rshift, and, xor, or, floor_divide, true_divide#\n#PYNAME=Add, Subtract, Divide, Remainder, Divmod, Lshift, Rshift, And, Xor, Or, FloorDivide, TrueDivide#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret, *tup;\n\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n else if ((m1->ob_type->tp_as_number == NULL) ||\n\t\t\t (m1->ob_type->tp_as_number->nb_@name@ == NULL)) {\n\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_@name@(m1, arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\telse {\n\t\t\t/* Convert m2 to a Python object and then try */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m2, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tif (arr == NULL) return NULL;\n ret = PyNumber_@PYNAME@(m1, arr);\n\t\t\tif (ret==NULL) {\n\t\t\t\tPyObject *newarr;\n\t\t\t\tPyErr_Clear();\n\t\t\t\t/* Convert object to Array scalar and try again */\n\t\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);\n\t\t\t\tif (newarr!=NULL) {\n\t\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(m1, newarr);\n\t\t\t\t\tPy_DECREF(newarr);\n\t\t\t\t}\n\t\t\t}\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n\t\telse if ((m2->ob_type->tp_as_number == NULL) ||\n\t\t\t (m2->ob_type->tp_as_number->nb_@name@ == NULL)) {\n\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_@name@(arr, m2);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\telse {\n\t\t\t/* Convert m1 to a Python object and then try */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m1, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tret = PyNumber_@PYNAME@(arr,m2);\n\t\t\tif (ret==NULL) {\n\t\t\t\tPyObject *newarr;\n\t\t\t\tPyErr_Clear();\n\t\t\t\t/* Convert object to Array and try again */\n\t\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);\n\t\t\t\tif (newarr!=NULL) {\n\t\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(newarr, m2);\n\t\t\t\t\tPy_DECREF(newarr);\n\t\t\t\t}\n\t\t\t}\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *\ngentype_multiply(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret, *tup;\n\tlong repeat;\n\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m1->ob_type->tp_as_number == NULL) ||\n\t\t\t (m1->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m2 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m2);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m1, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\\\n\t\t\t\t\tnb_multiply(m1, arr);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t/* Convert m2 to a Python object */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m2, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tif (arr == NULL) return NULL;\n ret = PyNumber_Multiply(m1, arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m2->ob_type->tp_as_number == NULL) ||\n\t\t\t (m2->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m1 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m1);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m2, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\t\\\n\t\t\t\t\tnb_multiply(arr, m2);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\t\t\t\n\t\t}\n\t\telse {\n\t\t\t/* Convert m1 to a Python object */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m1, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tif (arr == NULL) return NULL;\n ret = PyNumber_Multiply(arr, m2);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\t/* Both are array scalar objects */\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_multiply(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n\n}\n\n\n\n/**begin repeat\n\n#name=negative, absolute, invert, int, long, float, oct, hex#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1)\n{\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n/**end repeat**/\n\nstatic int\ngentype_nonzero_number(PyObject *m1)\n{\n\tPyObject *arr;\n\tint ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return -1;\n\tret = arr->ob_type->tp_as_number->nb_nonzero(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_str(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Str(arr->descr->getitem(arr->data, arr));\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_repr(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Repr(arr->descr->getitem(arr->data, arr));\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic void\nformat_longdouble(char *buf, size_t buflen, longdouble val, int precision)\n{\n register char *cp;\n\n PyOS_snprintf(buf, buflen, \"%.*\" LONGDOUBLE_FMT, precision, val);\n cp = buf;\n if (*cp == '-')\n cp++;\n for (; *cp != '\\0'; cp++) {\n if (!isdigit(Py_CHARMASK(*cp)))\n break;\n }\n if (*cp == '\\0') {\n *cp++ = '.';\n *cp++ = '0';\n *cp++ = '\\0';\n }\n}\n\n#if SIZEOF_LONGDOUBLE == SIZEOF_DOUBLE\n#define PREC_REPR 15\n#define PREC_STR 15\n#else\n#define PREC_REPR 21\n#define PREC_STR 21\n#endif\n\nstatic PyObject *\nlongdoubletype_repr(PyObject *self)\n{\n static char buf[100];\n format_longdouble(buf, sizeof(buf), ((PyLongDoubleScalarObject *)self)->obval, PREC_REPR);\n return PyString_FromString(buf);\n}\n\nstatic PyObject *\nclongdoubletype_repr(PyObject *self)\n{\n static char buf1[100];\n static char buf2[100];\n\tstatic char buf3[202];\n clongdouble x;\n x = ((PyCLongDoubleScalarObject *)self)->obval;\n format_longdouble(buf1, sizeof(buf1), x.real, PREC_REPR);\n format_longdouble(buf2, sizeof(buf2), x.imag, PREC_REPR);\n\n\tsnprintf(buf3, sizeof(buf3), \"(%s+%sj)\", buf1, buf2);\n\treturn PyString_FromString(buf3);\n}\n\n#define longdoubletype_str longdoubletype_repr\n#define clongdoubletype_str clongdoubletype_repr\n\n/** Could improve this with a PyLong_FromLongDouble(longdouble ldval)\n but this would need some more work...\n**/\n\n/**begin repeat\n\n#name=(int, long, hex, oct, float)*2#\n#KIND=(Long*4, Float)*2#\n#char=,,,,,c*5#\n#CHAR=,,,,,C*5#\n#POST=,,,,,.real*5#\n*/\nstatic PyObject *\n@char@longdoubletype_@name@(PyObject *self)\n{\n\tdouble dval;\n\tPyObject *obj, *ret;\n\t\n\tdval = (double)(((Py@CHAR@LongDoubleScalarObject *)self)->obval)@POST@;\n\tobj = Py@KIND@_FromDouble(dval);\n\tret = obj->ob_type->tp_as_number->nb_@name@(obj);\n\tPy_DECREF(obj);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *gentype_copy(PyObject *, PyObject *);\n\nstatic PyNumberMethods gentype_as_number = {\n (binaryfunc)gentype_add,\t\t /*nb_add*/\n (binaryfunc)gentype_subtract,\t\t /*nb_subtract*/\n (binaryfunc)gentype_multiply,\t\t /*nb_multiply*/\n (binaryfunc)gentype_divide,\t\t /*nb_divide*/\n (binaryfunc)gentype_remainder,\t /*nb_remainder*/\n (binaryfunc)gentype_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)gentype_power,\t\t /*nb_power*/\n (unaryfunc)gentype_negative,\t \n (unaryfunc)gentype_copy,\t\t /*nb_pos*/ \n (unaryfunc)gentype_absolute,\t\t /*(unaryfunc)gentype_abs,*/\n (inquiry)gentype_nonzero_number,\t\t /*nb_nonzero*/\n (unaryfunc)gentype_invert,\t\t /*nb_invert*/\n (binaryfunc)gentype_lshift,\t /*nb_lshift*/\n (binaryfunc)gentype_rshift,\t /*nb_rshift*/\n (binaryfunc)gentype_and,\t /*nb_and*/\n (binaryfunc)gentype_xor,\t /*nb_xor*/\n (binaryfunc)gentype_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)gentype_int,\t\t /*nb_int*/\n (unaryfunc)gentype_long,\t\t /*nb_long*/\n (unaryfunc)gentype_float,\t\t /*nb_float*/\n (unaryfunc)gentype_oct,\t\t /*nb_oct*/\n (unaryfunc)gentype_hex,\t\t /*nb_hex*/\n 0, /*inplace_add*/\n 0, /*inplace_subtract*/\n 0, /*inplace_multiply*/\n 0, /*inplace_divide*/\n 0, /*inplace_remainder*/\n 0, /*inplace_power*/\n 0, /*inplace_lshift*/\n 0, /*inplace_rshift*/\n 0, /*inplace_and*/\n 0, /*inplace_xor*/\n 0, /*inplace_or*/\n (binaryfunc)gentype_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)gentype_true_divide,\t /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n\n};\n\nstatic PyObject *\ngentype_richcompare(PyObject *self, PyObject *other, int cmp_op) \n{\n\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_richcompare(arr, other, cmp_op);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_ndim_get(PyObject *self)\n{\n\treturn PyInt_FromLong(0);\n}\n\nstatic PyObject *\ngentype_flags_get(PyObject *self)\n{\n\tPyObject *dict;\n\tdict = PyDict_New();\t\n\n#define ADDFLAG(flag, val) PyDict_SetItemString(dict, #flag, Py_##val);\n\n ADDFLAG(CONTIGUOUS, True);\n ADDFLAG(OWN_DATA, True);\n ADDFLAG(FORTRAN, True);\n ADDFLAG(ALIGNED, True);\n ADDFLAG(NOTSWAPPED, True);\n ADDFLAG(WRITEABLE, False);\n ADDFLAG(UPDATEIFCOPY, False);\n\treturn dict;\n#undef ADDFLAG\n}\n\nstatic PyObject *\ngentype_shape_get(PyObject *self)\n{\n\treturn PyTuple_New(0);\n}\n\n/*\nstatic int\ngentype_shape_set(PyObject *self, PyObject *val)\n{\n\tif (!PyTuple_Check(val) || PyTuple_GET_SIZE(val) > 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \\\n\t\t\t\t\"invalid shape for scalar\");\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n*/\n\n\nstatic PyObject *\ngentype_data_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\n\treturn PyBuffer_FromObject(self, 0, typecode.itemsize);\n}\n\n\nstatic PyObject *\ngentype_itemsize_get(PyObject *self)\n{\t\n\tPyArray_Typecode typecode;\n\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\treturn PyInt_FromLong((long) typecode.itemsize);\n}\n\nstatic PyObject *\ngentype_size_get(PyObject *self)\n{\n\treturn PyInt_FromLong(1);\n}\n\n\nstatic PyObject *\ngentype_typechar_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\tPyArray_Descr *descr;\n\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\tdescr = PyArray_DescrFromType(typecode.type_num);\n\tif (PyArray_IsScalar(self, Flexible)) \n\t\treturn PyString_FromFormat(\"%c%d\", (int)(descr->type),\n\t\t\t\t\t typecode.itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(descr->type), 1);\n}\n\nstatic PyObject *\ngentype_typestr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"dtypestr\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_descr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"__array_descr__\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\n\nstatic PyObject *\ngentype_typenum_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\treturn PyInt_FromLong((long) typecode.type_num);\n}\n\nstatic PyObject *\ngentype_type_get(PyObject *self)\n{\n\treturn (PyObject *)self->ob_type;\n}\n\n\nstatic PyObject *\ngentype_base_get(PyObject *self)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic PyObject *\ngentype_real_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\tPyArray_TypecodeFromScalar(self, &typecode);\n\t\treturn PyArray_Scalar(&(((PyScalarObject *)self)->obval),\n\t\t\t\t typecode.type_num-PyArray_NUM_FLOATTYPE,\n\t\t\t\t typecode.itemsize >> 1, 0);\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tPyObject *ret;\n\t\tret = PyObject_GetAttrString(obj, \"real\");\n\t\tif (ret != NULL) return ret;\n\t}\n\tPy_INCREF(self);\n\treturn (PyObject *)self;\n}\n\nstatic PyObject *\ngentype_imag_get(PyObject *self)\n{\t\n\tPyArray_Typecode typecode;\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\ttypecode.itemsize >>= 1;\n\t\treturn PyArray_Scalar(&(((PyScalarObject *)self)->obval)\n\t\t\t\t + typecode.itemsize, \n\t\t\t\t typecode.type_num-PyArray_NUM_FLOATTYPE,\n\t\t\t\t typecode.itemsize, 0);\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tPyObject *ret;\n\t\tret = PyObject_GetAttrString(obj, \"imag\");\n\t\tif (ret == NULL) {\n\t\t\tPyErr_Clear();\n\t\t\tobj = PyInt_FromLong(0);\n\t\t\tret = PyArray_Scalar((char *)&obj, PyArray_OBJECT, \n\t\t\t\t\t sizeof(void *), 0);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *ret;\n\t\tchar *temp;\n\t\ttemp = PyDataMem_NEW(typecode.itemsize);\n\t\tmemset(temp, '\\0', typecode.itemsize);\n\t\tret = PyArray_Scalar(temp, typecode.type_num,\n\t\t\t\t typecode.itemsize, 0);\n\t\tPyDataMem_FREE(temp);\n\t\treturn ret;\n\t}\n}\n\nstatic PyObject *\ngentype_flat_get(PyObject *self)\n{\n\tPyObject *ret, *arr;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = PyArray_IterNew(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyGetSetDef gentype_getsets[] = {\n {\"ndim\", \n\t (getter)gentype_ndim_get, \n\t (setter) 0, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)gentype_flags_get, \n\t (setter)0, \n\t \"integer value of flags\"},\n {\"shape\", \n\t (getter)gentype_shape_get, \n\t (setter)0, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)gentype_shape_get, \n\t (setter) 0, \n\t \"tuple of bytes steps in each dimension\"},\n {\"data\",\n\t (getter)gentype_data_get, \n\t (setter) 0, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)gentype_itemsize_get, \n\t (setter)0, \n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)gentype_size_get,\n (setter)0,\n \"number of elements in the gentype\"},\n\t{\"base\",\n\t (getter)gentype_base_get,\n\t (setter)0,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)gentype_type_get, \n\t (setter)0, \n\t \"get gentype type class\"},\n\t{\"dtypechar\",\n\t (getter)gentype_typechar_get,\n\t (setter)0,\n\t \"get gentype type character code\"},\n\t{\"dtypenum\",\n\t (getter)gentype_typenum_get,\n\t (setter)0,\n\t \"get gentype type number code\"},\n\t{\"dtypestr\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)gentype_real_get, \n\t (setter)0,\n\t \"real part of scalar\"},\n {\"imag\", \n\t (getter)gentype_imag_get, \n\t (setter)0, \n\t \"imaginary part of scalar\"},\n\t{\"flat\", \n\t (getter)gentype_flat_get, \n\t (setter)0, \n\t \"a 1-d view of scalar\"}, \n\t{\"__array_data__\", \n\t (getter)gentype_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)gentype_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t/* Does not have __array_priority__ because it is not a subtype.\n\t */\n \t{NULL, NULL, NULL, NULL} /* Sentinel */\n};\n\n/* 0-dim array from scalar object */\n\nstatic char doc_getarray[] = \"sc.__array__(|type) return 0-dim array\";\n\nstatic PyObject *\ngentype_getarray(PyObject *scalar, PyObject *args) \n{\n\tPyArray_Typecode outcode = {PyArray_NOTYPE, 0, 0};\n\n\tif (!PyArg_ParseTuple(args, \"|O&\", &PyArray_TypecodeConverter,\n\t\t\t &outcode)) return NULL;\n\treturn PyArray_FromScalar(scalar, &outcode);\n}\n\nstatic char doc_sc_wraparray[] = \"sc.__array_wrap__(obj) return scalar from array\";\n\nstatic PyObject *\ngentype_wraparray(PyObject *scalar, PyObject *args)\n{\n\tPyObject *arr;\n\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument.\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_Scalar(PyArray_DATA(arr), PyArray_TYPE(arr),\n\t\t\t PyArray_ITEMSIZE(arr), !PyArray_ISNOTSWAPPED(arr));\n}\n\n\n/**begin repeat\n\n#name=tolist, toscalar, tostring, astype, copy, resize, __deepcopy__, choose, sort, argsort, searchsorted, argmax, argmin, reshape, view, swapaxes, max, min, ptp, conj, conjugate, nonzero, all, any, flatten, ravel#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args)\n{\n\treturn gentype_generic_method(self, args, NULL, \"@name@\");\n}\n/**end repeat**/\n\nstatic PyObject *\ngentype_squeeze(PyObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tPy_INCREF(self);\n\treturn self;\n}\n\nstatic int\ngentype_getreadbuf(PyObject *, int, void **);\n\nstatic PyObject *\ngentype_byteswap(PyObject *self, PyObject *args)\n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\tif (inplace) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot byteswap a scalar in-place\");\n\t\treturn NULL;\n\t}\n\telse {\n\t\t/* get the data, copyswap it and pass it to a new Array scalar\n\t\t */\n\t\tchar *data;\n\t\tint numbytes;\n\t\tPyArray_Typecode type;\n\t\tPyArray_Descr *descr;\n\t\tPyObject *new;\n\t\tchar *newmem;\n\n\t\tnumbytes = gentype_getreadbuf(self, 0, (void **)&data);\n\t\tPyArray_TypecodeFromScalar(self, &type);\n\t\tnewmem = malloc(type.itemsize);\n\t\tif (newmem == NULL) return PyErr_NoMemory();\n\t\telse memcpy(newmem, data, type.itemsize);\n\t\tdescr = PyArray_DescrFromType(type.type_num);\n\t\tdescr->copyswap(newmem, NULL, 1, type.itemsize);\t\t\n\t\tnew = PyArray_Scalar(newmem, type.type_num, type.itemsize, 0);\n\t\tfree(newmem);\n\t\treturn new;\n\t}\n}\n\n/**begin repeat\n\n#name=transpose, getfield, take, put, putmask, repeat, tofile, mean, trace, diagonal, clip, std, sum, cumsum, prod, cumprod, compress#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\treturn gentype_generic_method(self, args, kwds, \"@name@\");\n}\n/**end repeat**/\n\n\nstatic PyObject *\ngentype_reduce(PyObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *obj=NULL, *mod=NULL;\n\tconst char *buffer; \n\tint buflen;\n\n\t/* Return a tuple of (callable object, arguments) */\n\n\tret = PyTuple_New(2);\n\tif (ret == NULL) return NULL;\t\n\tif (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) return NULL;\n\tobj = PyObject_GetAttrString(mod, \"scalar\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) return NULL;\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tobj = PyObject_GetAttrString((PyObject *)self, \"dtypestr\");\n\tif PyArray_IsScalar(self, Object) {\n\t\tmod = ((PyObjectScalarObject *)self)->obval;\n\t\tPyTuple_SET_ITEM(ret, 1,\n\t\t\t\t Py_BuildValue(\"NO\", obj, mod));\n\t}\n\telse {\n\t\tmod = PyString_FromStringAndSize(buffer, buflen);\n\t\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t\t Py_BuildValue(\"NN\", obj, mod));\n\t}\n\treturn ret;\n}\n\n/* ignores everything */\nstatic PyObject *\ngentype_setstate(PyObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn (Py_None);\n}\n\nstatic PyObject *\ngentype_dump(PyObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump(self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyObject *\ngentype_dumps(PyObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps(self, 2);\n}\n\n\n/* setting flags cannot be done for scalars */\nstatic PyObject *\ngentype_setflags(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic int _array_typecode_fromstr(char *, int *, PyArray_Typecode *);\n\n/* need to fill in doc-strings for these methods on import -- copy from \n array docstrings \n*/\nstatic PyMethodDef gentype_methods[] = {\n {\"tolist\",\t (PyCFunction)gentype_tolist,\t1, NULL},\n {\"toscalar\", (PyCFunction)gentype_toscalar, METH_VARARGS, NULL},\n\t{\"tofile\", (PyCFunction)gentype_tofile, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"tostring\", (PyCFunction)gentype_tostring, METH_VARARGS, NULL},\n {\"byteswap\", (PyCFunction)gentype_byteswap,1, NULL},\n {\"astype\", (PyCFunction)gentype_astype, 1, NULL},\n\t{\"getfield\", (PyCFunction)gentype_getfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n {\"copy\", (PyCFunction)gentype_copy, 1, NULL}, \n {\"resize\", (PyCFunction)gentype_resize, 1, NULL}, \n\n\t{\"__array__\", (PyCFunction)gentype_getarray, 1, doc_getarray},\n\t{\"__array_wrap__\", (PyCFunction)gentype_wraparray, 1, doc_sc_wraparray},\n\n /* for the copy module */\n {\"__copy__\", (PyCFunction)gentype_copy, 1, NULL},\n {\"__deepcopy__\", (PyCFunction)gentype___deepcopy__, 1, NULL},\n\n\n {\"__reduce__\", (PyCFunction) gentype_reduce, 1, NULL},\t\n\t/* For consistency does nothing */\n\t{\"__setstate__\", (PyCFunction) gentype_setstate, 1, NULL},\n\n\t{\"dumps\", (PyCFunction) gentype_dumps, 1, NULL},\n\t{\"dump\", (PyCFunction) gentype_dump, 1, NULL},\n\n\t/* Methods for array */\n\t{\"transpose\",\t(PyCFunction)gentype_transpose, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"take\",\t(PyCFunction)gentype_take, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"put\",\t(PyCFunction)gentype_put, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"putmask\",\t(PyCFunction)gentype_putmask, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"repeat\",\t(PyCFunction)gentype_repeat, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"choose\",\t(PyCFunction)gentype_choose, \n\t METH_VARARGS, NULL},\t\n\t{\"sort\",\t(PyCFunction)gentype_sort, \n\t METH_VARARGS, NULL},\n\t{\"argsort\",\t(PyCFunction)gentype_argsort, \n\t METH_VARARGS, NULL},\n\t{\"searchsorted\", (PyCFunction)gentype_searchsorted, \n\t METH_VARARGS, NULL},\t\n\t{\"argmax\",\t(PyCFunction)gentype_argmax, \n\t METH_VARARGS, NULL},\n\t{\"argmin\", (PyCFunction)gentype_argmin,\n\t METH_VARARGS, NULL},\n\t{\"reshape\",\t(PyCFunction)gentype_reshape, \n\t METH_VARARGS, NULL},\n\t{\"squeeze\",\t(PyCFunction)gentype_squeeze, \n\t METH_VARARGS, NULL},\n\t{\"view\", (PyCFunction)gentype_view, \n\t METH_VARARGS, NULL},\n\t{\"swapaxes\", (PyCFunction)gentype_swapaxes,\n\t METH_VARARGS, NULL},\n\t{\"max\", (PyCFunction)gentype_max,\n\t METH_VARARGS, NULL},\n\t{\"min\", (PyCFunction)gentype_min,\n\t METH_VARARGS, NULL},\n\t{\"ptp\", (PyCFunction)gentype_ptp,\n\t METH_VARARGS, NULL},\n\t{\"mean\", (PyCFunction)gentype_mean,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"trace\", (PyCFunction)gentype_trace,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"diagonal\", (PyCFunction)gentype_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"clip\", (PyCFunction)gentype_clip,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"conj\", (PyCFunction)gentype_conj,\n\t METH_VARARGS, NULL},\n\t{\"conjugate\", (PyCFunction)gentype_conjugate,\n\t METH_VARARGS, NULL},\n\t{\"nonzero\", (PyCFunction)gentype_nonzero,\n\t METH_VARARGS, NULL},\n\t{\"std\", (PyCFunction)gentype_std,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"sum\", (PyCFunction)gentype_sum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumsum\", (PyCFunction)gentype_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"prod\", (PyCFunction)gentype_prod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumprod\", (PyCFunction)gentype_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"all\", (PyCFunction)gentype_all,\n\t METH_VARARGS, NULL},\n\t{\"any\", (PyCFunction)gentype_any,\n\t METH_VARARGS, NULL},\n\t{\"compress\", (PyCFunction)gentype_compress,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"flatten\", (PyCFunction)gentype_flatten,\n\t METH_VARARGS, NULL},\n\t{\"ravel\", (PyCFunction)gentype_ravel,\n\t METH_VARARGS, NULL},\n\t{\"setflags\", (PyCFunction)gentype_setflags,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t/* add other methods!!! */\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic int\ngentype_getreadbuf(PyObject *self, int segment, void **ptrptr)\n{\n\tint numbytes;\n\tPyArray_Typecode outcode;\n\t\n\tif (segment != 0) {\n\t\tPyErr_SetString(PyExc_SystemError, \n\t\t\t\t\"Accessing non-existent array segment\");\n\t\treturn -1;\n\t}\n\n\tPyArray_TypecodeFromScalar(self, &outcode);\n\tnumbytes = outcode.itemsize;\n\tif PyArray_IsScalar(self, Flexible) {\n\t\tif PyArray_IsScalar(self, String)\n\t\t\t*ptrptr = PyString_AS_STRING(self);\n\t\telse if PyArray_IsScalar(self, Unicode)\n\t\t\t*ptrptr = (char *)PyUnicode_AS_DATA(self);\n\t\telse if PyArray_IsScalar(self, Void)\n\t\t\t*ptrptr = ((PyVoidScalarObject *)self)->obval;\n\t}\n\telse \n\t\t*ptrptr = (void *)&(((PyScalarObject *)self)->obval);\n\n\treturn numbytes;\n}\n\nstatic int\ngentype_getsegcount(PyObject *self, int *lenp)\n{\n\tPyArray_Typecode outcode;\n\n\tPyArray_TypecodeFromScalar(self, &outcode);\n\tif (lenp)\n\t\t*lenp = outcode.itemsize;\n\treturn 1;\n}\n\nstatic int\ngentype_getcharbuf(PyObject *self, int segment, const char **ptrptr)\n{\n\tif (PyArray_IsScalar(self, String) ||\t\\\n\t PyArray_IsScalar(self, Unicode))\n\t\treturn gentype_getreadbuf(self, segment, (void **)ptrptr);\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"Non-character array cannot be interpreted \"\\\n\t\t\t\t\"as character buffer.\");\n\t\treturn -1;\n\t}\n}\n\n\nstatic PyBufferProcs gentype_as_buffer = {\n (getreadbufferproc)gentype_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)0, /*bf_getwritebuffer*/\n (getsegcountproc)gentype_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)gentype_getcharbuf, /*bf_getcharbuffer*/\n};\n\n\n#define BASEFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES\n#define LEAFFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES\n\nstatic PyTypeObject PyGenericArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"generic_arrtype\",\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n\n/* works for VOID and UNICODE */\n\nstatic void\nflexible_dealloc(PyObject *v) \n{\n\tPyDataMem_FREE(((PyVoidScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nstring_arrtype_dealloc(PyObject *v)\n{\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nobject_arrtype_dealloc(PyObject *v)\n{\n\tPy_DECREF(((PyObjectScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\n/* string and unicode inherit from Python Type first and so GET_ITEM is different to\n get to the Python Type.\n */\n\n/**begin repeat \n#name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object#\n#TYPE=BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT#\n#num=1*16,0,0,1#\n*/\nstatic PyObject *\n@name@_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0, 0};\n\n\tif (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) {\n\t\tPyTypeObject *sup;\n\t\tPyObject *ret;\n\t\t/* We are inheriting from a Python type as well so\n\t\t give it first dibs on conversion */\n\t\tsup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, @num@);\n\t\tret = sup->tp_new(type, args, kwds);\n\t\tif (ret) return ret;\n\t\tPyErr_Clear();\n\t\t/* now do default conversion */\n\t}\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\n\ttypecode.type_num = PyArray_@TYPE@;\n\tarr = PyArray_FromAny(obj, &typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n/**end repeat**/\n\n/* bool->tp_new only returns Py_True or Py_False */\nstatic PyObject *\nbool_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\n\tarr = PyArray_FromAny(obj, &typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n\nstatic PyObject *\nvoid_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj, *arr;\n\tulonglong memu=1;\n\tPyObject *new=NULL;\n\tPyArray_Typecode typecode = {PyArray_VOID, 0, 0};\n\tchar *destptr;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\t/* For a VOID scalar first see if obj is an integer or long \n\t and create new memory of that size (filled with 0) for the scalar\n\t*/\n\n\tif (PyLong_Check(obj) || PyInt_Check(obj) || \\\n\t PyArray_IsScalar(obj, Integer) ||\n\t (PyArray_Check(obj) && PyArray_NDIM(obj)==0 &&\t\\\n\t PyArray_ISINTEGER(obj))) {\n\t\tnew = obj->ob_type->tp_as_number->nb_long(obj);\n\t}\n\tif (new && PyLong_Check(new)) {\n\t\tPyObject *ret;\n\t\tmemu = PyLong_AsUnsignedLongLong(new);\n\t\tPy_DECREF(new);\n\t\tif (PyErr_Occurred() || (memu > MAX_INT)) {\n\t\t\tPyErr_Clear();\n\t\t\tPyErr_Format(PyExc_OverflowError, \n\t\t\t\t \"size must be smaller than %d\",\n\t\t\t\t (int) MAX_INT);\n\t\t\treturn NULL;\n\t\t}\n\t\tdestptr = PyDataMem_NEW((int) memu);\n\t\tif (destptr == NULL) return PyErr_NoMemory();\n\t\tret = type->tp_alloc(type, 0);\n\t\tif (ret == NULL) {\n\t\t\tPyDataMem_FREE(destptr);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\t((PyVoidScalarObject *)ret)->obval = destptr;\n\t\t((PyVoidScalarObject *)ret)->ob_size = (int) memu;\n\t\tmemset(destptr, '\\0', (size_t) memu);\n\t\treturn ret;\n\t}\n\n\tarr = PyArray_FromAny(obj, &typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n\n\n/**************** Define Hash functions ********************/\n\n/**begin repeat\n#lname=bool,ubyte,ushort#\n#name=Bool,UByte, UShort#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return (long)(((Py@name@ScalarObject *)obj)->obval);\n}\n/**end repeat**/\n\n/**begin repeat\n#lname=byte,short,uint,ulong#\n#name=Byte,Short,UInt,ULong#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((Py@name@ScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n/**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\nstatic long\nint_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((PyIntScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#endif\n\n/**begin repeat\n#char=,u#\n#Char=,U#\n#ext=&& (x >= LONG_MIN),#\n*/\n#if SIZEOF_LONG == SIZEOF_LONGLONG\nstatic long\n@char@longlong_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((Py@Char@LongLongScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#else /* we assume SIZEOF_LONGLONG=2*SIZEOF_LONG */\nstatic long\n@char@longlong_arrtype_hash(PyObject *obj)\n{\n long y;\n @char@longlong x = (((Py@Char@LongLongScalarObject *)obj)->obval);\n\n if ((x <= LONG_MAX)@ext@) {\n y = (long) x;\n }\n else {\n union Mask {\n long hashvals[2];\n @char@longlong v;\n } both;\n\n both.v = x;\n y = both.hashvals[0] + (1000003)*both.hashvals[1];\n }\n if (y == -1) y = -2;\n return y;\n}\n#endif\n/**end repeat**/\n\n/* Wrong thing to do for longdouble, but....*/\n/**begin repeat\n#lname=float, longdouble#\n#name=Float, LongDouble#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return _Py_HashDouble((double) ((Py@name@ScalarObject *)obj)->obval);\n}\n\n/* borrowed from complex_hash */\nstatic long\nc@lname@_arrtype_hash(PyObject *obj)\n{\n long hashreal, hashimag, combined;\n hashreal = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).real);\n\n if (hashreal == -1) return -1;\n hashimag = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).imag);\n if (hashimag == -1) return -1;\n\n combined = hashreal + 1000003 * hashimag;\n if (combined == -1) combined = -2;\n return combined;\n}\n/**end repeat**/\n\nstatic long\nobject_arrtype_hash(PyObject *obj)\n{\n return PyObject_Hash(((PyObjectScalarObject *)obj)->obval);\n}\n\n/* just hash the pointer */\nstatic long\nvoid_arrtype_hash(PyObject *obj)\n{\n return _Py_HashPointer((void *)(((PyVoidScalarObject *)obj)->obval));\n}\n\n/**begin repeat\n#name=bool, string, unicode, void, object#\n#NAME=Bool, String, Unicode, Void, Object#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n/**begin repeat\n#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n#name=int*5, uint*5, float*3, complex*3#\n#CNAME=(CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@\" STRBITSOF_@CNAME@ \"_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n\n/**end repeat**/\n\n\n\n\nstatic PyNumberMethods longdoubletype_as_number;\nstatic PyNumberMethods clongdoubletype_as_number;\n\nstatic void \ninitialize_numeric_types(void)\n{\n\tPyGenericArrType_Type.tp_dealloc = (destructor)gentype_dealloc;\n\tPyGenericArrType_Type.tp_as_number = &gentype_as_number;\n\tPyGenericArrType_Type.tp_as_buffer = &gentype_as_buffer;\n\tPyGenericArrType_Type.tp_flags = BASEFLAGS;\n\tPyGenericArrType_Type.tp_methods = gentype_methods;\n\tPyGenericArrType_Type.tp_getset = gentype_getsets;\n\tPyGenericArrType_Type.tp_new = NULL;\n\tPyGenericArrType_Type.tp_free = PyObject_Del;\n\tPyGenericArrType_Type.tp_repr = gentype_repr;\n\tPyGenericArrType_Type.tp_str = gentype_str;\n\tPyGenericArrType_Type.tp_richcompare = gentype_richcompare;\n\n\t/**begin repeat\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, \nComplexFloating, Flexible, Character#\n\t*/\n Py@NAME@ArrType_Type.tp_flags = BASEFLAGS;\n\t/**end repeat**/\n\n\t/**begin repeat\n#name=bool, byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, void, object#\n#NAME=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Void, Object#\n\t*/\n\tPy@NAME@ArrType_Type.tp_flags = LEAFFLAGS;\n\tPy@NAME@ArrType_Type.tp_new = @name@_arrtype_new;\n\tPy@NAME@ArrType_Type.tp_richcompare = gentype_richcompare;\n\t/**end repeat**/\n\t/* Allow the Void type to be subclassed -- for adding new types */\n\tPyVoidArrType_Type.tp_flags = BASEFLAGS;\n\n /**begin repeat\n#name=bool, byte, short, longlong, ubyte, ushort, uint, ulong, ulonglong, float, longdouble, cfloat, clongdouble, void, object#\n#NAME=Bool, Byte, Short, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, LongDouble, CFloat, CLongDouble, Void, Object#\n */\n Py@NAME@ArrType_Type.tp_hash = @name@_arrtype_hash;\n /**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\n /* We won't be inheriting from Python Int type. */\n PyIntArrType_Type.tp_hash = int_arrtype_hash;\n#endif\n\n\t/* These need to be coded specially because getitem does not\n\t return a normal Python type\n\t*/\n\tPyLongDoubleArrType_Type.tp_as_number = &longdoubletype_as_number;\n\tPyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number;\n\n\t/**begin repeat\n#name=int, long, hex, oct, float, repr, str#\n#kind=tp_as_number->nb*5, tp*2#\n\t*/\n\tPyLongDoubleArrType_Type.@kind@_@name@ = longdoubletype_@name@;\n\tPyCLongDoubleArrType_Type.@kind@_@name@ = clongdoubletype_@name@;\n\t/**end repeat**/\n\n\tPyStringArrType_Type.tp_itemsize = sizeof(char);\n\tPyStringArrType_Type.tp_dealloc = string_arrtype_dealloc;\n\tPyFlexibleArrType_Type.tp_dealloc = flexible_dealloc;\n\tPyObjectArrType_Type.tp_dealloc = object_arrtype_dealloc;\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMapIter_Type.tp_iter = PyObject_SelfIter;\n}\n\n\nstatic PyTypeObject *typeobjects[] = {\n\t&PyBoolArrType_Type,\n\t&PyByteArrType_Type,\n\t&PyUByteArrType_Type,\n\t&PyShortArrType_Type,\n\t&PyUShortArrType_Type,\n\t&PyIntArrType_Type,\n\t&PyUIntArrType_Type,\n\t&PyLongArrType_Type,\n\t&PyULongArrType_Type,\n\t&PyLongLongArrType_Type,\n\t&PyULongLongArrType_Type,\n\t&PyFloatArrType_Type,\n\t&PyDoubleArrType_Type,\n\t&PyLongDoubleArrType_Type,\n\t&PyCFloatArrType_Type,\n\t&PyCDoubleArrType_Type,\n\t&PyCLongDoubleArrType_Type,\n\t&PyObjectArrType_Type,\n\t&PyStringArrType_Type,\n\t&PyUnicodeArrType_Type,\n\t&PyVoidArrType_Type\n};\n\n\nstatic int\nPyArray_TypenumFromTypeObject(PyObject *type) \n{\n\tint typenum, i;\n\n\ttypenum = PyArray_NOTYPE;\n i = 0;\n\twhile(i < PyArray_NTYPES) {\n\t\tif (type == (PyObject *)typeobjects[i]) {\n\t\t\ttypenum = i;\n\t\t\tbreak;\n\t\t}\n i++;\n\t}\n\tif (typenum != PyArray_NOTYPE)\n\t\treturn typenum;\n\n\t/* Find registered types */\n\t\n\t/* here */\n\n\t/* Convert generic types to specific types */\n\tif ((type == (PyObject *) &PyNumericArrType_Type) || \\\n\t (type == (PyObject *) &PyInexactArrType_Type) || \\\n\t (type == (PyObject *) &PyFloatingArrType_Type))\n\t\treturn PyArray_DOUBLE;\n\telse if (type == (PyObject *)&PyComplexFloatingArrType_Type)\n\t\treturn PyArray_CDOUBLE;\n\telse if ((type == (PyObject *)&PyIntegerArrType_Type) ||\t\\\n\t\t (type == (PyObject *)&PySignedIntegerArrType_Type))\n\t\treturn PyArray_LONG;\n\telse if (type == (PyObject *) &PyUnsignedIntegerArrType_Type)\n\t\treturn PyArray_ULONG;\n else if (type == (PyObject *) &PyCharacterArrType_Type)\n\t\treturn PyArray_STRING;\n\telse if (type == (PyObject *) &PyFlexibleArrType_Type)\n\t\treturn PyArray_VOID;\n\telse if (type == (PyObject *)&PyBool_Type)\n\t\ttypenum = PyArray_BOOL;\n\telse if (type == (PyObject *)&PyInt_Type)\n\t\ttypenum = PyArray_LONG;\n\telse if (type == (PyObject *)&PyFloat_Type)\n\t\ttypenum = PyArray_DOUBLE;\t\n\telse if (type == (PyObject *)&PyComplex_Type)\n\t\ttypenum = PyArray_CDOUBLE;\n\telse if (type == (PyObject *)&PyString_Type)\n\t\ttypenum = PyArray_STRING;\n\telse if (type == (PyObject *)&PyUnicode_Type)\n\t\ttypenum = PyArray_UNICODE;\n\telse if (type == (PyObject *)&PyBuffer_Type)\n\t\ttypenum = PyArray_VOID;\n\telse\n\t\ttypenum = PyArray_OBJECT;\n\treturn typenum;\n}\n\nstatic void \nPyArray_TypecodeFromTypeObject(PyObject *type, PyArray_Typecode *typecode) {\n\tint itemsize = 0;\n\tint type_num;\n\n\ttype_num = PyArray_TypenumFromTypeObject(type);\n\ttypecode->type_num = type_num;\n\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n itemsize = 0;\n\t}\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type_num);\n\t\tif (descr != NULL)\n\t\t\titemsize = descr->elsize;\n\t}\n\ttypecode->itemsize = itemsize;\n\treturn;\n}\n\nstatic void \nPyArray_TypecodeFromScalar(PyObject *sc, PyArray_Typecode *typecode)\n{\n\tint type_num;\n\n PyArray_TypecodeFromTypeObject((PyObject *)sc->ob_type, typecode);\n if (typecode->itemsize == 0) {\n type_num = typecode->type_num;\n\t\tif (type_num == PyArray_STRING) \n\t\t\ttypecode->itemsize = PyString_GET_SIZE(sc);\n\t\telse if (type_num == PyArray_UNICODE)\n\t\t\ttypecode->itemsize = PyUnicode_GET_DATA_SIZE(sc);\n\t\telse if (type_num == PyArray_VOID) {\n\t\t\ttypecode->itemsize = \\\n\t\t\t\t((PyVoidScalarObject *)sc)->ob_size;\n\t\t}\n }\n\treturn;\n}\n\nstatic PyObject *\nPyArray_TypeObjectFromType(int type)\n{\n\tPyArray_Descr *descr;\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr == NULL) return NULL;\n\tPy_INCREF((PyObject *)descr->typeobj);\n\treturn (PyObject *)descr->typeobj;\n}\n\n", "source_code_before": "/* -*- c -*- */\n\n/**begin repeat\n\n#name=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object,#\n#type=Bool, signed char, short, int, long, longlong, unsigned char, unsigned short, unsigned int, unsigned long, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, PyObject *,char#\n*/\ntypedef struct {\n\tPyObject_HEAD;\n\t@type@ obval;\n} Py@name@ScalarObject;\n\n/**end repeat**/\n\n/* Inheritance established later when tp_bases is set (or tp_base for \n single inheritance) */\n\n/**begin repeat\n\n#name=numeric, integer, signedinteger, unsignedinteger, inexact, floating, complexfloating, flexible, \ncharacter#\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character#\n*/\n\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n\n#define PyStringScalarObject PyStringObject\n#define PyUnicodeScalarObject PyUnicodeObject\n\ntypedef struct {\n\tPyObject_VAR_HEAD;\n\tchar *obval;\n} PyVoidScalarObject;\n\n/* 0-dim array from array-scalar object */\n\nstatic PyObject *\nPyArray_FromScalar(PyObject *scalar, PyArray_Typecode *outcode)\n{\n\tPyArray_Typecode typecode;\n\tPyObject *r;\n\tchar *memptr;\n\tPyObject *ret;\n\n\t/* convert to 0-dim array of scalar typecode */\n\tPyArray_TypecodeFromScalar(scalar, &typecode);\n\tr = PyArray_New(&PyArray_Type, 0, NULL, typecode.type_num,\n\t\t\tNULL, NULL, typecode.itemsize, 0, NULL);\n\tif (r==NULL) return NULL;\n\n\tswitch(typecode.type_num) {\n\tcase PyArray_STRING:\n\t\tmemptr = PyString_AS_STRING(scalar);\n\t\tbreak;\n\tcase PyArray_UNICODE:\n\t\tmemptr = (char *)PyUnicode_AS_DATA(scalar);\n\t\tbreak;\n\tcase PyArray_VOID:\n\t\tmemptr = (((PyVoidScalarObject *)scalar)->obval);\n\t\tbreak;\n\tdefault:\n\t\tmemptr = &(((PyScalarObject *)scalar)->obval);\n\t\tbreak;\n\t}\n\n\tmemcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r));\n\tif (PyArray_ISOBJECT(r)) {\n\t\tPy_INCREF(*((PyObject **)memptr));\n\t}\n\t\n\tif (outcode == NULL || \\\n\t outcode->type_num == PyArray_NOTYPE ||\t\\\n\t outcode->type_num == PyArray_TYPE(r))\n\t\treturn r;\n\n\t/* cast if necessary to desired output typecode */\n\tret = PyArray_CastToType((PyArrayObject *)r, outcode);\n\tPy_DECREF(r);\n\treturn ret;\n}\n\n\nstatic void\ngentype_dealloc(PyObject *v) \n{\n\tv->ob_type->tp_free(v);\n}\n\n\nstatic PyObject *\ngentype_power(PyObject *m1, PyObject *m2, PyObject *m3)\n{\n\tPyObject *arr, *ret, *arg2;\n\tchar *msg=\"unsupported operand type(s) for ** or pow()\";\n\t\n\tif (!PyArray_IsScalar(m1,Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m2,Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(m1, arr,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(arr, m2,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=arg2=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\targ2 = PyArray_FromScalar(m2, NULL);\t\n\tif (arr == NULL || arg2 == NULL) {\n\t\tPy_XDECREF(arr); Py_XDECREF(arg2); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_power(arr, arg2, Py_None);\n\tPy_DECREF(arr);\n\tPy_DECREF(arg2);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_generic_method(PyObject *self, PyObject *args, PyObject *kwds, \n\t\t char *str)\n{\n\tPyObject *arr, *meth, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tmeth = PyObject_GetAttrString(arr, str);\n\tif (kwds == NULL) \n\t\tret = PyObject_CallObject(meth, args);\n\telse\n\t\tret = PyObject_Call(meth, args, kwds);\n\tPy_DECREF(meth);\n\tPy_DECREF(arr);\n\treturn PyArray_Return((PyArrayObject *)ret);\n}\n\n/**begin repeat\n\n#name=add, subtract, divide, remainder, divmod, lshift, rshift, and, xor, or, floor_divide, true_divide#\n#PYNAME=Add, Subtract, Divide, Remainder, Divmod, Lshift, Rshift, And, Xor, Or, FloorDivide, TrueDivide#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret, *tup;\n\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n else if ((m1->ob_type->tp_as_number == NULL) ||\n\t\t\t (m1->ob_type->tp_as_number->nb_@name@ == NULL)) {\n\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_@name@(m1, arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\telse {\n\t\t\t/* Convert m2 to a Python object and then try */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m2, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tif (arr == NULL) return NULL;\n ret = PyNumber_@PYNAME@(m1, arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n\t\telse if ((m2->ob_type->tp_as_number == NULL) ||\n\t\t\t (m2->ob_type->tp_as_number->nb_@name@ == NULL)) {\n\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_@name@(arr, m2);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\telse {\n\t\t\t/* Convert m1 to a Python object and then try */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m1, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tret = PyNumber_@PYNAME@(arr,m2);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *\ngentype_multiply(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret, *tup;\n\tlong repeat;\n\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m1->ob_type->tp_as_number == NULL) ||\n\t\t\t (m1->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m2 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m2);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m1, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\\\n\t\t\t\t\tnb_multiply(m1, arr);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t/* Convert m2 to a Python object */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m2, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tif (arr == NULL) return NULL;\n ret = PyNumber_Multiply(m1, arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m2->ob_type->tp_as_number == NULL) ||\n\t\t\t (m2->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m1 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m1);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m2, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\t\\\n\t\t\t\t\tnb_multiply(arr, m2);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\t\t\t\n\t\t}\n\t\telse {\n\t\t\t/* Convert m1 to a Python object */\n\t\t\ttup = PyTuple_New(0);\n\t\t\tarr = gentype_generic_method(m1, tup, NULL, \n\t\t\t\t\t\t \"toscalar\");\n\t\t\tPy_DECREF(tup);\n\t\t\tif (arr == NULL) return NULL;\n ret = PyNumber_Multiply(arr, m2);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\t/* Both are array scalar objects */\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_multiply(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n\n}\n\n\n\n/**begin repeat\n\n#name=negative, absolute, invert, int, long, float, oct, hex#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1)\n{\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n/**end repeat**/\n\nstatic int\ngentype_nonzero_number(PyObject *m1)\n{\n\tPyObject *arr;\n\tint ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return -1;\n\tret = arr->ob_type->tp_as_number->nb_nonzero(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_str(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Str(arr->descr->getitem(arr->data, arr));\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_repr(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Repr(arr->descr->getitem(arr->data, arr));\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic void\nformat_longdouble(char *buf, size_t buflen, longdouble val, int precision)\n{\n register char *cp;\n\n PyOS_snprintf(buf, buflen, \"%.*\" LONGDOUBLE_FMT, precision, val);\n cp = buf;\n if (*cp == '-')\n cp++;\n for (; *cp != '\\0'; cp++) {\n if (!isdigit(Py_CHARMASK(*cp)))\n break;\n }\n if (*cp == '\\0') {\n *cp++ = '.';\n *cp++ = '0';\n *cp++ = '\\0';\n }\n}\n\n#if SIZEOF_LONGDOUBLE == SIZEOF_DOUBLE\n#define PREC_REPR 15\n#define PREC_STR 15\n#else\n#define PREC_REPR 21\n#define PREC_STR 21\n#endif\n\nstatic PyObject *\nlongdoubletype_repr(PyObject *self)\n{\n static char buf[100];\n format_longdouble(buf, sizeof(buf), ((PyLongDoubleScalarObject *)self)->obval, PREC_REPR);\n return PyString_FromString(buf);\n}\n\nstatic PyObject *\nclongdoubletype_repr(PyObject *self)\n{\n static char buf1[100];\n static char buf2[100];\n\tstatic char buf3[202];\n clongdouble x;\n x = ((PyCLongDoubleScalarObject *)self)->obval;\n format_longdouble(buf1, sizeof(buf1), x.real, PREC_REPR);\n format_longdouble(buf2, sizeof(buf2), x.imag, PREC_REPR);\n\n\tsnprintf(buf3, sizeof(buf3), \"(%s+%sj)\", buf1, buf2);\n\treturn PyString_FromString(buf3);\n}\n\n#define longdoubletype_str longdoubletype_repr\n#define clongdoubletype_str clongdoubletype_repr\n\n/** Could improve this with a PyLong_FromLongDouble(longdouble ldval)\n but this would need some more work...\n**/\n\n/**begin repeat\n\n#name=(int, long, hex, oct, float)*2#\n#KIND=(Long*4, Float)*2#\n#char=,,,,,c*5#\n#CHAR=,,,,,C*5#\n#POST=,,,,,.real*5#\n*/\nstatic PyObject *\n@char@longdoubletype_@name@(PyObject *self)\n{\n\tdouble dval;\n\tPyObject *obj, *ret;\n\t\n\tdval = (double)(((Py@CHAR@LongDoubleScalarObject *)self)->obval)@POST@;\n\tobj = Py@KIND@_FromDouble(dval);\n\tret = obj->ob_type->tp_as_number->nb_@name@(obj);\n\tPy_DECREF(obj);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *gentype_copy(PyObject *, PyObject *);\n\nstatic PyNumberMethods gentype_as_number = {\n (binaryfunc)gentype_add,\t\t /*nb_add*/\n (binaryfunc)gentype_subtract,\t\t /*nb_subtract*/\n (binaryfunc)gentype_multiply,\t\t /*nb_multiply*/\n (binaryfunc)gentype_divide,\t\t /*nb_divide*/\n (binaryfunc)gentype_remainder,\t /*nb_remainder*/\n (binaryfunc)gentype_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)gentype_power,\t\t /*nb_power*/\n (unaryfunc)gentype_negative,\t \n (unaryfunc)gentype_copy,\t\t /*nb_pos*/ \n (unaryfunc)gentype_absolute,\t\t /*(unaryfunc)gentype_abs,*/\n (inquiry)gentype_nonzero_number,\t\t /*nb_nonzero*/\n (unaryfunc)gentype_invert,\t\t /*nb_invert*/\n (binaryfunc)gentype_lshift,\t /*nb_lshift*/\n (binaryfunc)gentype_rshift,\t /*nb_rshift*/\n (binaryfunc)gentype_and,\t /*nb_and*/\n (binaryfunc)gentype_xor,\t /*nb_xor*/\n (binaryfunc)gentype_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)gentype_int,\t\t /*nb_int*/\n (unaryfunc)gentype_long,\t\t /*nb_long*/\n (unaryfunc)gentype_float,\t\t /*nb_float*/\n (unaryfunc)gentype_oct,\t\t /*nb_oct*/\n (unaryfunc)gentype_hex,\t\t /*nb_hex*/\n 0, /*inplace_add*/\n 0, /*inplace_subtract*/\n 0, /*inplace_multiply*/\n 0, /*inplace_divide*/\n 0, /*inplace_remainder*/\n 0, /*inplace_power*/\n 0, /*inplace_lshift*/\n 0, /*inplace_rshift*/\n 0, /*inplace_and*/\n 0, /*inplace_xor*/\n 0, /*inplace_or*/\n (binaryfunc)gentype_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)gentype_true_divide,\t /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n\n};\n\nstatic PyObject *\ngentype_richcompare(PyObject *self, PyObject *other, int cmp_op) \n{\n\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_richcompare(arr, other, cmp_op);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_ndim_get(PyObject *self)\n{\n\treturn PyInt_FromLong(0);\n}\n\nstatic PyObject *\ngentype_flags_get(PyObject *self)\n{\n\tPyObject *dict;\n\tdict = PyDict_New();\t\n\n#define ADDFLAG(flag, val) PyDict_SetItemString(dict, #flag, Py_##val);\n\n ADDFLAG(CONTIGUOUS, True);\n ADDFLAG(OWN_DATA, True);\n ADDFLAG(FORTRAN, True);\n ADDFLAG(ALIGNED, True);\n ADDFLAG(NOTSWAPPED, True);\n ADDFLAG(WRITEABLE, False);\n ADDFLAG(UPDATEIFCOPY, False);\n\treturn dict;\n#undef ADDFLAG\n}\n\nstatic PyObject *\ngentype_shape_get(PyObject *self)\n{\n\treturn PyTuple_New(0);\n}\n\n/*\nstatic int\ngentype_shape_set(PyObject *self, PyObject *val)\n{\n\tif (!PyTuple_Check(val) || PyTuple_GET_SIZE(val) > 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \\\n\t\t\t\t\"invalid shape for scalar\");\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n*/\n\n\nstatic PyObject *\ngentype_data_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\n\treturn PyBuffer_FromObject(self, 0, typecode.itemsize);\n}\n\n\nstatic PyObject *\ngentype_itemsize_get(PyObject *self)\n{\t\n\tPyArray_Typecode typecode;\n\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\treturn PyInt_FromLong((long) typecode.itemsize);\n}\n\nstatic PyObject *\ngentype_size_get(PyObject *self)\n{\n\treturn PyInt_FromLong(1);\n}\n\n\nstatic PyObject *\ngentype_typechar_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\tPyArray_Descr *descr;\n\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\tdescr = PyArray_DescrFromType(typecode.type_num);\n\tif (PyArray_IsScalar(self, Flexible)) \n\t\treturn PyString_FromFormat(\"%c%d\", (int)(descr->type),\n\t\t\t\t\t typecode.itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(descr->type), 1);\n}\n\nstatic PyObject *\ngentype_typestr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"dtypestr\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_descr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"__array_descr__\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\n\nstatic PyObject *\ngentype_typenum_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\treturn PyInt_FromLong((long) typecode.type_num);\n}\n\nstatic PyObject *\ngentype_type_get(PyObject *self)\n{\n\treturn (PyObject *)self->ob_type;\n}\n\n\nstatic PyObject *\ngentype_base_get(PyObject *self)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic PyObject *\ngentype_real_get(PyObject *self)\n{\n\tPyArray_Typecode typecode;\n\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\tPyArray_TypecodeFromScalar(self, &typecode);\n\t\treturn PyArray_Scalar(&(((PyScalarObject *)self)->obval),\n\t\t\t\t typecode.type_num-PyArray_NUM_FLOATTYPE,\n\t\t\t\t typecode.itemsize >> 1, 0);\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tPyObject *ret;\n\t\tret = PyObject_GetAttrString(obj, \"real\");\n\t\tif (ret != NULL) return ret;\n\t}\n\tPy_INCREF(self);\n\treturn (PyObject *)self;\n}\n\nstatic PyObject *\ngentype_imag_get(PyObject *self)\n{\t\n\tPyArray_Typecode typecode;\n\tPyArray_TypecodeFromScalar(self, &typecode);\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\ttypecode.itemsize >>= 1;\n\t\treturn PyArray_Scalar(&(((PyScalarObject *)self)->obval)\n\t\t\t\t + typecode.itemsize, \n\t\t\t\t typecode.type_num-PyArray_NUM_FLOATTYPE,\n\t\t\t\t typecode.itemsize, 0);\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tPyObject *ret;\n\t\tret = PyObject_GetAttrString(obj, \"imag\");\n\t\tif (ret == NULL) {\n\t\t\tPyErr_Clear();\n\t\t\tobj = PyInt_FromLong(0);\n\t\t\tret = PyArray_Scalar((char *)&obj, PyArray_OBJECT, \n\t\t\t\t\t sizeof(void *), 0);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *ret;\n\t\tchar *temp;\n\t\ttemp = PyDataMem_NEW(typecode.itemsize);\n\t\tmemset(temp, '\\0', typecode.itemsize);\n\t\tret = PyArray_Scalar(temp, typecode.type_num,\n\t\t\t\t typecode.itemsize, 0);\n\t\tPyDataMem_FREE(temp);\n\t\treturn ret;\n\t}\n}\n\nstatic PyObject *\ngentype_flat_get(PyObject *self)\n{\n\tPyObject *ret, *arr;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = PyArray_IterNew(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyGetSetDef gentype_getsets[] = {\n {\"ndim\", \n\t (getter)gentype_ndim_get, \n\t (setter) 0, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)gentype_flags_get, \n\t (setter)0, \n\t \"integer value of flags\"},\n {\"shape\", \n\t (getter)gentype_shape_get, \n\t (setter)0, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)gentype_shape_get, \n\t (setter) 0, \n\t \"tuple of bytes steps in each dimension\"},\n {\"data\",\n\t (getter)gentype_data_get, \n\t (setter) 0, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)gentype_itemsize_get, \n\t (setter)0, \n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)gentype_size_get,\n (setter)0,\n \"number of elements in the gentype\"},\n\t{\"base\",\n\t (getter)gentype_base_get,\n\t (setter)0,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)gentype_type_get, \n\t (setter)0, \n\t \"get gentype type class\"},\n\t{\"dtypechar\",\n\t (getter)gentype_typechar_get,\n\t (setter)0,\n\t \"get gentype type character code\"},\n\t{\"dtypenum\",\n\t (getter)gentype_typenum_get,\n\t (setter)0,\n\t \"get gentype type number code\"},\n\t{\"dtypestr\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)gentype_real_get, \n\t (setter)0,\n\t \"real part of scalar\"},\n {\"imag\", \n\t (getter)gentype_imag_get, \n\t (setter)0, \n\t \"imaginary part of scalar\"},\n\t{\"flat\", \n\t (getter)gentype_flat_get, \n\t (setter)0, \n\t \"a 1-d view of scalar\"}, \n\t{\"__array_data__\", \n\t (getter)gentype_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)gentype_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t/* Does not have __array_priority__ because it is not a subtype.\n\t */\n \t{NULL, NULL, NULL, NULL} /* Sentinel */\n};\n\n/* 0-dim array from scalar object */\n\nstatic char doc_getarray[] = \"sc.__array__(|type) return 0-dim array\";\n\nstatic PyObject *\ngentype_getarray(PyObject *scalar, PyObject *args) \n{\n\tPyArray_Typecode outcode = {PyArray_NOTYPE, 0, 0};\n\n\tif (!PyArg_ParseTuple(args, \"|O&\", &PyArray_TypecodeConverter,\n\t\t\t &outcode)) return NULL;\n\treturn PyArray_FromScalar(scalar, &outcode);\n}\n\nstatic char doc_sc_wraparray[] = \"sc.__array_wrap__(obj) return scalar from array\";\n\nstatic PyObject *\ngentype_wraparray(PyObject *scalar, PyObject *args)\n{\n\tPyObject *arr;\n\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument.\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_Scalar(PyArray_DATA(arr), PyArray_TYPE(arr),\n\t\t\t PyArray_ITEMSIZE(arr), !PyArray_ISNOTSWAPPED(arr));\n}\n\n\n/**begin repeat\n\n#name=tolist, toscalar, tostring, astype, copy, resize, __deepcopy__, choose, sort, argsort, searchsorted, argmax, argmin, reshape, view, swapaxes, max, min, ptp, conj, conjugate, nonzero, all, any, flatten, ravel#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args)\n{\n\treturn gentype_generic_method(self, args, NULL, \"@name@\");\n}\n/**end repeat**/\n\nstatic PyObject *\ngentype_squeeze(PyObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tPy_INCREF(self);\n\treturn self;\n}\n\nstatic int\ngentype_getreadbuf(PyObject *, int, void **);\n\nstatic PyObject *\ngentype_byteswap(PyObject *self, PyObject *args)\n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\tif (inplace) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot byteswap a scalar in-place\");\n\t\treturn NULL;\n\t}\n\telse {\n\t\t/* get the data, copyswap it and pass it to a new Array scalar\n\t\t */\n\t\tchar *data;\n\t\tint numbytes;\n\t\tPyArray_Typecode type;\n\t\tPyArray_Descr *descr;\n\t\tPyObject *new;\n\t\tchar *newmem;\n\n\t\tnumbytes = gentype_getreadbuf(self, 0, (void **)&data);\n\t\tPyArray_TypecodeFromScalar(self, &type);\n\t\tnewmem = malloc(type.itemsize);\n\t\tif (newmem == NULL) return PyErr_NoMemory();\n\t\telse memcpy(newmem, data, type.itemsize);\n\t\tdescr = PyArray_DescrFromType(type.type_num);\n\t\tdescr->copyswap(newmem, NULL, 1, type.itemsize);\t\t\n\t\tnew = PyArray_Scalar(newmem, type.type_num, type.itemsize, 0);\n\t\tfree(newmem);\n\t\treturn new;\n\t}\n}\n\n/**begin repeat\n\n#name=transpose, getfield, take, put, putmask, repeat, tofile, mean, trace, diagonal, clip, std, sum, cumsum, prod, cumprod, compress#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\treturn gentype_generic_method(self, args, kwds, \"@name@\");\n}\n/**end repeat**/\n\n\nstatic PyObject *\ngentype_reduce(PyObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *obj=NULL, *mod=NULL;\n\tconst char *buffer; \n\tint buflen;\n\n\t/* Return a tuple of (callable object, arguments) */\n\n\tret = PyTuple_New(2);\n\tif (ret == NULL) return NULL;\t\n\tif (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) return NULL;\n\tobj = PyObject_GetAttrString(mod, \"scalar\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) return NULL;\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tobj = PyObject_GetAttrString((PyObject *)self, \"dtypestr\");\n\tif PyArray_IsScalar(self, Object) {\n\t\tmod = ((PyObjectScalarObject *)self)->obval;\n\t\tPyTuple_SET_ITEM(ret, 1,\n\t\t\t\t Py_BuildValue(\"NO\", obj, mod));\n\t}\n\telse {\n\t\tmod = PyString_FromStringAndSize(buffer, buflen);\n\t\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t\t Py_BuildValue(\"NN\", obj, mod));\n\t}\n\treturn ret;\n}\n\n/* ignores everything */\nstatic PyObject *\ngentype_setstate(PyObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn (Py_None);\n}\n\nstatic PyObject *\ngentype_dump(PyObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump(self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyObject *\ngentype_dumps(PyObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps(self, 2);\n}\n\n\n/* setting flags cannot be done for scalars */\nstatic PyObject *\ngentype_setflags(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic int _array_typecode_fromstr(char *, int *, PyArray_Typecode *);\n\n/* need to fill in doc-strings for these methods on import -- copy from \n array docstrings \n*/\nstatic PyMethodDef gentype_methods[] = {\n {\"tolist\",\t (PyCFunction)gentype_tolist,\t1, NULL},\n {\"toscalar\", (PyCFunction)gentype_toscalar, METH_VARARGS, NULL},\n\t{\"tofile\", (PyCFunction)gentype_tofile, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"tostring\", (PyCFunction)gentype_tostring, METH_VARARGS, NULL},\n {\"byteswap\", (PyCFunction)gentype_byteswap,1, NULL},\n {\"astype\", (PyCFunction)gentype_astype, 1, NULL},\n\t{\"getfield\", (PyCFunction)gentype_getfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n {\"copy\", (PyCFunction)gentype_copy, 1, NULL}, \n {\"resize\", (PyCFunction)gentype_resize, 1, NULL}, \n\n\t{\"__array__\", (PyCFunction)gentype_getarray, 1, doc_getarray},\n\t{\"__array_wrap__\", (PyCFunction)gentype_wraparray, 1, doc_sc_wraparray},\n\n /* for the copy module */\n {\"__copy__\", (PyCFunction)gentype_copy, 1, NULL},\n {\"__deepcopy__\", (PyCFunction)gentype___deepcopy__, 1, NULL},\n\n\n {\"__reduce__\", (PyCFunction) gentype_reduce, 1, NULL},\t\n\t/* For consistency does nothing */\n\t{\"__setstate__\", (PyCFunction) gentype_setstate, 1, NULL},\n\n\t{\"dumps\", (PyCFunction) gentype_dumps, 1, NULL},\n\t{\"dump\", (PyCFunction) gentype_dump, 1, NULL},\n\n\t/* Methods for array */\n\t{\"transpose\",\t(PyCFunction)gentype_transpose, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"take\",\t(PyCFunction)gentype_take, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"put\",\t(PyCFunction)gentype_put, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"putmask\",\t(PyCFunction)gentype_putmask, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"repeat\",\t(PyCFunction)gentype_repeat, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"choose\",\t(PyCFunction)gentype_choose, \n\t METH_VARARGS, NULL},\t\n\t{\"sort\",\t(PyCFunction)gentype_sort, \n\t METH_VARARGS, NULL},\n\t{\"argsort\",\t(PyCFunction)gentype_argsort, \n\t METH_VARARGS, NULL},\n\t{\"searchsorted\", (PyCFunction)gentype_searchsorted, \n\t METH_VARARGS, NULL},\t\n\t{\"argmax\",\t(PyCFunction)gentype_argmax, \n\t METH_VARARGS, NULL},\n\t{\"argmin\", (PyCFunction)gentype_argmin,\n\t METH_VARARGS, NULL},\n\t{\"reshape\",\t(PyCFunction)gentype_reshape, \n\t METH_VARARGS, NULL},\n\t{\"squeeze\",\t(PyCFunction)gentype_squeeze, \n\t METH_VARARGS, NULL},\n\t{\"view\", (PyCFunction)gentype_view, \n\t METH_VARARGS, NULL},\n\t{\"swapaxes\", (PyCFunction)gentype_swapaxes,\n\t METH_VARARGS, NULL},\n\t{\"max\", (PyCFunction)gentype_max,\n\t METH_VARARGS, NULL},\n\t{\"min\", (PyCFunction)gentype_min,\n\t METH_VARARGS, NULL},\n\t{\"ptp\", (PyCFunction)gentype_ptp,\n\t METH_VARARGS, NULL},\n\t{\"mean\", (PyCFunction)gentype_mean,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"trace\", (PyCFunction)gentype_trace,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"diagonal\", (PyCFunction)gentype_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"clip\", (PyCFunction)gentype_clip,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"conj\", (PyCFunction)gentype_conj,\n\t METH_VARARGS, NULL},\n\t{\"conjugate\", (PyCFunction)gentype_conjugate,\n\t METH_VARARGS, NULL},\n\t{\"nonzero\", (PyCFunction)gentype_nonzero,\n\t METH_VARARGS, NULL},\n\t{\"std\", (PyCFunction)gentype_std,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"sum\", (PyCFunction)gentype_sum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumsum\", (PyCFunction)gentype_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"prod\", (PyCFunction)gentype_prod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumprod\", (PyCFunction)gentype_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"all\", (PyCFunction)gentype_all,\n\t METH_VARARGS, NULL},\n\t{\"any\", (PyCFunction)gentype_any,\n\t METH_VARARGS, NULL},\n\t{\"compress\", (PyCFunction)gentype_compress,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"flatten\", (PyCFunction)gentype_flatten,\n\t METH_VARARGS, NULL},\n\t{\"ravel\", (PyCFunction)gentype_ravel,\n\t METH_VARARGS, NULL},\n\t{\"setflags\", (PyCFunction)gentype_setflags,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t/* add other methods!!! */\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic int\ngentype_getreadbuf(PyObject *self, int segment, void **ptrptr)\n{\n\tint numbytes;\n\tPyArray_Typecode outcode;\n\t\n\tif (segment != 0) {\n\t\tPyErr_SetString(PyExc_SystemError, \n\t\t\t\t\"Accessing non-existent array segment\");\n\t\treturn -1;\n\t}\n\n\tPyArray_TypecodeFromScalar(self, &outcode);\n\tnumbytes = outcode.itemsize;\n\tif PyArray_IsScalar(self, Flexible) {\n\t\tif PyArray_IsScalar(self, String)\n\t\t\t*ptrptr = PyString_AS_STRING(self);\n\t\telse if PyArray_IsScalar(self, Unicode)\n\t\t\t*ptrptr = (char *)PyUnicode_AS_DATA(self);\n\t\telse if PyArray_IsScalar(self, Void)\n\t\t\t*ptrptr = ((PyVoidScalarObject *)self)->obval;\n\t}\n\telse \n\t\t*ptrptr = (void *)&(((PyScalarObject *)self)->obval);\n\n\treturn numbytes;\n}\n\nstatic int\ngentype_getsegcount(PyObject *self, int *lenp)\n{\n\tPyArray_Typecode outcode;\n\n\tPyArray_TypecodeFromScalar(self, &outcode);\n\tif (lenp)\n\t\t*lenp = outcode.itemsize;\n\treturn 1;\n}\n\nstatic int\ngentype_getcharbuf(PyObject *self, int segment, const char **ptrptr)\n{\n\tif (PyArray_IsScalar(self, String) ||\t\\\n\t PyArray_IsScalar(self, Unicode))\n\t\treturn gentype_getreadbuf(self, segment, (void **)ptrptr);\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"Non-character array cannot be interpreted \"\\\n\t\t\t\t\"as character buffer.\");\n\t\treturn -1;\n\t}\n}\n\n\nstatic PyBufferProcs gentype_as_buffer = {\n (getreadbufferproc)gentype_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)0, /*bf_getwritebuffer*/\n (getsegcountproc)gentype_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)gentype_getcharbuf, /*bf_getcharbuffer*/\n};\n\n\n#define BASEFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES\n#define LEAFFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES\n\nstatic PyTypeObject PyGenericArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"generic_arrtype\",\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n\n/* works for VOID and UNICODE */\n\nstatic void\nflexible_dealloc(PyObject *v) \n{\n\tPyDataMem_FREE(((PyVoidScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nstring_arrtype_dealloc(PyObject *v)\n{\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nobject_arrtype_dealloc(PyObject *v)\n{\n\tPy_DECREF(((PyObjectScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\n/* string and unicode inherit from Python Type first and so GET_ITEM is different to\n get to the Python Type.\n */\n\n/**begin repeat \n#name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object#\n#TYPE=BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT#\n#num=1*16,0,0,1#\n*/\nstatic PyObject *\n@name@_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\tPyArray_Typecode typecode = {PyArray_NOTYPE, 0, 0};\n\n\tif (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) {\n\t\tPyTypeObject *sup;\n\t\tPyObject *ret;\n\t\t/* We are inheriting from a Python type as well so\n\t\t give it first dibs on conversion */\n\t\tsup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, @num@);\n\t\tret = sup->tp_new(type, args, kwds);\n\t\tif (ret) return ret;\n\t\tPyErr_Clear();\n\t\t/* now do default conversion */\n\t}\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\n\ttypecode.type_num = PyArray_@TYPE@;\n\tarr = PyArray_FromAny(obj, &typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n/**end repeat**/\n\n/* bool->tp_new only returns Py_True or Py_False */\nstatic PyObject *\nbool_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\n\tarr = PyArray_FromAny(obj, &typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n\nstatic PyObject *\nvoid_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj, *arr;\n\tulonglong memu=1;\n\tPyObject *new=NULL;\n\tPyArray_Typecode typecode = {PyArray_VOID, 0, 0};\n\tchar *destptr;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\t/* For a VOID scalar first see if obj is an integer or long \n\t and create new memory of that size (filled with 0) for the scalar\n\t*/\n\n\tif (PyLong_Check(obj) || PyInt_Check(obj) || \\\n\t PyArray_IsScalar(obj, Integer) ||\n\t (PyArray_Check(obj) && PyArray_NDIM(obj)==0 &&\t\\\n\t PyArray_ISINTEGER(obj))) {\n\t\tnew = obj->ob_type->tp_as_number->nb_long(obj);\n\t}\n\tif (new && PyLong_Check(new)) {\n\t\tPyObject *ret;\n\t\tmemu = PyLong_AsUnsignedLongLong(new);\n\t\tPy_DECREF(new);\n\t\tif (PyErr_Occurred() || (memu > MAX_INT)) {\n\t\t\tPyErr_Clear();\n\t\t\tPyErr_Format(PyExc_OverflowError, \n\t\t\t\t \"size must be smaller than %d\",\n\t\t\t\t (int) MAX_INT);\n\t\t\treturn NULL;\n\t\t}\n\t\tdestptr = PyDataMem_NEW((int) memu);\n\t\tif (destptr == NULL) return PyErr_NoMemory();\n\t\tret = type->tp_alloc(type, 0);\n\t\tif (ret == NULL) {\n\t\t\tPyDataMem_FREE(destptr);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\t((PyVoidScalarObject *)ret)->obval = destptr;\n\t\t((PyVoidScalarObject *)ret)->ob_size = (int) memu;\n\t\tmemset(destptr, '\\0', (size_t) memu);\n\t\treturn ret;\n\t}\n\n\tarr = PyArray_FromAny(obj, &typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n\n\n/**************** Define Hash functions ********************/\n\n/**begin repeat\n#lname=bool,ubyte,ushort#\n#name=Bool,UByte, UShort#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return (long)(((Py@name@ScalarObject *)obj)->obval);\n}\n/**end repeat**/\n\n/**begin repeat\n#lname=byte,short,uint,ulong#\n#name=Byte,Short,UInt,ULong#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((Py@name@ScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n/**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\nstatic long\nint_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((PyIntScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#endif\n\n/**begin repeat\n#char=,u#\n#Char=,U#\n#ext=&& (x >= LONG_MIN),#\n*/\n#if SIZEOF_LONG == SIZEOF_LONGLONG\nstatic long\n@char@longlong_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((Py@Char@LongLongScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#else /* we assume SIZEOF_LONGLONG=2*SIZEOF_LONG */\nstatic long\n@char@longlong_arrtype_hash(PyObject *obj)\n{\n long y;\n @char@longlong x = (((Py@Char@LongLongScalarObject *)obj)->obval);\n\n if ((x <= LONG_MAX)@ext@) {\n y = (long) x;\n }\n else {\n union Mask {\n long hashvals[2];\n @char@longlong v;\n } both;\n\n both.v = x;\n y = both.hashvals[0] + (1000003)*both.hashvals[1];\n }\n if (y == -1) y = -2;\n return y;\n}\n#endif\n/**end repeat**/\n\n/* Wrong thing to do for longdouble, but....*/\n/**begin repeat\n#lname=float, longdouble#\n#name=Float, LongDouble#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return _Py_HashDouble((double) ((Py@name@ScalarObject *)obj)->obval);\n}\n\n/* borrowed from complex_hash */\nstatic long\nc@lname@_arrtype_hash(PyObject *obj)\n{\n long hashreal, hashimag, combined;\n hashreal = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).real);\n\n if (hashreal == -1) return -1;\n hashimag = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).imag);\n if (hashimag == -1) return -1;\n\n combined = hashreal + 1000003 * hashimag;\n if (combined == -1) combined = -2;\n return combined;\n}\n/**end repeat**/\n\nstatic long\nobject_arrtype_hash(PyObject *obj)\n{\n return PyObject_Hash(((PyObjectScalarObject *)obj)->obval);\n}\n\n/* just hash the pointer */\nstatic long\nvoid_arrtype_hash(PyObject *obj)\n{\n return _Py_HashPointer((void *)(((PyVoidScalarObject *)obj)->obval));\n}\n\n/**begin repeat\n#name=bool, string, unicode, void, object#\n#NAME=Bool, String, Unicode, Void, Object#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n/**begin repeat\n#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n#name=int*5, uint*5, float*3, complex*3#\n#CNAME=(CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@\" STRBITSOF_@CNAME@ \"_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n\n/**end repeat**/\n\n\n\n\nstatic PyNumberMethods longdoubletype_as_number;\nstatic PyNumberMethods clongdoubletype_as_number;\n\nstatic void \ninitialize_numeric_types(void)\n{\n\tPyGenericArrType_Type.tp_dealloc = (destructor)gentype_dealloc;\n\tPyGenericArrType_Type.tp_as_number = &gentype_as_number;\n\tPyGenericArrType_Type.tp_as_buffer = &gentype_as_buffer;\n\tPyGenericArrType_Type.tp_flags = BASEFLAGS;\n\tPyGenericArrType_Type.tp_methods = gentype_methods;\n\tPyGenericArrType_Type.tp_getset = gentype_getsets;\n\tPyGenericArrType_Type.tp_new = NULL;\n\tPyGenericArrType_Type.tp_free = PyObject_Del;\n\tPyGenericArrType_Type.tp_repr = gentype_repr;\n\tPyGenericArrType_Type.tp_str = gentype_str;\n\tPyGenericArrType_Type.tp_richcompare = gentype_richcompare;\n\n\t/**begin repeat\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, \nComplexFloating, Flexible, Character#\n\t*/\n Py@NAME@ArrType_Type.tp_flags = BASEFLAGS;\n\t/**end repeat**/\n\n\t/**begin repeat\n#name=bool, byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, void, object#\n#NAME=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Void, Object#\n\t*/\n\tPy@NAME@ArrType_Type.tp_flags = LEAFFLAGS;\n\tPy@NAME@ArrType_Type.tp_new = @name@_arrtype_new;\n\tPy@NAME@ArrType_Type.tp_richcompare = gentype_richcompare;\n\t/**end repeat**/\n\t/* Allow the Void type to be subclassed -- for adding new types */\n\tPyVoidArrType_Type.tp_flags = BASEFLAGS;\n\n /**begin repeat\n#name=bool, byte, short, longlong, ubyte, ushort, uint, ulong, ulonglong, float, longdouble, cfloat, clongdouble, void, object#\n#NAME=Bool, Byte, Short, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, LongDouble, CFloat, CLongDouble, Void, Object#\n */\n Py@NAME@ArrType_Type.tp_hash = @name@_arrtype_hash;\n /**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\n /* We won't be inheriting from Python Int type. */\n PyIntArrType_Type.tp_hash = int_arrtype_hash;\n#endif\n\n\t/* These need to be coded specially because getitem does not\n\t return a normal Python type\n\t*/\n\tPyLongDoubleArrType_Type.tp_as_number = &longdoubletype_as_number;\n\tPyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number;\n\n\t/**begin repeat\n#name=int, long, hex, oct, float, repr, str#\n#kind=tp_as_number->nb*5, tp*2#\n\t*/\n\tPyLongDoubleArrType_Type.@kind@_@name@ = longdoubletype_@name@;\n\tPyCLongDoubleArrType_Type.@kind@_@name@ = clongdoubletype_@name@;\n\t/**end repeat**/\n\n\tPyStringArrType_Type.tp_itemsize = sizeof(char);\n\tPyStringArrType_Type.tp_dealloc = string_arrtype_dealloc;\n\tPyFlexibleArrType_Type.tp_dealloc = flexible_dealloc;\n\tPyObjectArrType_Type.tp_dealloc = object_arrtype_dealloc;\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMapIter_Type.tp_iter = PyObject_SelfIter;\n}\n\n\nstatic PyTypeObject *typeobjects[] = {\n\t&PyBoolArrType_Type,\n\t&PyByteArrType_Type,\n\t&PyUByteArrType_Type,\n\t&PyShortArrType_Type,\n\t&PyUShortArrType_Type,\n\t&PyIntArrType_Type,\n\t&PyUIntArrType_Type,\n\t&PyLongArrType_Type,\n\t&PyULongArrType_Type,\n\t&PyLongLongArrType_Type,\n\t&PyULongLongArrType_Type,\n\t&PyFloatArrType_Type,\n\t&PyDoubleArrType_Type,\n\t&PyLongDoubleArrType_Type,\n\t&PyCFloatArrType_Type,\n\t&PyCDoubleArrType_Type,\n\t&PyCLongDoubleArrType_Type,\n\t&PyObjectArrType_Type,\n\t&PyStringArrType_Type,\n\t&PyUnicodeArrType_Type,\n\t&PyVoidArrType_Type\n};\n\n\nstatic int\nPyArray_TypenumFromTypeObject(PyObject *type) \n{\n\tint typenum, i;\n\n\ttypenum = PyArray_NOTYPE;\n i = 0;\n\twhile(i < PyArray_NTYPES) {\n\t\tif (type == (PyObject *)typeobjects[i]) {\n\t\t\ttypenum = i;\n\t\t\tbreak;\n\t\t}\n i++;\n\t}\n\tif (typenum != PyArray_NOTYPE)\n\t\treturn typenum;\n\n\t/* Find registered types */\n\t\n\t/* here */\n\n\t/* Convert generic types to specific types */\n\tif ((type == (PyObject *) &PyNumericArrType_Type) || \\\n\t (type == (PyObject *) &PyInexactArrType_Type) || \\\n\t (type == (PyObject *) &PyFloatingArrType_Type))\n\t\treturn PyArray_DOUBLE;\n\telse if (type == (PyObject *)&PyComplexFloatingArrType_Type)\n\t\treturn PyArray_CDOUBLE;\n\telse if ((type == (PyObject *)&PyIntegerArrType_Type) ||\t\\\n\t\t (type == (PyObject *)&PySignedIntegerArrType_Type))\n\t\treturn PyArray_LONG;\n\telse if (type == (PyObject *) &PyUnsignedIntegerArrType_Type)\n\t\treturn PyArray_ULONG;\n else if (type == (PyObject *) &PyCharacterArrType_Type)\n\t\treturn PyArray_STRING;\n\telse if (type == (PyObject *) &PyFlexibleArrType_Type)\n\t\treturn PyArray_VOID;\n\telse if (type == (PyObject *)&PyBool_Type)\n\t\ttypenum = PyArray_BOOL;\n\telse if (type == (PyObject *)&PyInt_Type)\n\t\ttypenum = PyArray_LONG;\n\telse if (type == (PyObject *)&PyFloat_Type)\n\t\ttypenum = PyArray_DOUBLE;\t\n\telse if (type == (PyObject *)&PyComplex_Type)\n\t\ttypenum = PyArray_CDOUBLE;\n\telse if (type == (PyObject *)&PyString_Type)\n\t\ttypenum = PyArray_STRING;\n\telse if (type == (PyObject *)&PyUnicode_Type)\n\t\ttypenum = PyArray_UNICODE;\n\telse if (type == (PyObject *)&PyBuffer_Type)\n\t\ttypenum = PyArray_VOID;\n\telse\n\t\ttypenum = PyArray_OBJECT;\n\treturn typenum;\n}\n\nstatic void \nPyArray_TypecodeFromTypeObject(PyObject *type, PyArray_Typecode *typecode) {\n\tint itemsize = 0;\n\tint type_num;\n\n\ttype_num = PyArray_TypenumFromTypeObject(type);\n\ttypecode->type_num = type_num;\n\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n itemsize = 0;\n\t}\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type_num);\n\t\tif (descr != NULL)\n\t\t\titemsize = descr->elsize;\n\t}\n\ttypecode->itemsize = itemsize;\n\treturn;\n}\n\nstatic void \nPyArray_TypecodeFromScalar(PyObject *sc, PyArray_Typecode *typecode)\n{\n\tint type_num;\n\n PyArray_TypecodeFromTypeObject((PyObject *)sc->ob_type, typecode);\n if (typecode->itemsize == 0) {\n type_num = typecode->type_num;\n\t\tif (type_num == PyArray_STRING) \n\t\t\ttypecode->itemsize = PyString_GET_SIZE(sc);\n\t\telse if (type_num == PyArray_UNICODE)\n\t\t\ttypecode->itemsize = PyUnicode_GET_DATA_SIZE(sc);\n\t\telse if (type_num == PyArray_VOID) {\n\t\t\ttypecode->itemsize = \\\n\t\t\t\t((PyVoidScalarObject *)sc)->ob_size;\n\t\t}\n }\n\treturn;\n}\n\nstatic PyObject *\nPyArray_TypeObjectFromType(int type)\n{\n\tPyArray_Descr *descr;\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr == NULL) return NULL;\n\tPy_INCREF((PyObject *)descr->typeobj);\n\treturn (PyObject *)descr->typeobj;\n}\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "\t\t\tif (ret==NULL) {", "\t\t\t\tPyObject *newarr;", "\t\t\t\tPyErr_Clear();", "\t\t\t\t/* Convert object to Array scalar and try again */", "\t\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);", "\t\t\t\tif (newarr!=NULL) {", "\t\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(m1, newarr);", "\t\t\t\t\tPy_DECREF(newarr);", "\t\t\t\t}", "\t\t\t}", "\t\t\tif (ret==NULL) {", "\t\t\t\tPyObject *newarr;", "\t\t\t\tPyErr_Clear();", "\t\t\t\t/* Convert object to Array and try again */", "\t\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);", "\t\t\t\tif (newarr!=NULL) {", "\t\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(newarr, m2);", "\t\t\t\t\tPy_DECREF(newarr);", "\t\t\t\t}", "\t\t\t}" ], "deleted": [] } }, { "old_path": "scipy/base/src/umathmodule.c.src", "new_path": "scipy/base/src/umathmodule.c.src", "filename": "umathmodule.c.src", "extension": "src", "change_type": "MODIFY", "diff": "@@ -1052,12 +1052,32 @@ static void\n }\n /**end repeat**/\n \n+/**begin repeat\n+\n+#kind=greater, greater_equal, less, less_equal, equal, not_equal, logical_and, logical_or, bitwise_and, bitwise_or, bitwise_xor#\n+#OP=>, >=, <, <=, ==, !=, &&, ||, &, |, ^#\n+**/\n+static void\n+BOOL_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n+{\n+\tregister intp i;\n+\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+\tchar *i1=args[0], *i2=args[1], *op=args[2];\n+\tBool in1, in2;\n+\tfor(i=0; i*17, >=*17, <*17, <=*17#\n-#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#\n-#kind= greater*17, greater_equal*17, less*17, less_equal*17#\n+#TYPE=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE)*4#\n+#OP= >*16, >=*16, <*16, <=*16#\n+#typ=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#\n+#kind= greater*16, greater_equal*16, less*16, less_equal*16#\n */\n \n static void \n@@ -1075,10 +1095,10 @@ static void\n \n /**begin repeat\n \n-#TYPE=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*4#\n-#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*4#\n-#OP= ==*14, !=*14, &&*14, ||*14#\n-#kind=equal*14, not_equal*14, logical_and*14, logical_or*14#\n+#TYPE=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*4#\n+#typ=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*4#\n+#OP= ==*13, !=*13, &&*13, ||*13#\n+#kind=equal*13, not_equal*13, logical_and*13, logical_or*13#\n */\n static void \n @TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n@@ -1135,8 +1155,8 @@ OBJECT_@kind@(char **args, intp *dimensions, intp *steps, void *func) {\n \n /**begin repeat\n \n-#TYPE=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE#\n-#typ=Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n+#TYPE=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE#\n+#typ=byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#\n */\n static void \n @TYPE@_negative(char **args, intp *dimensions, intp *steps, void *func) \n@@ -1168,6 +1188,7 @@ static void\n }\n /**end repeat**/\n \n+#define BOOL_negative BOOL_logical_not\n \n \n /**begin repeat\n@@ -1190,26 +1211,6 @@ static void\n }\n /**end repeat**/\n \n-/**begin repeat\n-\n-#TYPE=BOOL*3#\n-#typ=Bool*3#\n-#OP= &, |, ^#\n-#kind=and, or, xor#\n-\n-*/\n-static void \n-@TYPE@_bitwise_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n-{\n-\tregister intp i;\n-\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n-\tchar *i1=args[0], *i2=args[1], *op=args[2];\n-\tfor(i=0; i\n\n\n/* A whole slew of basic math functions are provided originally by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n#ifndef M_PI\n#define M_PI 3.14159265358979323846264338328\n#endif\n\n#ifndef HAVE_INVERSE_HYPERBOLIC\nstatic double acosh(double x)\n{\n\treturn log(x + sqrt((x-1.0)*(x+1.0)));\n}\n\nstatic double asinh(double xx)\n{\n\tdouble x;\n\tint sign;\n\tif (xx < 0.0) {\n\t\tsign = -1;\n\t\tx = -xx;\n\t}\n\telse {\n\t\tsign = 1;\n\t\tx = xx;\n\t}\n\treturn sign*log(x + sqrt(x*x+1.0));\n}\n\nstatic double atanh(double x)\n{\n\treturn 0.5*log((1.0+x)/(1.0-x));\n}\n#endif\n\n#if !defined(HAVE_INVERSE_HYPERBOLIC_FLOAT)\nstatic float acoshf(float x)\n{\n return (float)acosh((double)(x));\n}\n\nstatic float asinhf(float x)\n{\n return (float)asinh((double)(x));\n}\n\nstatic float atanhf(float x)\n{\n return (float)atanh((double)(x));\n}\n#endif\n\n#ifdef HAVE_HYPOT\n#if !defined(NeXT) && !defined(_MSC_VER)\nextern double hypot(double, double);\n#endif\n#else\ndouble hypot(double x, double y)\n{\n\tdouble yx;\n\n\tx = fabs(x);\n\ty = fabs(y);\n\tif (x < y) {\n\t\tdouble temp = x;\n\t\tx = y;\n\t\ty = temp;\n\t}\n\tif (x == 0.)\n\t\treturn 0.;\n\telse {\n\t\tyx = y/x;\n\t\treturn x*sqrt(1.+yx*yx);\n\t}\n}\n#endif\n\n\n\n/* Define isnan, isinf, isfinite, signbit if needed */\n/* Use fpclassify if possible */\n/* isnan, isinf --\n these will use macros and then fpclassify if available before\n defaulting to a dumb convert-to-double version...\n\n isfinite -- define a macro if not already available\n signbit -- if macro available use it, otherwise define a function\n and a dumb convert-to-double version for other types.\n*/\n\n#if defined(fpclassify)\n\n#if !defined(isnan)\n#define isnan(x) (fpclassify(x) == FP_NAN)\n#endif\n#if !defined(isinf)\n#define isinf(x) (fpclassify(x) == FP_INFINITE)\n#endif\n\n#else /* check to see if already have a function like this */\n\n#if !defined(HAVE_ISNAN)\n\n#if !defined(isnan)\n#include \"_isnan.c\"\n#endif\n\n#if !defined(isinf)\n#define isinf(x) (!isnan((x)) && isnan((x)-(x)))\n#endif\n\n#endif /* HAVE_ISNAN */\n#endif /* !defined(isnan) */\n\n\n/* Define signbit if needed */\n#if !defined(signbit)\n#include \"_signbit.c\"\n#endif\n\n\n/* Now defined the extended type macros */\n\n/* We assume that isnan and isinf are defined in the same \n way: as functions, with extended functions, or macros\n*/\n\n#if !defined(isnan)\n\n#if !defined(HAVE_LONGDOUBLE_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanl(x) isnan((double)(x)))\n#define isinfl(x) (!isnanl((x)) && isnanl((x)-(x)))\n#endif\n\n#if !defined(HAVE_FLOAT_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanf(x) isnan((double)(x)))\n#define isinff(x) (!isnanlf((x)) && isnanf((x)-(x))\n#endif\n\n#else /* !defined(isnan) */\n\n#define isnanl(x) isnan(x)\n#define isnanf(x) isnan(x)\n#define isinfl(x) isinf(x)\n#define isinff(x) isinf(x)\n\n#endif /* !defined(isnan) */\n\n\n\n#if !defined(signbit)\n#define signbitl(x) ((longdouble) signbit((double)(x)))\n#define signbitf(x) ((float) signbit((double) (x)))\n#else\n#define signbitl(x) signbit(x)\n#define signbitf(x) signbit(x)\n#endif\n\n#if !defined(isfinite)\n#define isfinite(x) (!(isinf(x) || isnan(x)))\n#endif\n#define isfinitef(x) (!(isinff(x) || isnanf(x)))\n#define isfinitel(x) (!(isinfl(x) || isnanl(x)))\n\n\n/* First, the C functions that do the real work */\n\n/* if C99 extensions not availble\n\nthen define dummy functions that use the double versions for\n\nsin, cos, tan\nsinh, cosh, tanh, \nfabs, floor, ceil, fmod, sqrt, log10, log, exp, fabs\nasin, acos, atan, \nasinh, acosh, atanh\n\nhypot, atan2, pow\n\n*/\n\n/**begin repeat\n\n#kind=(sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,sqrt,log10,log,exp,asin,acos,atan,asinh,acosh,atanh)*2#\n#typ=longdouble*19, float*19#\n#c=l*19,f*19#\n#TYPE=LONGDOUBLE*19, FLOAT*19#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x) {\n\treturn (@typ@) @kind@((double)x);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n\n#kind=(atan2,hypot,pow,fmod)*2#\n#typ=longdouble*4, float*4#\n#c=l*4,f*4#\n#TYPE=LONGDOUBLE*4,FLOAT*4#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x, @typ@ y) {\n\treturn (@typ@) @kind@((double)x, (double) y);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n#kind=modf*2#\n#typ=longdouble, float#\n#c=l,f#\n#TYPE=LONGDOUBLE, FLOAT#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ modf@c@(@typ@ x, @typ@ *iptr) {\n double nx, niptr, y;\n nx = (double) x;\n y = modf(nx, &niptr);\n *iptr = (@typ@) niptr;\n return (@typ@) y;\n}\n#endif\n/**end repeat**/\n\n\n\n/* Don't pass structures between functions (only pointers) because how\n structures are passed is compiler dependent and could cause\n segfaults if ufuncobject.c is compiled with a different compiler\n than an extension that makes use of the UFUNC API\n*/\n\n/**begin repeat\n\n#typ=float, double, longdouble#\n#c=f,,l#\n*/\n\n/* constants */\nstatic c@typ@ nc_1@c@ = {1., 0.};\nstatic c@typ@ nc_half@c@ = {0.5, 0.};\nstatic c@typ@ nc_i@c@ = {0., 1.};\nstatic c@typ@ nc_i2@c@ = {0., 0.5};\n/*\nstatic c@typ@ nc_mi@c@ = {0., -1.};\nstatic c@typ@ nc_pi2@c@ = {M_PI/2., 0.};\n*/\n\nstatic void\nnc_sum@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real + b->real;\n\tr->imag = a->imag + b->imag;\n\treturn;\n}\n\nstatic void\nnc_diff@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real - b->real;\n\tr->imag = a->imag - b->imag;\n\treturn;\n}\n\nstatic void\nnc_neg@c@(c@typ@ *a, c@typ@ *r)\n{\n\tr->real = -a->real;\n\tr->imag = -a->imag;\n\treturn;\n}\n\nstatic void\nnc_prod@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\tr->real = ar*br - ai*bi;\n\tr->imag = ar*bi + ai*br;\n\treturn;\n}\n\nstatic void\nnc_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = (ar*br + ai*bi)/d;\n\tr->imag = (ai*br - ar*bi)/d;\n\treturn;\n}\n\nstatic void\nnc_floor_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = floor@c@((ar*br + ai*bi)/d);\n\tr->imag = 0;\n\treturn;\n}\n\nstatic void \nnc_sqrt@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ s,d;\n\tif (x->real == 0. && x->imag == 0.)\n\t\t*r = *x;\n\telse {\n\t\ts = sqrt@c@(0.5*(fabs@c@(x->real) + hypot@c@(x->real,x->imag)));\n\t\td = 0.5*x->imag/s;\n\t\tif (x->real > 0.) {\n\t\t\tr->real = s;\n\t\t\tr->imag = d;\n\t\t}\n\t\telse if (x->imag >= 0.) {\n\t\t\tr->real = d;\n\t\t\tr->imag = s;\n\t\t}\n\t\telse {\n\t\t\tr->real = -d;\n\t\t\tr->imag = -s;\n\t\t}\n\t}\n\treturn;\n}\n\nstatic void \nnc_log@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ l = hypot@c@(x->real,x->imag);\n\tr->imag = atan2@c@(x->imag, x->real);\n\tr->real = log@c@(l);\n\treturn;\n}\n\nstatic void \nnc_exp@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ a = exp@c@(x->real);\n\tr->real = a*cos@c@(x->imag);\n\tr->imag = a*sin@c@(x->imag);\n\treturn;\n}\n\nstatic void\nnc_pow@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\t\n\tif (br == 0. && bi == 0.) {\n\t\tr->real = 1.;\n\t\tr->imag = 0.;\n\t}\n\telse if (ar == 0. && ai == 0.) {\n\t\tr->real = 0.;\n\t\tr->imag = 0.;\n\t}\n\telse {\n\t\tnc_log@c@(a, r);\n\t\tnc_prod@c@(r, b, r);\n\t\tnc_exp@c@(r, r);\n\t}\n\treturn;\n}\n\n\nstatic void \nnc_prodi@c@(c@typ@ *x, c@typ@ *r)\n{\n\tr->real = -x->imag;\n\tr->imag = x->real;\n\treturn;\n}\n\n\nstatic void \nnc_acos@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x,x,r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn; \n\t/* return nc_neg(nc_prodi(nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))))));\n\t*/\n}\n\nstatic void \nnc_acosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\treturn;\n\t/*\n\t return nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))));\n\t*/\n}\n\nstatic void \nnc_asin@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(x, pa);\n\tnc_sum@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/* \n\t return nc_neg(nc_prodi(nc_log(nc_sum(nc_prod(nc_i,x),\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x)))))));\n\t*/\n}\n\n\nstatic void \nnc_asinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_sum@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_diff@c@(r, x, r);\n\tnc_log@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/*\n\t return nc_neg(nc_log(nc_diff(nc_sqrt(nc_sum(nc_1,nc_prod(x,x))),x)));\n\t*/\n}\n\nstatic void \nnc_atan@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_i@c@, x, pa);\n\tnc_sum@c@(&nc_i@c@, x, r);\n\tnc_quot@c@(r, pa, r);\n\tnc_log@c@(r,r);\n\tnc_prod@c@(&nc_i2@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_i2,nc_log(nc_quot(nc_sum(nc_i,x),nc_diff(nc_i,x))));\n\t*/\n}\n\nstatic void \nnc_atanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_1@c@, x, r);\n\tnc_sum@c@(&nc_1@c@, x, pa);\n\tnc_quot@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prod@c@(&nc_half@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_half,nc_log(nc_quot(nc_sum(nc_1,x),nc_diff(nc_1,x))));\n\t*/\n}\n\nstatic void\nnc_cos@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos@c@(xr)*cosh@c@(xi);\n\tr->imag = -sin@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void \nnc_cosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos(xi)*cosh(xr);\n\tr->imag = sin(xi)*sinh(xr);\n\treturn;\n}\n\n\n#define M_LOG10_E 0.434294481903251827651128918916605082294397\n\nstatic void \nnc_log10@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_log@c@(x, r);\n\tr->real *= M_LOG10_E;\n\tr->imag *= M_LOG10_E;\n\treturn;\n}\n\nstatic void \nnc_sin@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = sin@c@(xr)*cosh@c@(xi);\n\tr->imag = cos@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void\nnc_sinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag; \n\tr->real = cos@c@(xi)*sinh@c@(xr);\n\tr->imag = sin@c@(xi)*cosh@c@(xr);\n\treturn;\n}\n\nstatic void \nnc_tan@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ sr,cr,shi,chi;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsr = sin@c@(xr);\n\tcr = cos@c@(xr);\n\tshi = sinh(xi);\n\tchi = cosh(xi);\n\trs = sr*chi;\n\tis = cr*shi;\n\trc = cr*chi;\n\tic = -sr*shi;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\nstatic void \nnc_tanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ si,ci,shr,chr;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsi = sin@c@(xi);\n\tci = cos@c@(xi);\n\tshr = sinh@c@(xr);\n\tchr = cosh@c@(xr);\n\trs = ci*shr;\n\tis = si*chr;\n\trc = ci*chr;\n\tic = si*shr;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#TYPE=(BOOL, BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*2#\n#OP=||, +*13, ^, -*13#\n#kind=add*14, subtract*14#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*2#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else\n\tah = al = bh = bl = 0;\n#endif\n\n /* 128-bit product: z*2**64 + (x+y)*2**32 + w */\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n\t/* *c = ((x + y)<<32) + w; */\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>32) || (y>>32) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 32);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>64) || (y>>64) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 64);\n#else\n\treturn 0;\n#endif\n\t\n}\n\nstatic int slonglong_overflow(longlong a0, longlong b0)\n{\n\tulonglong a, b;\n ulonglong ah, al, bh, bl, w, x, y, z;\n\n /* Convert to non-negative quantities */\n\tif (a0 < 0) { a = -a0; } else { a = a0; }\n\tif (b0 < 0) { b = -b0; } else { b = b0; }\n\n\n#if SIZEOF_LONGLONG == 64\n\tah = (a >> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else \n\tah = al = bh = bl = 0;\n#endif\n\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n /* \n\t ulonglong c = ((x + y)<<32) + w;\n\t if ((a0 < 0) ^ (b0 < 0))\n\t *c = -c;\n\t else \n\t *c = c\n\t */\n\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>31) || (y>>31) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 31);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>63) || (y>>63) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 63);\n#else\n\treturn 0;\n#endif\n}\n\n/** end direct numarray code **/\n\nstatic void\nBOOL_multiply(char **args, intp *dimensions, intp *steps, void *func) {\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nULONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tulonglong temp;\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\telse if (temp < MIN_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nLONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tlonglong temp;\n\tfor (i=0; i, >=, <, <=, ==, !=, &&, ||, &, |, ^#\n**/\nstatic void\nBOOL_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tBool in1, in2;\n\tfor(i=0; i*16, >=*16, <*16, <=*16#\n#typ=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#\n#kind= greater*16, greater_equal*16, less*16, less_equal*16#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i>*10#\n#kind=remainder*10, bitwise_and*10, bitwise_or*10, bitwise_xor*10, left_shift*10, right_shift*10#\n\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i*17, <*17#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*2#\n#kind= maximum*17, minimum*17#\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i\n\n\n/* A whole slew of basic math functions are provided originally by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n#ifndef M_PI\n#define M_PI 3.14159265358979323846264338328\n#endif\n\n#ifndef HAVE_INVERSE_HYPERBOLIC\nstatic double acosh(double x)\n{\n\treturn log(x + sqrt((x-1.0)*(x+1.0)));\n}\n\nstatic double asinh(double xx)\n{\n\tdouble x;\n\tint sign;\n\tif (xx < 0.0) {\n\t\tsign = -1;\n\t\tx = -xx;\n\t}\n\telse {\n\t\tsign = 1;\n\t\tx = xx;\n\t}\n\treturn sign*log(x + sqrt(x*x+1.0));\n}\n\nstatic double atanh(double x)\n{\n\treturn 0.5*log((1.0+x)/(1.0-x));\n}\n#endif\n\n#if !defined(HAVE_INVERSE_HYPERBOLIC_FLOAT)\nstatic float acoshf(float x)\n{\n return (float)acosh((double)(x));\n}\n\nstatic float asinhf(float x)\n{\n return (float)asinh((double)(x));\n}\n\nstatic float atanhf(float x)\n{\n return (float)atanh((double)(x));\n}\n#endif\n\n#ifdef HAVE_HYPOT\n#if !defined(NeXT) && !defined(_MSC_VER)\nextern double hypot(double, double);\n#endif\n#else\ndouble hypot(double x, double y)\n{\n\tdouble yx;\n\n\tx = fabs(x);\n\ty = fabs(y);\n\tif (x < y) {\n\t\tdouble temp = x;\n\t\tx = y;\n\t\ty = temp;\n\t}\n\tif (x == 0.)\n\t\treturn 0.;\n\telse {\n\t\tyx = y/x;\n\t\treturn x*sqrt(1.+yx*yx);\n\t}\n}\n#endif\n\n\n\n/* Define isnan, isinf, isfinite, signbit if needed */\n/* Use fpclassify if possible */\n/* isnan, isinf --\n these will use macros and then fpclassify if available before\n defaulting to a dumb convert-to-double version...\n\n isfinite -- define a macro if not already available\n signbit -- if macro available use it, otherwise define a function\n and a dumb convert-to-double version for other types.\n*/\n\n#if defined(fpclassify)\n\n#if !defined(isnan)\n#define isnan(x) (fpclassify(x) == FP_NAN)\n#endif\n#if !defined(isinf)\n#define isinf(x) (fpclassify(x) == FP_INFINITE)\n#endif\n\n#else /* check to see if already have a function like this */\n\n#if !defined(HAVE_ISNAN)\n\n#if !defined(isnan)\n#include \"_isnan.c\"\n#endif\n\n#if !defined(isinf)\n#define isinf(x) (!isnan((x)) && isnan((x)-(x)))\n#endif\n\n#endif /* HAVE_ISNAN */\n#endif /* !defined(isnan) */\n\n\n/* Define signbit if needed */\n#if !defined(signbit)\n#include \"_signbit.c\"\n#endif\n\n\n/* Now defined the extended type macros */\n\n/* We assume that isnan and isinf are defined in the same \n way: as functions, with extended functions, or macros\n*/\n\n#if !defined(isnan)\n\n#if !defined(HAVE_LONGDOUBLE_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanl(x) isnan((double)(x)))\n#define isinfl(x) (!isnanl((x)) && isnanl((x)-(x)))\n#endif\n\n#if !defined(HAVE_FLOAT_FUNCS) || !defined(HAVE_ISNAN)\n#define isnanf(x) isnan((double)(x)))\n#define isinff(x) (!isnanlf((x)) && isnanf((x)-(x))\n#endif\n\n#else /* !defined(isnan) */\n\n#define isnanl(x) isnan(x)\n#define isnanf(x) isnan(x)\n#define isinfl(x) isinf(x)\n#define isinff(x) isinf(x)\n\n#endif /* !defined(isnan) */\n\n\n\n#if !defined(signbit)\n#define signbitl(x) ((longdouble) signbit((double)(x)))\n#define signbitf(x) ((float) signbit((double) (x)))\n#else\n#define signbitl(x) signbit(x)\n#define signbitf(x) signbit(x)\n#endif\n\n#if !defined(isfinite)\n#define isfinite(x) (!(isinf(x) || isnan(x)))\n#endif\n#define isfinitef(x) (!(isinff(x) || isnanf(x)))\n#define isfinitel(x) (!(isinfl(x) || isnanl(x)))\n\n\n/* First, the C functions that do the real work */\n\n/* if C99 extensions not availble\n\nthen define dummy functions that use the double versions for\n\nsin, cos, tan\nsinh, cosh, tanh, \nfabs, floor, ceil, fmod, sqrt, log10, log, exp, fabs\nasin, acos, atan, \nasinh, acosh, atanh\n\nhypot, atan2, pow\n\n*/\n\n/**begin repeat\n\n#kind=(sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,sqrt,log10,log,exp,asin,acos,atan,asinh,acosh,atanh)*2#\n#typ=longdouble*19, float*19#\n#c=l*19,f*19#\n#TYPE=LONGDOUBLE*19, FLOAT*19#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x) {\n\treturn (@typ@) @kind@((double)x);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n\n#kind=(atan2,hypot,pow,fmod)*2#\n#typ=longdouble*4, float*4#\n#c=l*4,f*4#\n#TYPE=LONGDOUBLE*4,FLOAT*4#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ @kind@@c@(@typ@ x, @typ@ y) {\n\treturn (@typ@) @kind@((double)x, (double) y);\n}\n#endif\n/**end repeat**/\n\n/**begin repeat\n#kind=modf*2#\n#typ=longdouble, float#\n#c=l,f#\n#TYPE=LONGDOUBLE, FLOAT#\n*/\n#ifndef HAVE_@TYPE@_FUNCS\n@typ@ modf@c@(@typ@ x, @typ@ *iptr) {\n double nx, niptr, y;\n nx = (double) x;\n y = modf(nx, &niptr);\n *iptr = (@typ@) niptr;\n return (@typ@) y;\n}\n#endif\n/**end repeat**/\n\n\n\n/* Don't pass structures between functions (only pointers) because how\n structures are passed is compiler dependent and could cause\n segfaults if ufuncobject.c is compiled with a different compiler\n than an extension that makes use of the UFUNC API\n*/\n\n/**begin repeat\n\n#typ=float, double, longdouble#\n#c=f,,l#\n*/\n\n/* constants */\nstatic c@typ@ nc_1@c@ = {1., 0.};\nstatic c@typ@ nc_half@c@ = {0.5, 0.};\nstatic c@typ@ nc_i@c@ = {0., 1.};\nstatic c@typ@ nc_i2@c@ = {0., 0.5};\n/*\nstatic c@typ@ nc_mi@c@ = {0., -1.};\nstatic c@typ@ nc_pi2@c@ = {M_PI/2., 0.};\n*/\n\nstatic void\nnc_sum@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real + b->real;\n\tr->imag = a->imag + b->imag;\n\treturn;\n}\n\nstatic void\nnc_diff@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\tr->real = a->real - b->real;\n\tr->imag = a->imag - b->imag;\n\treturn;\n}\n\nstatic void\nnc_neg@c@(c@typ@ *a, c@typ@ *r)\n{\n\tr->real = -a->real;\n\tr->imag = -a->imag;\n\treturn;\n}\n\nstatic void\nnc_prod@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\tr->real = ar*br - ai*bi;\n\tr->imag = ar*bi + ai*br;\n\treturn;\n}\n\nstatic void\nnc_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = (ar*br + ai*bi)/d;\n\tr->imag = (ai*br - ar*bi)/d;\n\treturn;\n}\n\nstatic void\nnc_floor_quot@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag; \n\t@typ@ d = br*br + bi*bi;\n\tr->real = floor@c@((ar*br + ai*bi)/d);\n\tr->imag = 0;\n\treturn;\n}\n\nstatic void \nnc_sqrt@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ s,d;\n\tif (x->real == 0. && x->imag == 0.)\n\t\t*r = *x;\n\telse {\n\t\ts = sqrt@c@(0.5*(fabs@c@(x->real) + hypot@c@(x->real,x->imag)));\n\t\td = 0.5*x->imag/s;\n\t\tif (x->real > 0.) {\n\t\t\tr->real = s;\n\t\t\tr->imag = d;\n\t\t}\n\t\telse if (x->imag >= 0.) {\n\t\t\tr->real = d;\n\t\t\tr->imag = s;\n\t\t}\n\t\telse {\n\t\t\tr->real = -d;\n\t\t\tr->imag = -s;\n\t\t}\n\t}\n\treturn;\n}\n\nstatic void \nnc_log@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ l = hypot@c@(x->real,x->imag);\n\tr->imag = atan2@c@(x->imag, x->real);\n\tr->real = log@c@(l);\n\treturn;\n}\n\nstatic void \nnc_exp@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ a = exp@c@(x->real);\n\tr->real = a*cos@c@(x->imag);\n\tr->imag = a*sin@c@(x->imag);\n\treturn;\n}\n\nstatic void\nnc_pow@c@(c@typ@ *a, c@typ@ *b, c@typ@ *r)\n{\n\t@typ@ ar=a->real, br=b->real, ai=a->imag, bi=b->imag;\n\t\n\tif (br == 0. && bi == 0.) {\n\t\tr->real = 1.;\n\t\tr->imag = 0.;\n\t}\n\telse if (ar == 0. && ai == 0.) {\n\t\tr->real = 0.;\n\t\tr->imag = 0.;\n\t}\n\telse {\n\t\tnc_log@c@(a, r);\n\t\tnc_prod@c@(r, b, r);\n\t\tnc_exp@c@(r, r);\n\t}\n\treturn;\n}\n\n\nstatic void \nnc_prodi@c@(c@typ@ *x, c@typ@ *r)\n{\n\tr->real = -x->imag;\n\tr->imag = x->real;\n\treturn;\n}\n\n\nstatic void \nnc_acos@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x,x,r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn; \n\t/* return nc_neg(nc_prodi(nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))))));\n\t*/\n}\n\nstatic void \nnc_acosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_sum@c@(x, r, r);\n\tnc_log@c@(r, r);\n\treturn;\n\t/*\n\t return nc_log(nc_sum(x,nc_prod(nc_i,\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x))))));\n\t*/\n}\n\nstatic void \nnc_asin@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_prod@c@(x, x, r);\n\tnc_diff@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_prodi@c@(x, pa);\n\tnc_sum@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prodi@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/* \n\t return nc_neg(nc_prodi(nc_log(nc_sum(nc_prod(nc_i,x),\n\t nc_sqrt(nc_diff(nc_1,nc_prod(x,x)))))));\n\t*/\n}\n\n\nstatic void \nnc_asinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_prod@c@(x, x, r);\n\tnc_sum@c@(&nc_1@c@, r, r);\n\tnc_sqrt@c@(r, r);\n\tnc_diff@c@(r, x, r);\n\tnc_log@c@(r, r);\n\tnc_neg@c@(r, r);\n\treturn;\n\t/*\n\t return nc_neg(nc_log(nc_diff(nc_sqrt(nc_sum(nc_1,nc_prod(x,x))),x)));\n\t*/\n}\n\nstatic void \nnc_atan@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_i@c@, x, pa);\n\tnc_sum@c@(&nc_i@c@, x, r);\n\tnc_quot@c@(r, pa, r);\n\tnc_log@c@(r,r);\n\tnc_prod@c@(&nc_i2@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_i2,nc_log(nc_quot(nc_sum(nc_i,x),nc_diff(nc_i,x))));\n\t*/\n}\n\nstatic void \nnc_atanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\tc@typ@ a, *pa=&a;\n\tnc_diff@c@(&nc_1@c@, x, r);\n\tnc_sum@c@(&nc_1@c@, x, pa);\n\tnc_quot@c@(pa, r, r);\n\tnc_log@c@(r, r);\n\tnc_prod@c@(&nc_half@c@, r, r);\n\treturn;\n\t/*\n\t return nc_prod(nc_half,nc_log(nc_quot(nc_sum(nc_1,x),nc_diff(nc_1,x))));\n\t*/\n}\n\nstatic void\nnc_cos@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos@c@(xr)*cosh@c@(xi);\n\tr->imag = -sin@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void \nnc_cosh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = cos(xi)*cosh(xr);\n\tr->imag = sin(xi)*sinh(xr);\n\treturn;\n}\n\n\n#define M_LOG10_E 0.434294481903251827651128918916605082294397\n\nstatic void \nnc_log10@c@(c@typ@ *x, c@typ@ *r)\n{\n\tnc_log@c@(x, r);\n\tr->real *= M_LOG10_E;\n\tr->imag *= M_LOG10_E;\n\treturn;\n}\n\nstatic void \nnc_sin@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag;\n\tr->real = sin@c@(xr)*cosh@c@(xi);\n\tr->imag = cos@c@(xr)*sinh@c@(xi);\n\treturn;\n}\n\nstatic void\nnc_sinh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ xr=x->real, xi=x->imag; \n\tr->real = cos@c@(xi)*sinh@c@(xr);\n\tr->imag = sin@c@(xi)*cosh@c@(xr);\n\treturn;\n}\n\nstatic void \nnc_tan@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ sr,cr,shi,chi;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsr = sin@c@(xr);\n\tcr = cos@c@(xr);\n\tshi = sinh(xi);\n\tchi = cosh(xi);\n\trs = sr*chi;\n\tis = cr*shi;\n\trc = cr*chi;\n\tic = -sr*shi;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\nstatic void \nnc_tanh@c@(c@typ@ *x, c@typ@ *r)\n{\n\t@typ@ si,ci,shr,chr;\n\t@typ@ rs,is,rc,ic;\n\t@typ@ d;\n\t@typ@ xr=x->real, xi=x->imag;\n\tsi = sin@c@(xi);\n\tci = cos@c@(xi);\n\tshr = sinh@c@(xr);\n\tchr = cosh@c@(xr);\n\trs = ci*shr;\n\tis = si*chr;\n\trc = ci*chr;\n\tic = si*shr;\n\td = rc*rc + ic*ic;\n\tr->real = (rs*rc+is*ic)/d;\n\tr->imag = (is*rc-rs*ic)/d;\n\treturn;\n}\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#TYPE=(BOOL, BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*2#\n#OP=||, +*13, ^, -*13#\n#kind=add*14, subtract*14#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*2#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else\n\tah = al = bh = bl = 0;\n#endif\n\n /* 128-bit product: z*2**64 + (x+y)*2**32 + w */\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n\t/* *c = ((x + y)<<32) + w; */\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>32) || (y>>32) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 32);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>64) || (y>>64) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 64);\n#else\n\treturn 0;\n#endif\n\t\n}\n\nstatic int slonglong_overflow(longlong a0, longlong b0)\n{\n\tulonglong a, b;\n ulonglong ah, al, bh, bl, w, x, y, z;\n\n /* Convert to non-negative quantities */\n\tif (a0 < 0) { a = -a0; } else { a = a0; }\n\tif (b0 < 0) { b = -b0; } else { b = b0; }\n\n\n#if SIZEOF_LONGLONG == 64\n\tah = (a >> 32);\n\tal = (a & 0xFFFFFFFFL);\n\tbh = (b >> 32);\n\tbl = (b & 0xFFFFFFFFL);\n#elif SIZEOF_LONGLONG == 128\n\tah = (a >> 64);\n\tal = (a & 0xFFFFFFFFFFFFFFFFL);\n\tbh = (b >> 64);\n\tbl = (b & 0xFFFFFFFFFFFFFFFFL);\n#else \n\tah = al = bh = bl = 0;\n#endif\n\n\tw = al*bl;\n\tx = bh*al;\n\ty = ah*bl;\n\tz = ah*bh;\n\n /* \n\t ulonglong c = ((x + y)<<32) + w;\n\t if ((a0 < 0) ^ (b0 < 0))\n\t *c = -c;\n\t else \n\t *c = c\n\t */\n\n#if SIZEOF_LONGLONG == 64\n\treturn z || (x>>31) || (y>>31) ||\n\t\t(((x & 0xFFFFFFFFL) + (y & 0xFFFFFFFFL) + (w >> 32)) >> 31);\n#elif SIZEOF_LONGLONG == 128\n\treturn z || (x>>63) || (y>>63) ||\n\t\t(((x & 0xFFFFFFFFFFFFFFFFL) + (y & 0xFFFFFFFFFFFFFFFFL) + (w >> 64)) >> 63);\n#else\n\treturn 0;\n#endif\n}\n\n/** end direct numarray code **/\n\nstatic void\nBOOL_multiply(char **args, intp *dimensions, intp *steps, void *func) {\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nULONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tulonglong temp;\n\tfor (i=0; i MAX_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\telse if (temp < MIN_@TYP@) \n\t\t\tgenerate_overflow_error();\n\t\t*((@typ@ *)op) = temp;\n\t} \n}\n\n/**end repeat**/\n\nstatic void \nLONGLONG_multiply(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0], is2=steps[1], os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tlonglong temp;\n\tfor (i=0; i*17, >=*17, <*17, <=*17#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#\n#kind= greater*17, greater_equal*17, less*17, less_equal*17#\n*/\n\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i>*10#\n#kind=remainder*10, bitwise_and*10, bitwise_or*10, bitwise_xor*10, left_shift*10, right_shift*10#\n\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i*17, <*17#\n#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*2#\n#kind= maximum*17, minimum*17#\n*/\nstatic void \n@TYPE@_@kind@(char **args, intp *dimensions, intp *steps, void *func) \n{\n\tregister intp i;\n\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n\tchar *i1=args[0], *i2=args[1], *op=args[2];\n\tfor(i=0; i, >=, <, <=, ==, !=, &&, ||, &, |, ^#", "**/", "static void", "BOOL_@kind@(char **args, intp *dimensions, intp *steps, void *func)", "{", "\tregister intp i;", "\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", "\tchar *i1=args[0], *i2=args[1], *op=args[2];", "\tBool in1, in2;", "\tfor(i=0; i*16, >=*16, <*16, <=*16#", "#typ=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#", "#kind= greater*16, greater_equal*16, less*16, less_equal*16#", "#TYPE=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*4#", "#typ=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*4#", "#OP= ==*13, !=*13, &&*13, ||*13#", "#kind=equal*13, not_equal*13, logical_and*13, logical_or*13#", "#TYPE=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE#", "#typ=byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#", "#define BOOL_negative BOOL_logical_not" ], "deleted": [ "#TYPE=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE)*4#", "#OP= >*17, >=*17, <*17, <=*17#", "#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble)*4#", "#kind= greater*17, greater_equal*17, less*17, less_equal*17#", "#TYPE=(BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*4#", "#typ=(Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*4#", "#OP= ==*14, !=*14, &&*14, ||*14#", "#kind=equal*14, not_equal*14, logical_and*14, logical_or*14#", "#TYPE=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE#", "#typ=Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble#", "/**begin repeat", "", "#TYPE=BOOL*3#", "#typ=Bool*3#", "#OP= &, |, ^#", "#kind=and, or, xor#", "", "*/", "static void", "@TYPE@_bitwise_@kind@(char **args, intp *dimensions, intp *steps, void *func)", "{", "\tregister intp i;", "\tintp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", "\tchar *i1=args[0], *i2=args[1], *op=args[2];", "\tfor(i=0; i 1e10) and assert_all(isfinite(vals))\n+ assert_all(isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\nimport unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base);reload(scipy.base.type_check)\nfrom scipy.base import *\ndel sys.path[0]\n\ndef assert_all(x):\n assert(all(x)), x\n \nclass test_mintypecode(ScipyTestCase):\n\n def check_default_1(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype),'d')\n assert_equal(mintypecode('f'),'f')\n assert_equal(mintypecode('d'),'d')\n assert_equal(mintypecode('F'),'F')\n assert_equal(mintypecode('D'),'D')\n\n def check_default_2(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype+'f'),'f')\n assert_equal(mintypecode(itype+'d'),'d')\n assert_equal(mintypecode(itype+'F'),'F')\n assert_equal(mintypecode(itype+'D'),'D')\n assert_equal(mintypecode('ff'),'f')\n assert_equal(mintypecode('fd'),'d')\n assert_equal(mintypecode('fF'),'F')\n assert_equal(mintypecode('fD'),'D')\n assert_equal(mintypecode('df'),'d')\n assert_equal(mintypecode('dd'),'d')\n #assert_equal(mintypecode('dF',savespace=1),'F')\n assert_equal(mintypecode('dF'),'D')\n assert_equal(mintypecode('dD'),'D')\n assert_equal(mintypecode('Ff'),'F')\n #assert_equal(mintypecode('Fd',savespace=1),'F')\n assert_equal(mintypecode('Fd'),'D')\n assert_equal(mintypecode('FF'),'F')\n assert_equal(mintypecode('FD'),'D')\n assert_equal(mintypecode('Df'),'D')\n assert_equal(mintypecode('Dd'),'D')\n assert_equal(mintypecode('DF'),'D')\n assert_equal(mintypecode('DD'),'D')\n\n def check_default_3(self):\n assert_equal(mintypecode('fdF'),'D')\n #assert_equal(mintypecode('fdF',savespace=1),'F')\n assert_equal(mintypecode('fdD'),'D')\n assert_equal(mintypecode('fFD'),'D')\n assert_equal(mintypecode('dFD'),'D')\n\n assert_equal(mintypecode('ifd'),'d')\n assert_equal(mintypecode('ifF'),'F')\n assert_equal(mintypecode('ifD'),'D')\n assert_equal(mintypecode('idF'),'D')\n #assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \nclass test_isscalar(unittest.TestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(unittest.TestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(unittest.TestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert_all(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert_all(isnan(1) == 0)\n def check_complex(self):\n assert_all(isnan(1+1j) == 0)\n def check_complex1(self):\n assert_all(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert_all(isfinite(1) == 1)\n def check_complex(self):\n assert_all(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert_all(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert_all(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert_all(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert_all(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert_all(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isinf(log(-1.)) == 0)\n # assert_all(isnan(log(-1.)) == 1)\n\nclass test_isposinf(unittest.TestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(unittest.TestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(unittest.TestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))\n assert(vals[1] == 0)\n assert_all(vals[2] > 1e10) and assert_all(isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert_all(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert_all(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert_all(isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert_all(isfinite(vals)) \n #assert_all(vals.imag > 1e10) and assert_all(isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) \n\n\nclass test_real_if_close(unittest.TestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert_all(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert_all(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert_all(isrealobj(b))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", "source_code_before": "\nimport unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base);reload(scipy.base.type_check)\nfrom scipy.base import *\ndel sys.path[0]\n\ndef assert_all(x):\n assert(all(x)), x\n \nclass test_mintypecode(ScipyTestCase):\n\n def check_default_1(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype),'d')\n assert_equal(mintypecode('f'),'f')\n assert_equal(mintypecode('d'),'d')\n assert_equal(mintypecode('F'),'F')\n assert_equal(mintypecode('D'),'D')\n\n def check_default_2(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype+'f'),'f')\n assert_equal(mintypecode(itype+'d'),'d')\n assert_equal(mintypecode(itype+'F'),'F')\n assert_equal(mintypecode(itype+'D'),'D')\n assert_equal(mintypecode('ff'),'f')\n assert_equal(mintypecode('fd'),'d')\n assert_equal(mintypecode('fF'),'F')\n assert_equal(mintypecode('fD'),'D')\n assert_equal(mintypecode('df'),'d')\n assert_equal(mintypecode('dd'),'d')\n #assert_equal(mintypecode('dF',savespace=1),'F')\n assert_equal(mintypecode('dF'),'D')\n assert_equal(mintypecode('dD'),'D')\n assert_equal(mintypecode('Ff'),'F')\n #assert_equal(mintypecode('Fd',savespace=1),'F')\n assert_equal(mintypecode('Fd'),'D')\n assert_equal(mintypecode('FF'),'F')\n assert_equal(mintypecode('FD'),'D')\n assert_equal(mintypecode('Df'),'D')\n assert_equal(mintypecode('Dd'),'D')\n assert_equal(mintypecode('DF'),'D')\n assert_equal(mintypecode('DD'),'D')\n\n def check_default_3(self):\n assert_equal(mintypecode('fdF'),'D')\n #assert_equal(mintypecode('fdF',savespace=1),'F')\n assert_equal(mintypecode('fdD'),'D')\n assert_equal(mintypecode('fFD'),'D')\n assert_equal(mintypecode('dFD'),'D')\n\n assert_equal(mintypecode('ifd'),'d')\n assert_equal(mintypecode('ifF'),'F')\n assert_equal(mintypecode('ifD'),'D')\n assert_equal(mintypecode('idF'),'D')\n #assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \nclass test_isscalar(unittest.TestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(unittest.TestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(unittest.TestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert_all(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert_all(isnan(1) == 0)\n def check_complex(self):\n assert_all(isnan(1+1j) == 0)\n def check_complex1(self):\n assert_all(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert_all(isfinite(1) == 1)\n def check_complex(self):\n assert_all(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert_all(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert_all(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert_all(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert_all(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert_all(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isinf(log(-1.)) == 0)\n # assert_all(isnan(log(-1.)) == 1)\n\nclass test_isposinf(unittest.TestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(unittest.TestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(unittest.TestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))\n assert(vals[1] == 0)\n assert_all(vals[2] > 1e10) and assert_all(isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert_all(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert_all(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert_all(vals.imag > 1e10) and assert_all(isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert_all(isfinite(vals)) \n #assert_all(vals.imag > 1e10) and assert_all(isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) \n\n\nclass test_real_if_close(unittest.TestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert_all(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert_all(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert_all(isrealobj(b))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", "methods": [ { "name": "assert_all", "long_name": "assert_all( x )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 11, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_default_1", "long_name": "check_default_1( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 2, "token_count": 55, "parameters": [ "self" ], "start_line": 16, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_default_2", "long_name": "check_default_2( self )", "filename": "test_type_check.py", "nloc": 22, "complexity": 2, "token_count": 198, "parameters": [ "self" ], "start_line": 24, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_default_3", "long_name": "check_default_3( self )", "filename": "test_type_check.py", "nloc": 10, "complexity": 1, "token_count": 86, "parameters": [ "self" ], "start_line": 49, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 64, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 77, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 91, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 95, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 105, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 125, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 133, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 139, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 145, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 159, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 161, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 169, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_posinf_scalar", "long_name": "check_posinf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 171, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 173, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf_scalar", "long_name": "check_neginf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 177, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 191, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 198, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 203, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_good", "long_name": "check_complex_good( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 206, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_bad", "long_name": "check_complex_bad( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_bad2", "long_name": "check_complex_bad2( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 215, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 9, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 228, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "methods_before": [ { "name": "assert_all", "long_name": "assert_all( x )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 11, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_default_1", "long_name": "check_default_1( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 2, "token_count": 55, "parameters": [ "self" ], "start_line": 16, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_default_2", "long_name": "check_default_2( self )", "filename": "test_type_check.py", "nloc": 22, "complexity": 2, "token_count": 198, "parameters": [ "self" ], "start_line": 24, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_default_3", "long_name": "check_default_3( self )", "filename": "test_type_check.py", "nloc": 10, "complexity": 1, "token_count": 86, "parameters": [ "self" ], "start_line": 49, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 64, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 77, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 91, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 95, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 105, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 125, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 133, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 139, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 145, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 159, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 161, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 169, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_posinf_scalar", "long_name": "check_posinf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 171, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 173, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf_scalar", "long_name": "check_neginf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 177, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 191, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 198, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 203, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_good", "long_name": "check_complex_good( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 206, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_bad", "long_name": "check_complex_bad( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "self" ], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_bad2", "long_name": "check_complex_bad2( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 215, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 9, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 228, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "check_complex_bad", "long_name": "check_complex_bad( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 196, "complexity": 47, "token_count": 1807, "diff_parsed": { "added": [ " assert_all(isfinite(vals))" ], "deleted": [ " assert_all(vals.imag > 1e10) and assert_all(isfinite(vals))" ] } } ] }, { "hash": "bce31b09bd8a73d11734b7185d79309d59cbaa92", "msg": "Added compatibility information", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-06T02:47:25+00:00", "author_timezone": 0, "committer_date": "2005-10-06T02:47:25+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3dc10e072d3073655e78e6217b789a323da70a84" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 1, "insertions": 59, "lines": 60, "files": 2, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": null, "new_path": "COMPATIBILITY", "filename": "COMPATIBILITY", "extension": "COMPATIBILITY", "change_type": "ADD", "diff": "@@ -0,0 +1,54 @@\n+\n+\n+X.flat returns an indexable 1-D iterator (mostly similar to an array but always 1-d)\n+\n+long(<>) --> pylong(<>) if from Numeric * was changed to from scipy.base import *\n+\n+.typecode() --> .dtypechar\n+\n+.iscontiguous() --> .flags['CONTIGUOUS']\n+\n+.byteswapped() -> .byteswap()\n+\n+.itemsize() -> .itemsize\n+\n+If you used typecode characters:\n+\n+'c' -> 'S1'\n+'b' -> 'B'\n+'1' -> 'b'\n+'s' -> 'h'\n+'w' -> 'H'\n+'u' -> 'I'\n+\n+\n+C -level\n+\n+some API calls that used to take PyObject * now take PyArrayObject * (this should only cause warnings during compile and not actual problems). \n+ PyArray_Take \n+\n+These commands now return a buffer that must be freed once it is used\n+using PyMemData_FREE(ptr) or PyMemData_XFREE(ptr);\n+\n+a->descr->zero --> PyArray_Zero(a)\n+a->descr->one --> PyArray_One(a)\n+\n+Numeric/arrayobject.h --> scipy/arrayobject.h\n+\n+\n+# These will actually work and are defines for PyArray_BYTE, \n+# but you really should change it in your code\n+PyArray_CHAR --> PyArray_BYTE (or PyArray_STRING which is more flexible) \n+PyArray_SBYTE --> PyArray_BYTE\n+\n+Any uses of character codes will need adjusting....\n+use PyArray_XXXLTR where XXX is the name of the type.\n+\n+\n+If you used function pointers directly (why did you do that?),\n+the arguments have changed. \n+\n+a->descr->cast[i](fromdata, fromstep, todata, tostep, n)\n+a->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out)\n+\n+\n", "added_lines": 54, "deleted_lines": 0, "source_code": "\n\nX.flat returns an indexable 1-D iterator (mostly similar to an array but always 1-d)\n\nlong(<>) --> pylong(<>) if from Numeric * was changed to from scipy.base import *\n\n.typecode() --> .dtypechar\n\n.iscontiguous() --> .flags['CONTIGUOUS']\n\n.byteswapped() -> .byteswap()\n\n.itemsize() -> .itemsize\n\nIf you used typecode characters:\n\n'c' -> 'S1'\n'b' -> 'B'\n'1' -> 'b'\n's' -> 'h'\n'w' -> 'H'\n'u' -> 'I'\n\n\nC -level\n\nsome API calls that used to take PyObject * now take PyArrayObject * (this should only cause warnings during compile and not actual problems). \n PyArray_Take \n\nThese commands now return a buffer that must be freed once it is used\nusing PyMemData_FREE(ptr) or PyMemData_XFREE(ptr);\n\na->descr->zero --> PyArray_Zero(a)\na->descr->one --> PyArray_One(a)\n\nNumeric/arrayobject.h --> scipy/arrayobject.h\n\n\n# These will actually work and are defines for PyArray_BYTE, \n# but you really should change it in your code\nPyArray_CHAR --> PyArray_BYTE (or PyArray_STRING which is more flexible) \nPyArray_SBYTE --> PyArray_BYTE\n\nAny uses of character codes will need adjusting....\nuse PyArray_XXXLTR where XXX is the name of the type.\n\n\nIf you used function pointers directly (why did you do that?),\nthe arguments have changed. \n\na->descr->cast[i](fromdata, fromstep, todata, tostep, n)\na->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out)\n\n\n", "source_code_before": null, "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "", "", "X.flat returns an indexable 1-D iterator (mostly similar to an array but always 1-d)", "", "long(<>) --> pylong(<>) if from Numeric * was changed to from scipy.base import *", "", ".typecode() --> .dtypechar", "", ".iscontiguous() --> .flags['CONTIGUOUS']", "", ".byteswapped() -> .byteswap()", "", ".itemsize() -> .itemsize", "", "If you used typecode characters:", "", "'c' -> 'S1'", "'b' -> 'B'", "'1' -> 'b'", "'s' -> 'h'", "'w' -> 'H'", "'u' -> 'I'", "", "", "C -level", "", "some API calls that used to take PyObject * now take PyArrayObject * (this should only cause warnings during compile and not actual problems).", " PyArray_Take", "", "These commands now return a buffer that must be freed once it is used", "using PyMemData_FREE(ptr) or PyMemData_XFREE(ptr);", "", "a->descr->zero --> PyArray_Zero(a)", "a->descr->one --> PyArray_One(a)", "", "Numeric/arrayobject.h --> scipy/arrayobject.h", "", "", "# These will actually work and are defines for PyArray_BYTE,", "# but you really should change it in your code", "PyArray_CHAR --> PyArray_BYTE (or PyArray_STRING which is more flexible)", "PyArray_SBYTE --> PyArray_BYTE", "", "Any uses of character codes will need adjusting....", "use PyArray_XXXLTR where XXX is the name of the type.", "", "", "If you used function pointers directly (why did you do that?),", "the arguments have changed.", "", "a->descr->cast[i](fromdata, fromstep, todata, tostep, n)", "a->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out)", "", "" ], "deleted": [] } }, { "old_path": "scipy/base/include/scipy/arrayobject.h", "new_path": "scipy/base/include/scipy/arrayobject.h", "filename": "arrayobject.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -1099,8 +1099,11 @@ typedef struct {\n #define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n \t\t\t\t (type < PyArray_USERDEF+\\\n \t\t\t\t PyArray_NUMUSERTYPES))\n-\t\t\t\t \n \n+#define PyTypeNum_ISEXTENDED(type) (((type >= PyArray_STRING) && \\\n+\t\t\t\t (type <= PyArray_VOID)) ||\t \\\n+\t\t\t\t (type >= PyArray_USERDEF))\n+\t\t\t\t \n #define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n \n #define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n@@ -1114,6 +1117,7 @@ typedef struct {\n #define PyArray_ISPYTHONTYPE(obj) PyTypeNum_ISPYTHONTYPE(PyArray_TYPE(obj))\n #define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n #define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n+#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n #define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n \n /* Object arrays ignore notswapped flag */\n", "added_lines": 5, "deleted_lines": 1, "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n#define NDARRAY_VERSION 0x0400\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"%I64d\"\n# define ULONGLONG_FMT \"%I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"%lld\" Another possible variant\n #define ULONGLONG_FMT \"%llu\"\n\n\t #define LONGLONG_FMT \"%qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"%qu\"\n\t*/\n# define LONGLONG_FMT \"%Ld\"\n# define ULONGLONG_FMT \"%Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAKEFLOAT(x) x.\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80\n\ttypedef cdouble Complex160\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80\n\ttypedef cfloat Complex160\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80\n\ttypedef clongdouble Complex160\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n /* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and unbyteswapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (char *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, char *, void *);\n\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and byteswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(char *, intp, char *, intp, char *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, int, char *, void *);\n\n\ntypedef struct {\n \tPyTypeObject *typeobj; /* the type object for this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* character representing this type */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type -- \n\t\t\t\t or 0 if variable */\n \tint alignment; /* alignment needed for this type */\n\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n} PyArray_Descr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tint itemsize; /* needed for Flexible size arrays:\n CHAR, UNICODE, and VOID arrays\n \t\t\t */ \n\tPyObject *weakreflist; /* For weakreferences */\n\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\ntypedef struct { /* Just the type_num and itemsize variables \n\t\t for use in the TypeNum Converter function */\n\tint type_num;\n\tint itemsize;\n\tint fortran; /* Set to 1 if fortran-defined strides is desired */\n} PyArray_Typecode;\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n\t/* Not used -- always assumed \n#define OWN_DIMENSIONS 2 \n#define OWN_STRIDES 4 \n\t*/\n\n#define OWNDATA 8\n#define OWN_DATA OWNDATA\n\n#define FORTRAN 0x020 /* set if array is a contiguous Fortran array */\n\t /* first index varies the fastest in memory\n\t\t\t (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n\t/* array never has these two set -- FromAny flags only */\n#define FORCECAST 0x040 \n#define ENSURECOPY 0x080 \t\n\n#define ALIGNED 0x100\n#define NOTSWAPPED 0x200\n#define WRITEABLE 0x400\n\n /* Flag used in creating a new array, not set in the array */\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE MAX_INT32\n#define MAXBUFNUM 1024\n\n\n#define BEHAVED_FLAGS ALIGNED | NOTSWAPPED | WRITEABLE\n#define BEHAVED_FLAGS_RO ALIGNED | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n\n#define PyArray_ISCARRAY(m) PyArray_CHKFLAGS(m, CARRAY_FLAGS)\n#define PyArray_ISFARRAY(m) PyArray_CHKFLAGS(m, FARRAY_FLAGS)\n#define PyArray_ISBEHAVED(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS_RO)\n\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS\n#define END_THREADS Py_END_ALLOW_THREADS\n#define END_THREADS_FAIL Py_UNBLOCK_THREADS\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS\n#define END_THREADS\n#define END_THREADS_FAIL\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n unsigned char contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\\\n\tif (it->contiguous) it->dataptr += it->ao->itemsize;\t \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->itemsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n/* Not constructed anywhere. Just serves as a standard type that\n PyArray_Broadcast expects.\n\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n/* Map Iterator API */ \n#define PyArrayMapIter_Check(op) PyObject_TypeCheck(op, &PyArrayMapIter_Type)\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->itemsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type==PyArray_STRING) || \\\n\t\t\t\t (type==PyArray_UNICODE) ||\t\\\n\t\t\t\t (type==PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (((type >= PyArray_STRING) && \\\n\t\t\t\t (type <= PyArray_VOID)) ||\t \\\n\t\t\t\t (type >= PyArray_USERDEF))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHONTYPE(obj) PyTypeNum_ISPYTHONTYPE(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n/* Object arrays ignore notswapped flag */\n#define PyArray_ISNOTSWAPPED(m) (PyArray_CHKFLAGS(m, NOTSWAPPED) || \\\n\t\t\t\t PyArray_ISOBJECT(m))\n\n\n /* Often, rather than always convert to an array, \n we may want to delegate behavior for other objects passed in\n */\n\n\t/* \n\n#define Py_DELEGATE(op, name) \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, NULL);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS(op, name, args)\t\t\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, args);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS_KWDS(op, name, args, kwds)\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_Call(meth, args, kwds);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\t*/\n\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_Check(op) (PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_CheckScalar(m) (PyObject_TypeCheck((m),\t\t\t\\\n\t\t\t\t\t\t &PyGenericArrType_Type) \\\n\t\t\t\t|| ((PyArray_Check((m))) &&\t\t\\\n\t\t\t\t (((PyArrayObject *)(m))->nd == 0)))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj) \\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n\t (PyArrayObject *)(PyArray_ContiguousFromObject((PyObject *)(m), \\\n\t\t PyArray_TYPE(m), 0, 0))) \n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyList\n#define PyArray_ISSPACESAVER(m) TRUE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n#define NDARRAY_VERSION 0x0400\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"%I64d\"\n# define ULONGLONG_FMT \"%I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"%lld\" Another possible variant\n #define ULONGLONG_FMT \"%llu\"\n\n\t #define LONGLONG_FMT \"%qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"%qu\"\n\t*/\n# define LONGLONG_FMT \"%Ld\"\n# define ULONGLONG_FMT \"%Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAKEFLOAT(x) x.\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80\n\ttypedef cdouble Complex160\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80\n\ttypedef cfloat Complex160\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80\n\ttypedef clongdouble Complex160\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n /* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and unbyteswapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (char *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, char *, void *);\n\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and byteswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(char *, intp, char *, intp, char *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, int, char *, void *);\n\n\ntypedef struct {\n \tPyTypeObject *typeobj; /* the type object for this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* character representing this type */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type -- \n\t\t\t\t or 0 if variable */\n \tint alignment; /* alignment needed for this type */\n\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n} PyArray_Descr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tint itemsize; /* needed for Flexible size arrays:\n CHAR, UNICODE, and VOID arrays\n \t\t\t */ \n\tPyObject *weakreflist; /* For weakreferences */\n\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\ntypedef struct { /* Just the type_num and itemsize variables \n\t\t for use in the TypeNum Converter function */\n\tint type_num;\n\tint itemsize;\n\tint fortran; /* Set to 1 if fortran-defined strides is desired */\n} PyArray_Typecode;\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n\t/* Not used -- always assumed \n#define OWN_DIMENSIONS 2 \n#define OWN_STRIDES 4 \n\t*/\n\n#define OWNDATA 8\n#define OWN_DATA OWNDATA\n\n#define FORTRAN 0x020 /* set if array is a contiguous Fortran array */\n\t /* first index varies the fastest in memory\n\t\t\t (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n\t/* array never has these two set -- FromAny flags only */\n#define FORCECAST 0x040 \n#define ENSURECOPY 0x080 \t\n\n#define ALIGNED 0x100\n#define NOTSWAPPED 0x200\n#define WRITEABLE 0x400\n\n /* Flag used in creating a new array, not set in the array */\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE MAX_INT32\n#define MAXBUFNUM 1024\n\n\n#define BEHAVED_FLAGS ALIGNED | NOTSWAPPED | WRITEABLE\n#define BEHAVED_FLAGS_RO ALIGNED | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n\n#define PyArray_ISCARRAY(m) PyArray_CHKFLAGS(m, CARRAY_FLAGS)\n#define PyArray_ISFARRAY(m) PyArray_CHKFLAGS(m, FARRAY_FLAGS)\n#define PyArray_ISBEHAVED(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS_RO)\n\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS\n#define END_THREADS Py_END_ALLOW_THREADS\n#define END_THREADS_FAIL Py_UNBLOCK_THREADS\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS\n#define END_THREADS\n#define END_THREADS_FAIL\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n unsigned char contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\\\n\tif (it->contiguous) it->dataptr += it->ao->itemsize;\t \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->itemsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n/* Not constructed anywhere. Just serves as a standard type that\n PyArray_Broadcast expects.\n\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n/* Map Iterator API */ \n#define PyArrayMapIter_Check(op) PyObject_TypeCheck(op, &PyArrayMapIter_Type)\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->itemsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type==PyArray_STRING) || \\\n\t\t\t\t (type==PyArray_UNICODE) ||\t\\\n\t\t\t\t (type==PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\t\t\t\t \n\n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHONTYPE(obj) PyTypeNum_ISPYTHONTYPE(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n/* Object arrays ignore notswapped flag */\n#define PyArray_ISNOTSWAPPED(m) (PyArray_CHKFLAGS(m, NOTSWAPPED) || \\\n\t\t\t\t PyArray_ISOBJECT(m))\n\n\n /* Often, rather than always convert to an array, \n we may want to delegate behavior for other objects passed in\n */\n\n\t/* \n\n#define Py_DELEGATE(op, name) \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, NULL);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS(op, name, args)\t\t\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, args);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS_KWDS(op, name, args, kwds)\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_Call(meth, args, kwds);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\t*/\n\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_Check(op) (PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_CheckScalar(m) (PyObject_TypeCheck((m),\t\t\t\\\n\t\t\t\t\t\t &PyGenericArrType_Type) \\\n\t\t\t\t|| ((PyArray_Check((m))) &&\t\t\\\n\t\t\t\t (((PyArrayObject *)(m))->nd == 0)))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj) \\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n\t (PyArrayObject *)(PyArray_ContiguousFromObject((PyObject *)(m), \\\n\t\t PyArray_TYPE(m), 0, 0))) \n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyList\n#define PyArray_ISSPACESAVER(m) TRUE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 252, "complexity": 0, "token_count": 1156, "diff_parsed": { "added": [ "#define PyTypeNum_ISEXTENDED(type) (((type >= PyArray_STRING) && \\", "\t\t\t\t (type <= PyArray_VOID)) ||\t \\", "\t\t\t\t (type >= PyArray_USERDEF))", "", "#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))" ], "deleted": [ "" ] } } ] }, { "hash": "6de1ded3b69fc30f2588ba18daeeaccb8f399c5f", "msg": "Added more COMPATIBILITY info.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-06T16:55:50+00:00", "author_timezone": 0, "committer_date": "2005-10-06T16:55:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "bce31b09bd8a73d11734b7185d79309d59cbaa92" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 0, "insertions": 2, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "COMPATIBILITY", "new_path": "COMPATIBILITY", "filename": "COMPATIBILITY", "extension": "COMPATIBILITY", "change_type": "MODIFY", "diff": "@@ -50,5 +50,7 @@ the arguments have changed.\n \n a->descr->cast[i](fromdata, fromstep, todata, tostep, n)\n a->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out)\n+ anything but single-stepping is not supported by this function\n+ use the PyArray_CastXXXX functions.\n \n \n", "added_lines": 2, "deleted_lines": 0, "source_code": "\n\nX.flat returns an indexable 1-D iterator (mostly similar to an array but always 1-d)\n\nlong(<>) --> pylong(<>) if from Numeric * was changed to from scipy.base import *\n\n.typecode() --> .dtypechar\n\n.iscontiguous() --> .flags['CONTIGUOUS']\n\n.byteswapped() -> .byteswap()\n\n.itemsize() -> .itemsize\n\nIf you used typecode characters:\n\n'c' -> 'S1'\n'b' -> 'B'\n'1' -> 'b'\n's' -> 'h'\n'w' -> 'H'\n'u' -> 'I'\n\n\nC -level\n\nsome API calls that used to take PyObject * now take PyArrayObject * (this should only cause warnings during compile and not actual problems). \n PyArray_Take \n\nThese commands now return a buffer that must be freed once it is used\nusing PyMemData_FREE(ptr) or PyMemData_XFREE(ptr);\n\na->descr->zero --> PyArray_Zero(a)\na->descr->one --> PyArray_One(a)\n\nNumeric/arrayobject.h --> scipy/arrayobject.h\n\n\n# These will actually work and are defines for PyArray_BYTE, \n# but you really should change it in your code\nPyArray_CHAR --> PyArray_BYTE (or PyArray_STRING which is more flexible) \nPyArray_SBYTE --> PyArray_BYTE\n\nAny uses of character codes will need adjusting....\nuse PyArray_XXXLTR where XXX is the name of the type.\n\n\nIf you used function pointers directly (why did you do that?),\nthe arguments have changed. \n\na->descr->cast[i](fromdata, fromstep, todata, tostep, n)\na->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out)\n anything but single-stepping is not supported by this function\n use the PyArray_CastXXXX functions.\n\n\n", "source_code_before": "\n\nX.flat returns an indexable 1-D iterator (mostly similar to an array but always 1-d)\n\nlong(<>) --> pylong(<>) if from Numeric * was changed to from scipy.base import *\n\n.typecode() --> .dtypechar\n\n.iscontiguous() --> .flags['CONTIGUOUS']\n\n.byteswapped() -> .byteswap()\n\n.itemsize() -> .itemsize\n\nIf you used typecode characters:\n\n'c' -> 'S1'\n'b' -> 'B'\n'1' -> 'b'\n's' -> 'h'\n'w' -> 'H'\n'u' -> 'I'\n\n\nC -level\n\nsome API calls that used to take PyObject * now take PyArrayObject * (this should only cause warnings during compile and not actual problems). \n PyArray_Take \n\nThese commands now return a buffer that must be freed once it is used\nusing PyMemData_FREE(ptr) or PyMemData_XFREE(ptr);\n\na->descr->zero --> PyArray_Zero(a)\na->descr->one --> PyArray_One(a)\n\nNumeric/arrayobject.h --> scipy/arrayobject.h\n\n\n# These will actually work and are defines for PyArray_BYTE, \n# but you really should change it in your code\nPyArray_CHAR --> PyArray_BYTE (or PyArray_STRING which is more flexible) \nPyArray_SBYTE --> PyArray_BYTE\n\nAny uses of character codes will need adjusting....\nuse PyArray_XXXLTR where XXX is the name of the type.\n\n\nIf you used function pointers directly (why did you do that?),\nthe arguments have changed. \n\na->descr->cast[i](fromdata, fromstep, todata, tostep, n)\na->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out)\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ " anything but single-stepping is not supported by this function", " use the PyArray_CastXXXX functions." ], "deleted": [] } } ] }, { "hash": "c2871a8b8b80fc3505195b179baa1472d46e063f", "msg": "Added optimization for array_subscript and eleminated threaded support for a while.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-06T22:15:37+00:00", "author_timezone": 0, "committer_date": "2005-10-06T22:15:37+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "6de1ded3b69fc30f2588ba18daeeaccb8f399c5f" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 3, "insertions": 15, "lines": 18, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy/base/include/scipy/arrayobject.h", "new_path": "scipy/base/include/scipy/arrayobject.h", "filename": "arrayobject.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -881,6 +881,7 @@ typedef struct {\n #define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n #define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n \n+ /* This needs to be check on a threaded system \n #if defined(ALLOW_THREADS)\n #define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS\n #define END_THREADS Py_END_ALLOW_THREADS\n@@ -889,13 +890,15 @@ typedef struct {\n #define ALLOW_C_API __save__ = PyGILState_Ensure();\n #define DISABLE_C_API PyGILState_Release(__save__);\n #else\n+ */\n #define BEGIN_THREADS\n #define END_THREADS\n #define END_THREADS_FAIL\n #define ALLOW_C_API_DEF\n #define\tALLOW_C_API \n #define\tDISABLE_C_API \n-#endif\n+ /*#endif\n+ */\n \n typedef struct {\n PyObject_HEAD\n", "added_lines": 4, "deleted_lines": 1, "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n#define NDARRAY_VERSION 0x0400\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"%I64d\"\n# define ULONGLONG_FMT \"%I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"%lld\" Another possible variant\n #define ULONGLONG_FMT \"%llu\"\n\n\t #define LONGLONG_FMT \"%qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"%qu\"\n\t*/\n# define LONGLONG_FMT \"%Ld\"\n# define ULONGLONG_FMT \"%Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAKEFLOAT(x) x.\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80\n\ttypedef cdouble Complex160\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80\n\ttypedef cfloat Complex160\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80\n\ttypedef clongdouble Complex160\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n /* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and unbyteswapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (char *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, char *, void *);\n\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and byteswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(char *, intp, char *, intp, char *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, int, char *, void *);\n\n\ntypedef struct {\n \tPyTypeObject *typeobj; /* the type object for this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* character representing this type */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type -- \n\t\t\t\t or 0 if variable */\n \tint alignment; /* alignment needed for this type */\n\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n} PyArray_Descr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tint itemsize; /* needed for Flexible size arrays:\n CHAR, UNICODE, and VOID arrays\n \t\t\t */ \n\tPyObject *weakreflist; /* For weakreferences */\n\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\ntypedef struct { /* Just the type_num and itemsize variables \n\t\t for use in the TypeNum Converter function */\n\tint type_num;\n\tint itemsize;\n\tint fortran; /* Set to 1 if fortran-defined strides is desired */\n} PyArray_Typecode;\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n\t/* Not used -- always assumed \n#define OWN_DIMENSIONS 2 \n#define OWN_STRIDES 4 \n\t*/\n\n#define OWNDATA 8\n#define OWN_DATA OWNDATA\n\n#define FORTRAN 0x020 /* set if array is a contiguous Fortran array */\n\t /* first index varies the fastest in memory\n\t\t\t (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n\t/* array never has these two set -- FromAny flags only */\n#define FORCECAST 0x040 \n#define ENSURECOPY 0x080 \t\n\n#define ALIGNED 0x100\n#define NOTSWAPPED 0x200\n#define WRITEABLE 0x400\n\n /* Flag used in creating a new array, not set in the array */\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE MAX_INT32\n#define MAXBUFNUM 1024\n\n\n#define BEHAVED_FLAGS ALIGNED | NOTSWAPPED | WRITEABLE\n#define BEHAVED_FLAGS_RO ALIGNED | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n\n#define PyArray_ISCARRAY(m) PyArray_CHKFLAGS(m, CARRAY_FLAGS)\n#define PyArray_ISFARRAY(m) PyArray_CHKFLAGS(m, FARRAY_FLAGS)\n#define PyArray_ISBEHAVED(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS_RO)\n\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n /* This needs to be check on a threaded system \n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS\n#define END_THREADS Py_END_ALLOW_THREADS\n#define END_THREADS_FAIL Py_UNBLOCK_THREADS\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n */\n#define BEGIN_THREADS\n#define END_THREADS\n#define END_THREADS_FAIL\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n /*#endif\n */\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n unsigned char contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\\\n\tif (it->contiguous) it->dataptr += it->ao->itemsize;\t \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->itemsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n/* Not constructed anywhere. Just serves as a standard type that\n PyArray_Broadcast expects.\n\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n/* Map Iterator API */ \n#define PyArrayMapIter_Check(op) PyObject_TypeCheck(op, &PyArrayMapIter_Type)\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->itemsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type==PyArray_STRING) || \\\n\t\t\t\t (type==PyArray_UNICODE) ||\t\\\n\t\t\t\t (type==PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (((type >= PyArray_STRING) && \\\n\t\t\t\t (type <= PyArray_VOID)) ||\t \\\n\t\t\t\t (type >= PyArray_USERDEF))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHONTYPE(obj) PyTypeNum_ISPYTHONTYPE(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n/* Object arrays ignore notswapped flag */\n#define PyArray_ISNOTSWAPPED(m) (PyArray_CHKFLAGS(m, NOTSWAPPED) || \\\n\t\t\t\t PyArray_ISOBJECT(m))\n\n\n /* Often, rather than always convert to an array, \n we may want to delegate behavior for other objects passed in\n */\n\n\t/* \n\n#define Py_DELEGATE(op, name) \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, NULL);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS(op, name, args)\t\t\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, args);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS_KWDS(op, name, args, kwds)\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_Call(meth, args, kwds);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\t*/\n\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_Check(op) (PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_CheckScalar(m) (PyObject_TypeCheck((m),\t\t\t\\\n\t\t\t\t\t\t &PyGenericArrType_Type) \\\n\t\t\t\t|| ((PyArray_Check((m))) &&\t\t\\\n\t\t\t\t (((PyArrayObject *)(m))->nd == 0)))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj) \\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n\t (PyArrayObject *)(PyArray_ContiguousFromObject((PyObject *)(m), \\\n\t\t PyArray_TYPE(m), 0, 0))) \n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyList\n#define PyArray_ISSPACESAVER(m) TRUE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n#define NDARRAY_VERSION 0x0400\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"%I64d\"\n# define ULONGLONG_FMT \"%I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"%lld\" Another possible variant\n #define ULONGLONG_FMT \"%llu\"\n\n\t #define LONGLONG_FMT \"%qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"%qu\"\n\t*/\n# define LONGLONG_FMT \"%Ld\"\n# define ULONGLONG_FMT \"%Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAKEFLOAT(x) x.\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80\n\ttypedef cdouble Complex160\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80\n\ttypedef cfloat Complex160\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80\n\ttypedef clongdouble Complex160\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n /* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and unbyteswapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (char *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, char *, void *);\n\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and byteswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(char *, intp, char *, intp, char *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, int, char *, void *);\n\n\ntypedef struct {\n \tPyTypeObject *typeobj; /* the type object for this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* character representing this type */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type -- \n\t\t\t\t or 0 if variable */\n \tint alignment; /* alignment needed for this type */\n\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n} PyArray_Descr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tint itemsize; /* needed for Flexible size arrays:\n CHAR, UNICODE, and VOID arrays\n \t\t\t */ \n\tPyObject *weakreflist; /* For weakreferences */\n\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\ntypedef struct { /* Just the type_num and itemsize variables \n\t\t for use in the TypeNum Converter function */\n\tint type_num;\n\tint itemsize;\n\tint fortran; /* Set to 1 if fortran-defined strides is desired */\n} PyArray_Typecode;\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n\t/* Not used -- always assumed \n#define OWN_DIMENSIONS 2 \n#define OWN_STRIDES 4 \n\t*/\n\n#define OWNDATA 8\n#define OWN_DATA OWNDATA\n\n#define FORTRAN 0x020 /* set if array is a contiguous Fortran array */\n\t /* first index varies the fastest in memory\n\t\t\t (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n\t/* array never has these two set -- FromAny flags only */\n#define FORCECAST 0x040 \n#define ENSURECOPY 0x080 \t\n\n#define ALIGNED 0x100\n#define NOTSWAPPED 0x200\n#define WRITEABLE 0x400\n\n /* Flag used in creating a new array, not set in the array */\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE MAX_INT32\n#define MAXBUFNUM 1024\n\n\n#define BEHAVED_FLAGS ALIGNED | NOTSWAPPED | WRITEABLE\n#define BEHAVED_FLAGS_RO ALIGNED | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n\n#define PyArray_ISCARRAY(m) PyArray_CHKFLAGS(m, CARRAY_FLAGS)\n#define PyArray_ISFARRAY(m) PyArray_CHKFLAGS(m, FARRAY_FLAGS)\n#define PyArray_ISBEHAVED(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS_RO)\n\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS\n#define END_THREADS Py_END_ALLOW_THREADS\n#define END_THREADS_FAIL Py_UNBLOCK_THREADS\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS\n#define END_THREADS\n#define END_THREADS_FAIL\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n unsigned char contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\\\n\tif (it->contiguous) it->dataptr += it->ao->itemsize;\t \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->itemsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n/* Not constructed anywhere. Just serves as a standard type that\n PyArray_Broadcast expects.\n\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n/* Map Iterator API */ \n#define PyArrayMapIter_Check(op) PyObject_TypeCheck(op, &PyArrayMapIter_Type)\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->itemsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type==PyArray_STRING) || \\\n\t\t\t\t (type==PyArray_UNICODE) ||\t\\\n\t\t\t\t (type==PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (((type >= PyArray_STRING) && \\\n\t\t\t\t (type <= PyArray_VOID)) ||\t \\\n\t\t\t\t (type >= PyArray_USERDEF))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHONTYPE(obj) PyTypeNum_ISPYTHONTYPE(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n/* Object arrays ignore notswapped flag */\n#define PyArray_ISNOTSWAPPED(m) (PyArray_CHKFLAGS(m, NOTSWAPPED) || \\\n\t\t\t\t PyArray_ISOBJECT(m))\n\n\n /* Often, rather than always convert to an array, \n we may want to delegate behavior for other objects passed in\n */\n\n\t/* \n\n#define Py_DELEGATE(op, name) \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, NULL);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS(op, name, args)\t\t\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, args);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS_KWDS(op, name, args, kwds)\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_Call(meth, args, kwds);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\t*/\n\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_Check(op) (PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_CheckScalar(m) (PyObject_TypeCheck((m),\t\t\t\\\n\t\t\t\t\t\t &PyGenericArrType_Type) \\\n\t\t\t\t|| ((PyArray_Check((m))) &&\t\t\\\n\t\t\t\t (((PyArrayObject *)(m))->nd == 0)))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj) \\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n\t (PyArrayObject *)(PyArray_ContiguousFromObject((PyObject *)(m), \\\n\t\t PyArray_TYPE(m), 0, 0))) \n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyList\n#define PyArray_ISSPACESAVER(m) TRUE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 252, "complexity": 0, "token_count": 1156, "diff_parsed": { "added": [ " /* This needs to be check on a threaded system", " */", " /*#endif", " */" ], "deleted": [ "#endif" ] } }, { "old_path": "scipy/base/src/arrayobject.c", "new_path": "scipy/base/src/arrayobject.c", "filename": "arrayobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -16,7 +16,7 @@ Brigham Young University\n \n maintainer email: oliphant.travis@ieee.org\n \n-Numarray design by \n+Numarray design (which provided guidance) by \n Space Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n \n@@ -36,7 +36,7 @@ Space Science Telescope Institute\n \n #define error_converting(x) (((x) == -1) && PyErr_Occurred())\n \n-static int\n+static intp\n PyArray_PyIntAsIntp(PyObject *o)\n {\n \tlonglong long_value = -1;\n@@ -1669,6 +1669,15 @@ array_subscript(PyArrayObject *self, PyObject *op)\n PyArrayObject *other;\n \tPyArrayMapIterObject *mit;\n \n+ if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n+ PyLong_Check(op)) {\n+ intp value;\n+ value = PyArray_PyIntAsIntp(op);\n+ if (PyErr_Occurred())\n+ PyErr_Clear();\n+ else if ((value <= MAX_INT) || (value >= -MAX_INT))\n+ return array_item(self, (int) value);\n+ }\n \n \tif (PyArrayMapIter_Check(op)) {\n \t\tmit = (PyArrayMapIterObject *)op;\n", "added_lines": 11, "deleted_lines": 2, "source_code": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n if (PyErr_Occurred())\n PyErr_Clear();\n else if ((value <= MAX_INT) || (value >= -MAX_INT))\n return array_item(self, (int) value);\n }\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_BOOL;\n\t\tchksize = sizeof(Bool);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\tchar *msg = \"Cannot copy-back to a read-only array.\";\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "source_code_before": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic int\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_BOOL;\n\t\tchksize = sizeof(Bool);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\tchar *msg = \"Cannot copy-back to a read-only array.\";\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "methods": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1194, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1206, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1240, "end_line": 1270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1274, "end_line": 1282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1288, "end_line": 1338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1345, "end_line": 1390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1394, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1492, "end_line": 1526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1531, "end_line": 1581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1584, "end_line": 1643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 53, "complexity": 16, "token_count": 376, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1744, "end_line": 1796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1804, "end_line": 1807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1826, "end_line": 1838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1841, "end_line": 1856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1860, "end_line": 1869, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1872, "end_line": 1883, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1951, "end_line": 1984, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1990, "end_line": 2029, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2032, "end_line": 2051, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2055, "end_line": 2074, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2078, "end_line": 2089, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2092, "end_line": 2103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2106, "end_line": 2118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2121, "end_line": 2124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2127, "end_line": 2130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2133, "end_line": 2136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2139, "end_line": 2142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2145, "end_line": 2148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2151, "end_line": 2154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2157, "end_line": 2160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2163, "end_line": 2166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2169, "end_line": 2172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2175, "end_line": 2178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2181, "end_line": 2184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2187, "end_line": 2190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2193, "end_line": 2196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2199, "end_line": 2202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2205, "end_line": 2208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2211, "end_line": 2214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2217, "end_line": 2220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2223, "end_line": 2226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2229, "end_line": 2232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2235, "end_line": 2238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2241, "end_line": 2244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2247, "end_line": 2250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2253, "end_line": 2256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2259, "end_line": 2262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2265, "end_line": 2268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2271, "end_line": 2274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2277, "end_line": 2280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2283, "end_line": 2287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2290, "end_line": 2294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2298, "end_line": 2316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2319, "end_line": 2334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2338, "end_line": 2364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2367, "end_line": 2392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2395, "end_line": 2417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2420, "end_line": 2442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2445, "end_line": 2467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2470, "end_line": 2474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2535, "end_line": 2573, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2577, "end_line": 2598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2601, "end_line": 2606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2627, "end_line": 2674, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2677, "end_line": 2713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2719, "end_line": 2736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2739, "end_line": 2751, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2754, "end_line": 2766, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2770, "end_line": 2847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2850, "end_line": 2879, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2885, "end_line": 2901, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2906, "end_line": 2929, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2935, "end_line": 2951, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2955, "end_line": 2971, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2975, "end_line": 2991, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2994, "end_line": 3027, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3031, "end_line": 3053, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3060, "end_line": 3075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3095, "end_line": 3119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3123, "end_line": 3267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3272, "end_line": 3377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3381, "end_line": 3398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3402, "end_line": 3517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3524, "end_line": 3527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3530, "end_line": 3540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3613, "end_line": 3616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3620, "end_line": 3654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3658, "end_line": 3661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3664, "end_line": 3697, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3701, "end_line": 3708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3711, "end_line": 3719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3723, "end_line": 3737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3740, "end_line": 3784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3788, "end_line": 3791, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3794, "end_line": 3801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3805, "end_line": 3812, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3815, "end_line": 3835, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3838, "end_line": 3860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3863, "end_line": 3866, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3870, "end_line": 3873, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3885, "end_line": 3943, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3948, "end_line": 3958, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3962, "end_line": 3987, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3991, "end_line": 4023, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4026, "end_line": 4059, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4062, "end_line": 4099, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4102, "end_line": 4105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4108, "end_line": 4160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4336, "end_line": 4361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4364, "end_line": 4386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4393, "end_line": 4419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4422, "end_line": 4442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 123, "complexity": 28, "token_count": 661, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4445, "end_line": 4583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4586, "end_line": 4609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4613, "end_line": 4636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4640, "end_line": 4697, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4701, "end_line": 4708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4714, "end_line": 4804, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4810, "end_line": 4821, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4824, "end_line": 4859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4866, "end_line": 4912, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4915, "end_line": 5005, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 5009, "end_line": 5114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5117, "end_line": 5211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5214, "end_line": 5235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5239, "end_line": 5301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5304, "end_line": 5309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5312, "end_line": 5318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5372, "end_line": 5402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5412, "end_line": 5428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5434, "end_line": 5439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5442, "end_line": 5448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5451, "end_line": 5457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5463, "end_line": 5534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5537, "end_line": 5561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5571, "end_line": 5608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5613, "end_line": 5623, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5626, "end_line": 5631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5634, "end_line": 5639, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5643, "end_line": 5646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5650, "end_line": 5698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5701, "end_line": 5753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5757, "end_line": 5876, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5880, "end_line": 5912, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5915, "end_line": 5956, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5960, "end_line": 6082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6095, "end_line": 6136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6141, "end_line": 6145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6210, "end_line": 6271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6279, "end_line": 6294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6300, "end_line": 6369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6373, "end_line": 6409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6415, "end_line": 6459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6477, "end_line": 6613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6619, "end_line": 6688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6691, "end_line": 6824, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6830, "end_line": 6860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6866, "end_line": 6877, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6880, "end_line": 6889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6892, "end_line": 6910, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1194, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1206, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1240, "end_line": 1270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1274, "end_line": 1282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1288, "end_line": 1338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1345, "end_line": 1390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1394, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1492, "end_line": 1526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1531, "end_line": 1581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1584, "end_line": 1643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 10, "token_count": 307, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1735, "end_line": 1787, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1795, "end_line": 1798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1817, "end_line": 1829, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1832, "end_line": 1847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1851, "end_line": 1860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1863, "end_line": 1874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1942, "end_line": 1975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1981, "end_line": 2020, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2023, "end_line": 2042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2046, "end_line": 2065, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2069, "end_line": 2080, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2083, "end_line": 2094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2097, "end_line": 2109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2112, "end_line": 2115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2118, "end_line": 2121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2124, "end_line": 2127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2130, "end_line": 2133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2136, "end_line": 2139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2142, "end_line": 2145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2148, "end_line": 2151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2154, "end_line": 2157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2160, "end_line": 2163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2166, "end_line": 2169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2172, "end_line": 2175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2178, "end_line": 2181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2184, "end_line": 2187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2190, "end_line": 2193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2196, "end_line": 2199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2202, "end_line": 2205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2208, "end_line": 2211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2214, "end_line": 2217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2220, "end_line": 2223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2226, "end_line": 2229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2232, "end_line": 2235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2238, "end_line": 2241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2244, "end_line": 2247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2250, "end_line": 2253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2256, "end_line": 2259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2262, "end_line": 2265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2268, "end_line": 2271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2274, "end_line": 2278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2281, "end_line": 2285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2289, "end_line": 2307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2310, "end_line": 2325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2329, "end_line": 2355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2358, "end_line": 2383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2386, "end_line": 2408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2411, "end_line": 2433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2436, "end_line": 2458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2461, "end_line": 2465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2526, "end_line": 2564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2568, "end_line": 2589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2592, "end_line": 2597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2618, "end_line": 2665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2668, "end_line": 2704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2710, "end_line": 2727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2730, "end_line": 2742, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2745, "end_line": 2757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2761, "end_line": 2838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2841, "end_line": 2870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2876, "end_line": 2892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2897, "end_line": 2920, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2926, "end_line": 2942, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2946, "end_line": 2962, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2966, "end_line": 2982, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2985, "end_line": 3018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3022, "end_line": 3044, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3051, "end_line": 3066, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3086, "end_line": 3110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3114, "end_line": 3258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3263, "end_line": 3368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3372, "end_line": 3389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3393, "end_line": 3508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3515, "end_line": 3518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3521, "end_line": 3531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3604, "end_line": 3607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3611, "end_line": 3645, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3649, "end_line": 3652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3655, "end_line": 3688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3692, "end_line": 3699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3702, "end_line": 3710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3714, "end_line": 3728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3731, "end_line": 3775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3779, "end_line": 3782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3785, "end_line": 3792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3796, "end_line": 3803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3806, "end_line": 3826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3829, "end_line": 3851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3854, "end_line": 3857, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3861, "end_line": 3864, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3876, "end_line": 3934, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3939, "end_line": 3949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3953, "end_line": 3978, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3982, "end_line": 4014, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4017, "end_line": 4050, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4053, "end_line": 4090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4093, "end_line": 4096, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4099, "end_line": 4151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4327, "end_line": 4352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4355, "end_line": 4377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4384, "end_line": 4410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4413, "end_line": 4433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 123, "complexity": 28, "token_count": 661, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4436, "end_line": 4574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4577, "end_line": 4600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4604, "end_line": 4627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4631, "end_line": 4688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4692, "end_line": 4699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4705, "end_line": 4795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4801, "end_line": 4812, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4815, "end_line": 4850, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4857, "end_line": 4903, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4906, "end_line": 4996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 5000, "end_line": 5105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5108, "end_line": 5202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5205, "end_line": 5226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5230, "end_line": 5292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5295, "end_line": 5300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5303, "end_line": 5309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5363, "end_line": 5393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5403, "end_line": 5419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5425, "end_line": 5430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5433, "end_line": 5439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5442, "end_line": 5448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5454, "end_line": 5525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5528, "end_line": 5552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5562, "end_line": 5599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5604, "end_line": 5614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5617, "end_line": 5622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5625, "end_line": 5630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5634, "end_line": 5637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5641, "end_line": 5689, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5692, "end_line": 5744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5748, "end_line": 5867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5871, "end_line": 5903, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5906, "end_line": 5947, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5951, "end_line": 6073, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6086, "end_line": 6127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6132, "end_line": 6136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6201, "end_line": 6262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6270, "end_line": 6285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6291, "end_line": 6360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6364, "end_line": 6400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6406, "end_line": 6450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6468, "end_line": 6604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6610, "end_line": 6679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6682, "end_line": 6815, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6821, "end_line": 6851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6857, "end_line": 6868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6871, "end_line": 6880, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6883, "end_line": 6901, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 53, "complexity": 16, "token_count": 376, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 0 } ], "nloc": 5466, "complexity": 1201, "token_count": 32661, "diff_parsed": { "added": [ "Numarray design (which provided guidance) by", "static intp", " if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\", " PyLong_Check(op)) {", " intp value;", " value = PyArray_PyIntAsIntp(op);", " if (PyErr_Occurred())", " PyErr_Clear();", " else if ((value <= MAX_INT) || (value >= -MAX_INT))", " return array_item(self, (int) value);", " }" ], "deleted": [ "Numarray design by", "static int" ] } } ] }, { "hash": "d52d900dc6551e59cd679365723ff8e1dd7dfd9e", "msg": "Fixed issues with threading...", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-07T00:06:47+00:00", "author_timezone": 0, "committer_date": "2005-10-07T00:06:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c2871a8b8b80fc3505195b179baa1472d46e063f" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 30, "insertions": 61, "lines": 91, "files": 4, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.42105263157894735, "modified_files": [ { "old_path": "scipy/base/include/scipy/arrayobject.h", "new_path": "scipy/base/include/scipy/arrayobject.h", "filename": "arrayobject.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -881,24 +881,21 @@ typedef struct {\n #define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n #define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n \n- /* This needs to be check on a threaded system \n #if defined(ALLOW_THREADS)\n-#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS\n-#define END_THREADS Py_END_ALLOW_THREADS\n-#define END_THREADS_FAIL Py_UNBLOCK_THREADS\n+#define BEGIN_THREADS_DEF PyThreadState *_save;\n+#define BEGIN_THREADS _save = PyEval_SaveThread();\n+#define END_THREADS PyEval_RestoreThread(_save);\n #define ALLOW_C_API_DEF PyGILState_STATE __save__;\n #define ALLOW_C_API __save__ = PyGILState_Ensure();\n #define DISABLE_C_API PyGILState_Release(__save__);\n #else\n- */\n+#define BEGIN_THREADS_DEF\n #define BEGIN_THREADS\n #define END_THREADS\n-#define END_THREADS_FAIL\n #define ALLOW_C_API_DEF\n #define\tALLOW_C_API \n #define\tDISABLE_C_API \n- /*#endif\n- */\n+#endif\n \n typedef struct {\n PyObject_HEAD\n", "added_lines": 5, "deleted_lines": 8, "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n#define NDARRAY_VERSION 0x0400\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"%I64d\"\n# define ULONGLONG_FMT \"%I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"%lld\" Another possible variant\n #define ULONGLONG_FMT \"%llu\"\n\n\t #define LONGLONG_FMT \"%qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"%qu\"\n\t*/\n# define LONGLONG_FMT \"%Ld\"\n# define ULONGLONG_FMT \"%Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAKEFLOAT(x) x.\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80\n\ttypedef cdouble Complex160\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80\n\ttypedef cfloat Complex160\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80\n\ttypedef clongdouble Complex160\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n /* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and unbyteswapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (char *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, char *, void *);\n\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and byteswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(char *, intp, char *, intp, char *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, int, char *, void *);\n\n\ntypedef struct {\n \tPyTypeObject *typeobj; /* the type object for this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* character representing this type */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type -- \n\t\t\t\t or 0 if variable */\n \tint alignment; /* alignment needed for this type */\n\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n} PyArray_Descr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tint itemsize; /* needed for Flexible size arrays:\n CHAR, UNICODE, and VOID arrays\n \t\t\t */ \n\tPyObject *weakreflist; /* For weakreferences */\n\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\ntypedef struct { /* Just the type_num and itemsize variables \n\t\t for use in the TypeNum Converter function */\n\tint type_num;\n\tint itemsize;\n\tint fortran; /* Set to 1 if fortran-defined strides is desired */\n} PyArray_Typecode;\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n\t/* Not used -- always assumed \n#define OWN_DIMENSIONS 2 \n#define OWN_STRIDES 4 \n\t*/\n\n#define OWNDATA 8\n#define OWN_DATA OWNDATA\n\n#define FORTRAN 0x020 /* set if array is a contiguous Fortran array */\n\t /* first index varies the fastest in memory\n\t\t\t (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n\t/* array never has these two set -- FromAny flags only */\n#define FORCECAST 0x040 \n#define ENSURECOPY 0x080 \t\n\n#define ALIGNED 0x100\n#define NOTSWAPPED 0x200\n#define WRITEABLE 0x400\n\n /* Flag used in creating a new array, not set in the array */\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE MAX_INT32\n#define MAXBUFNUM 1024\n\n\n#define BEHAVED_FLAGS ALIGNED | NOTSWAPPED | WRITEABLE\n#define BEHAVED_FLAGS_RO ALIGNED | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n\n#define PyArray_ISCARRAY(m) PyArray_CHKFLAGS(m, CARRAY_FLAGS)\n#define PyArray_ISFARRAY(m) PyArray_CHKFLAGS(m, FARRAY_FLAGS)\n#define PyArray_ISBEHAVED(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS_RO)\n\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n unsigned char contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\\\n\tif (it->contiguous) it->dataptr += it->ao->itemsize;\t \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->itemsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n/* Not constructed anywhere. Just serves as a standard type that\n PyArray_Broadcast expects.\n\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n/* Map Iterator API */ \n#define PyArrayMapIter_Check(op) PyObject_TypeCheck(op, &PyArrayMapIter_Type)\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->itemsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type==PyArray_STRING) || \\\n\t\t\t\t (type==PyArray_UNICODE) ||\t\\\n\t\t\t\t (type==PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (((type >= PyArray_STRING) && \\\n\t\t\t\t (type <= PyArray_VOID)) ||\t \\\n\t\t\t\t (type >= PyArray_USERDEF))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHONTYPE(obj) PyTypeNum_ISPYTHONTYPE(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n/* Object arrays ignore notswapped flag */\n#define PyArray_ISNOTSWAPPED(m) (PyArray_CHKFLAGS(m, NOTSWAPPED) || \\\n\t\t\t\t PyArray_ISOBJECT(m))\n\n\n /* Often, rather than always convert to an array, \n we may want to delegate behavior for other objects passed in\n */\n\n\t/* \n\n#define Py_DELEGATE(op, name) \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, NULL);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS(op, name, args)\t\t\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, args);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS_KWDS(op, name, args, kwds)\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_Call(meth, args, kwds);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\t*/\n\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_Check(op) (PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_CheckScalar(m) (PyObject_TypeCheck((m),\t\t\t\\\n\t\t\t\t\t\t &PyGenericArrType_Type) \\\n\t\t\t\t|| ((PyArray_Check((m))) &&\t\t\\\n\t\t\t\t (((PyArrayObject *)(m))->nd == 0)))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj) \\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n\t (PyArrayObject *)(PyArray_ContiguousFromObject((PyObject *)(m), \\\n\t\t PyArray_TYPE(m), 0, 0))) \n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyList\n#define PyArray_ISSPACESAVER(m) TRUE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n#define NDARRAY_VERSION 0x0400\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"%I64d\"\n# define ULONGLONG_FMT \"%I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"%lld\" Another possible variant\n #define ULONGLONG_FMT \"%llu\"\n\n\t #define LONGLONG_FMT \"%qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"%qu\"\n\t*/\n# define LONGLONG_FMT \"%Ld\"\n# define ULONGLONG_FMT \"%Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAKEFLOAT(x) x.\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80\n\ttypedef cdouble Complex160\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80\n\ttypedef cfloat Complex160\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80\n\ttypedef clongdouble Complex160\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n /* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and unbyteswapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (char *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, char *, void *);\n\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and byteswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(char *, intp, char *, intp, char *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, int, char *, void *);\n\n\ntypedef struct {\n \tPyTypeObject *typeobj; /* the type object for this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* character representing this type */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type -- \n\t\t\t\t or 0 if variable */\n \tint alignment; /* alignment needed for this type */\n\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n} PyArray_Descr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tint itemsize; /* needed for Flexible size arrays:\n CHAR, UNICODE, and VOID arrays\n \t\t\t */ \n\tPyObject *weakreflist; /* For weakreferences */\n\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\ntypedef struct { /* Just the type_num and itemsize variables \n\t\t for use in the TypeNum Converter function */\n\tint type_num;\n\tint itemsize;\n\tint fortran; /* Set to 1 if fortran-defined strides is desired */\n} PyArray_Typecode;\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n\t/* Not used -- always assumed \n#define OWN_DIMENSIONS 2 \n#define OWN_STRIDES 4 \n\t*/\n\n#define OWNDATA 8\n#define OWN_DATA OWNDATA\n\n#define FORTRAN 0x020 /* set if array is a contiguous Fortran array */\n\t /* first index varies the fastest in memory\n\t\t\t (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n\t/* array never has these two set -- FromAny flags only */\n#define FORCECAST 0x040 \n#define ENSURECOPY 0x080 \t\n\n#define ALIGNED 0x100\n#define NOTSWAPPED 0x200\n#define WRITEABLE 0x400\n\n /* Flag used in creating a new array, not set in the array */\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE MAX_INT32\n#define MAXBUFNUM 1024\n\n\n#define BEHAVED_FLAGS ALIGNED | NOTSWAPPED | WRITEABLE\n#define BEHAVED_FLAGS_RO ALIGNED | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n\n#define PyArray_ISCARRAY(m) PyArray_CHKFLAGS(m, CARRAY_FLAGS)\n#define PyArray_ISFARRAY(m) PyArray_CHKFLAGS(m, FARRAY_FLAGS)\n#define PyArray_ISBEHAVED(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_CHKFLAGS(m, BEHAVED_FLAGS_RO)\n\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n /* This needs to be check on a threaded system \n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS\n#define END_THREADS Py_END_ALLOW_THREADS\n#define END_THREADS_FAIL Py_UNBLOCK_THREADS\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n */\n#define BEGIN_THREADS\n#define END_THREADS\n#define END_THREADS_FAIL\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n /*#endif\n */\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n unsigned char contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\\\n\tif (it->contiguous) it->dataptr += it->ao->itemsize;\t \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->itemsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n/* Not constructed anywhere. Just serves as a standard type that\n PyArray_Broadcast expects.\n\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n/* Map Iterator API */ \n#define PyArrayMapIter_Check(op) PyObject_TypeCheck(op, &PyArrayMapIter_Type)\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->itemsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type==PyArray_STRING) || \\\n\t\t\t\t (type==PyArray_UNICODE) ||\t\\\n\t\t\t\t (type==PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (((type >= PyArray_STRING) && \\\n\t\t\t\t (type <= PyArray_VOID)) ||\t \\\n\t\t\t\t (type >= PyArray_USERDEF))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHONTYPE(obj) PyTypeNum_ISPYTHONTYPE(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n/* Object arrays ignore notswapped flag */\n#define PyArray_ISNOTSWAPPED(m) (PyArray_CHKFLAGS(m, NOTSWAPPED) || \\\n\t\t\t\t PyArray_ISOBJECT(m))\n\n\n /* Often, rather than always convert to an array, \n we may want to delegate behavior for other objects passed in\n */\n\n\t/* \n\n#define Py_DELEGATE(op, name) \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, NULL);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS(op, name, args)\t\t\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_CallObject(meth, args);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\n#define Py_DELEGATE_ARGS_KWDS(op, name, args, kwds)\t \\\n\tif (PyObject_HasAttrString(op, #name)) { \\\n\t\tPyObject *ret=NULL;\t\t\t\t \\\n\t\tPyObject *meth=PyObject_GetAttrString(op, #name); \\\n\t\tif (PyCallable_Check(meth)) {\t\t\t \\\n\t\t\tret = PyObject_Call(meth, args, kwds);\t \\\n\t\t}\t\t\t\t\t\t \\\n Py_XDECREF(args); \\\n\t\tPy_XDECREF(meth);\t\t\t\t \\\n\t\treturn ret;\t\t\t\t\t \\\n\t}\n\t*/\n\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_Check(op) (PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_CheckScalar(m) (PyObject_TypeCheck((m),\t\t\t\\\n\t\t\t\t\t\t &PyGenericArrType_Type) \\\n\t\t\t\t|| ((PyArray_Check((m))) &&\t\t\\\n\t\t\t\t (((PyArrayObject *)(m))->nd == 0)))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj) \\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n\t (PyArrayObject *)(PyArray_ContiguousFromObject((PyObject *)(m), \\\n\t\t PyArray_TYPE(m), 0, 0))) \n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyList\n#define PyArray_ISSPACESAVER(m) TRUE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 252, "complexity": 0, "token_count": 1156, "diff_parsed": { "added": [ "#define BEGIN_THREADS_DEF PyThreadState *_save;", "#define BEGIN_THREADS _save = PyEval_SaveThread();", "#define END_THREADS PyEval_RestoreThread(_save);", "#define BEGIN_THREADS_DEF", "#endif" ], "deleted": [ " /* This needs to be check on a threaded system", "#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS", "#define END_THREADS Py_END_ALLOW_THREADS", "#define END_THREADS_FAIL Py_UNBLOCK_THREADS", " */", "#define END_THREADS_FAIL", " /*#endif", " */" ] } }, { "old_path": "scipy/base/include/scipy/ufuncobject.h", "new_path": "scipy/base/include/scipy/ufuncobject.h", "filename": "ufuncobject.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -105,6 +105,7 @@ typedef struct {\n \t*/\n \tintp steps[MAX_ARGS];\n \n+ int obj; /* This loop calls object functions */\n \t\n } PyUFuncLoopObject;\n \n@@ -150,8 +151,19 @@ typedef struct {\n \t/* For copying small arrays */\n \tPyObject *decref;\n \n+ int obj;\n+ \n } PyUFuncReduceObject;\n \n+\n+#if defined(ALLOW_THREADS)\n+#define LOOP_BEGIN_THREADS if (!(loop->obj)) _save = PyEval_SaveThread();\n+#define LOOP_END_THREADS if (!(loop->obj)) PyEval_RestoreThread(_save);\n+#else\n+#define LOOP_BEGIN_THREADS \n+#define LOOP_END_THREADS \n+#endif\n+\n #define PyUFunc_Unbounded 120\n #define PyUFunc_One 1\n #define PyUFunc_Zero 0\n@@ -165,8 +177,6 @@ typedef struct {\n } PyUFunc_PyFuncData;\n \n \n-\n-\n #include \"__ufunc_api.h\"\n \n #define UFUNC_ERRMASK_NAME \"_UFUNC_ERRMASK\"\n@@ -174,9 +184,10 @@ typedef struct {\n #define UFUNC_BUFSIZE_NAME \"_UFUNC_BUFSIZE\"\n \n #define UFUNC_CHECK_ERROR() \\\n-\tif (PyErr_Occurred() || (loop->errormask &&\t\t\t\\\n-\t PyUFunc_checkfperr(loop->errormask,\t\t\t\t\\\n-\t\t\t loop->errobj)))\t\t\t\t\\\n+\tif ((loop->obj && PyErr_Occurred()) || \\\n+ (loop->errormask && \\\n+ PyUFunc_checkfperr(loop->errormask, \\\n+ loop->errobj)))\t\t\t\t\\\n \t\tgoto fail\n \n /* This code checks the IEEE status flags in a platform-dependent way */\n", "added_lines": 16, "deleted_lines": 5, "source_code": "#ifndef Py_UFUNCOBJECT_H\n#define Py_UFUNCOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define MAX_ARGS 40\n\ntypedef void (*PyUFuncGenericFunction) (char **, intp *, intp *, void *);\n\ntypedef struct {\n\tPyObject_HEAD\n\tint nin, nout, nargs;\n\tint identity;\n\tPyUFuncGenericFunction *functions;\n\tvoid **data;\n\tint ntypes;\n\tint check_return;\n\tchar *name, *types;\n\tchar *doc;\n void *ptr;\n PyObject *obj;\n\tPyObject *userloops;\n} PyUFuncObject;\n\n#include \"arrayobject.h\"\n\n#define UFUNC_ERR_IGNORE 0\n#define UFUNC_ERR_WARN 1\n#define UFUNC_ERR_RAISE 2\n#define UFUNC_ERR_CALL 3\n\n\t/* Python side integer mask */\n\n#define UFUNC_MASK_DIVIDEBYZERO 0x03\n#define UFUNC_MASK_OVERFLOW 0x0c\n#define UFUNC_MASK_UNDERFLOW 0x30\n#define UFUNC_MASK_INVALID 0xc0\n\n#define UFUNC_SHIFT_DIVIDEBYZERO 0\n#define UFUNC_SHIFT_OVERFLOW 2\n#define UFUNC_SHIFT_UNDERFLOW 4\n#define UFUNC_SHIFT_INVALID 6 \n\n\n/* platform-dependent code translates floating point\n status to an integer sum of these values\n*/\n#define UFUNC_FPE_DIVIDEBYZERO 1\n#define UFUNC_FPE_OVERFLOW 2\n#define UFUNC_FPE_UNDERFLOW 4\n#define UFUNC_FPE_INVALID 8\n\t\n#define UFUNC_ERR_DEFAULT 0 /* Default error mode */\n\n\t/* Only internal -- not exported, yet*/\ntypedef struct {\n\t/* Multi-iterator portion --- needs to be present in this order \n\t to work with PyArray_Broadcast */\n\tPyObject_HEAD\n\tint numiter;\n\tintp size; \n\tintp index; \n\tint nd;\n\tintp dimensions[MAX_DIMS];\t\n\tPyArrayIterObject *iters[MAX_ARGS];\n /* End of Multi-iterator portion */\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\t\n\t/* The error handling */\n\tint errormask; /* Integer showing desired error handling */\n\tPyObject *errobj; /* currently a tuple with \n\t\t\t\t (string, func or None)\n\t\t\t */\n\n\t/* Specific function and data to use */\n\tPyUFuncGenericFunction function;\n\tvoid *funcdata;\n\n\t/* Loop method */\n\tint meth;\n\t\n\t/* Whether or not to swap */\n\tint swap[MAX_ARGS];\n\n\t/* Buffers for the loop */\n\tvoid *buffer[MAX_ARGS];\n\tint bufsize;\n\tint bufcnt;\n\tvoid *dptr[MAX_ARGS];\n\n\t/* For casting */\n\tvoid *castbuf[MAX_ARGS];\n\tPyArray_VectorUnaryFunc *cast[MAX_ARGS];\n\n\t/* usually points to buffer but when a cast is to be\n\t done it switches for that argument to castbuf.\n\t*/\n\tvoid *bufptr[MAX_ARGS]; \n\n\t/* Steps filled in from iters or sizeof(item)\n\t depending on loop method. \n\t*/\n\tintp steps[MAX_ARGS];\n\n int obj; /* This loop calls object functions */\n\t\n} PyUFuncLoopObject;\n\n/* Could make this more clever someday */\n#define UFUNC_MAXIDENTITY 32\n\ntypedef struct {\n PyObject_HEAD\n PyArrayIterObject *it;\n PyArrayObject *ret;\n\tPyArrayIterObject *rit; /* Needed for Accumulate */\n int outsize;\n\tintp index;\n\tintp size;\n char idptr[UFUNC_MAXIDENTITY];\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\n\t/* The error handling */\n\tint errormask;\n\tPyObject *errobj;\n \n PyUFuncGenericFunction function;\n void *funcdata; \n int meth;\n int swap;\n \n void *buffer;\n int bufsize;\n\n void *castbuf;\n PyArray_VectorUnaryFunc *cast;\n\n void *bufptr[3];\n intp steps[3];\n\n intp N;\n int instrides;\n int insize;\n char *inptr;\n\n\t/* For copying small arrays */\n\tPyObject *decref;\n \n int obj;\n \n} PyUFuncReduceObject;\n\n\n#if defined(ALLOW_THREADS)\n#define LOOP_BEGIN_THREADS if (!(loop->obj)) _save = PyEval_SaveThread();\n#define LOOP_END_THREADS if (!(loop->obj)) PyEval_RestoreThread(_save);\n#else\n#define LOOP_BEGIN_THREADS \n#define LOOP_END_THREADS \n#endif\n\n#define PyUFunc_Unbounded 120\n#define PyUFunc_One 1\n#define PyUFunc_Zero 0\n#define PyUFunc_None -1\n\n\ntypedef struct {\n int nin;\n int nout;\n PyObject *callable; \n} PyUFunc_PyFuncData;\n\n\n#include \"__ufunc_api.h\"\n\n#define UFUNC_ERRMASK_NAME \"_UFUNC_ERRMASK\"\n#define UFUNC_ERRFUNC_NAME \"_UFUNC_ERRFUNC\"\n#define UFUNC_BUFSIZE_NAME \"_UFUNC_BUFSIZE\"\n\n#define UFUNC_CHECK_ERROR() \\\n\tif ((loop->obj && PyErr_Occurred()) || \\\n (loop->errormask && \\\n PyUFunc_checkfperr(loop->errormask, \\\n loop->errobj)))\t\t\t\t\\\n\t\tgoto fail\n\n/* This code checks the IEEE status flags in a platform-dependent way */\n/* Adapted from Numarray */\n\n/* OSF/Alpha (Tru64) ---------------------------------------------*/\n#if defined(__osf__) && defined(__alpha)\n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\\\n\tunsigned long fpstatus;\t\t \\\n\t\t\t\t\t\t\\\n\tfpstatus = ieee_get_fp_control();\t\t\t\t\\\n\t/* clear status bits as well as disable exception mode if on */ \\\n\tieee_set_fp_control( 0 );\t\t\t\t\t\\\n\tret = ((IEEE_STATUS_DZE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((IEEE_STATUS_OVF & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_UNF & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \\\n\t}\n\t\n/* MS Windows -----------------------------------------------------*/\n#elif defined(_MSC_VER) \n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t \\\n\tint fpstatus = (int) _clear87();\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\tret = ((SW_ZERODIVIDE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((SW_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((SW_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((SW_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t}\n\t\n\n/* Solaris --------------------------------------------------------*/\n/* --------ignoring SunOS ieee_flags approach, someone else can\n** deal with that! */\n#elif defined(sun)\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\t\t\\\n\tint fpstatus;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n\tfpstatus = (int) fpgetsticky();\t\t\t\t\t\\\n\tret = ((FP_X_DZ & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((FP_X_OFL & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_X_UFL & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((FP_X_INV & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) fpsetsticky(0);\t\t\t\t\t\t\\\n\t}\n\t\n#elif defined(linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) \n\n#if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__)\n#include \n#elif defined(__CYGWIN__)\n#include \n#endif\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tint fpstatus = (int) fetestexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\\\n\t\t\t\t\t FE_UNDERFLOW | FE_INVALID);\t\\\n\tret = ((FE_DIVBYZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FE_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FE_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FE_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) feclearexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\t\\\n\t\t\t FE_UNDERFLOW | FE_INVALID);\t\t\\\n}\n\n#define generate_divbyzero_error() feraiseexcept(FE_DIVBYZERO)\n#define generate_overflow_error() feraiseexcept(FE_OVERFLOW)\n\t\n#elif defined(AIX)\n\n#include \n#include \n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tfpflag_t fpstatus; \\\n \\\n\tfpstatus = fp_read_flag();\n\tret = ((FP_DIV_BY_ZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FP_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FP_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\n\tfp_clr_flag( FP_DIV_BY_ZERO | FP_OVERFLOW | FP_UNDERFLOW | FP_INVALID); \\\n}\n\n#else\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n printf(\"floating point flags not supported on this platform\\n\"); \\\n ret = 0;\t\t\t\t\t\t\t \\\n }\n\n#endif\n\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* !Py_UFUNCOBJECT_H */\n", "source_code_before": "#ifndef Py_UFUNCOBJECT_H\n#define Py_UFUNCOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define MAX_ARGS 40\n\ntypedef void (*PyUFuncGenericFunction) (char **, intp *, intp *, void *);\n\ntypedef struct {\n\tPyObject_HEAD\n\tint nin, nout, nargs;\n\tint identity;\n\tPyUFuncGenericFunction *functions;\n\tvoid **data;\n\tint ntypes;\n\tint check_return;\n\tchar *name, *types;\n\tchar *doc;\n void *ptr;\n PyObject *obj;\n\tPyObject *userloops;\n} PyUFuncObject;\n\n#include \"arrayobject.h\"\n\n#define UFUNC_ERR_IGNORE 0\n#define UFUNC_ERR_WARN 1\n#define UFUNC_ERR_RAISE 2\n#define UFUNC_ERR_CALL 3\n\n\t/* Python side integer mask */\n\n#define UFUNC_MASK_DIVIDEBYZERO 0x03\n#define UFUNC_MASK_OVERFLOW 0x0c\n#define UFUNC_MASK_UNDERFLOW 0x30\n#define UFUNC_MASK_INVALID 0xc0\n\n#define UFUNC_SHIFT_DIVIDEBYZERO 0\n#define UFUNC_SHIFT_OVERFLOW 2\n#define UFUNC_SHIFT_UNDERFLOW 4\n#define UFUNC_SHIFT_INVALID 6 \n\n\n/* platform-dependent code translates floating point\n status to an integer sum of these values\n*/\n#define UFUNC_FPE_DIVIDEBYZERO 1\n#define UFUNC_FPE_OVERFLOW 2\n#define UFUNC_FPE_UNDERFLOW 4\n#define UFUNC_FPE_INVALID 8\n\t\n#define UFUNC_ERR_DEFAULT 0 /* Default error mode */\n\n\t/* Only internal -- not exported, yet*/\ntypedef struct {\n\t/* Multi-iterator portion --- needs to be present in this order \n\t to work with PyArray_Broadcast */\n\tPyObject_HEAD\n\tint numiter;\n\tintp size; \n\tintp index; \n\tint nd;\n\tintp dimensions[MAX_DIMS];\t\n\tPyArrayIterObject *iters[MAX_ARGS];\n /* End of Multi-iterator portion */\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\t\n\t/* The error handling */\n\tint errormask; /* Integer showing desired error handling */\n\tPyObject *errobj; /* currently a tuple with \n\t\t\t\t (string, func or None)\n\t\t\t */\n\n\t/* Specific function and data to use */\n\tPyUFuncGenericFunction function;\n\tvoid *funcdata;\n\n\t/* Loop method */\n\tint meth;\n\t\n\t/* Whether or not to swap */\n\tint swap[MAX_ARGS];\n\n\t/* Buffers for the loop */\n\tvoid *buffer[MAX_ARGS];\n\tint bufsize;\n\tint bufcnt;\n\tvoid *dptr[MAX_ARGS];\n\n\t/* For casting */\n\tvoid *castbuf[MAX_ARGS];\n\tPyArray_VectorUnaryFunc *cast[MAX_ARGS];\n\n\t/* usually points to buffer but when a cast is to be\n\t done it switches for that argument to castbuf.\n\t*/\n\tvoid *bufptr[MAX_ARGS]; \n\n\t/* Steps filled in from iters or sizeof(item)\n\t depending on loop method. \n\t*/\n\tintp steps[MAX_ARGS];\n\n\t\n} PyUFuncLoopObject;\n\n/* Could make this more clever someday */\n#define UFUNC_MAXIDENTITY 32\n\ntypedef struct {\n PyObject_HEAD\n PyArrayIterObject *it;\n PyArrayObject *ret;\n\tPyArrayIterObject *rit; /* Needed for Accumulate */\n int outsize;\n\tintp index;\n\tintp size;\n char idptr[UFUNC_MAXIDENTITY];\n\n\t/* The ufunc */\n\tPyUFuncObject *ufunc;\n\n\t/* The error handling */\n\tint errormask;\n\tPyObject *errobj;\n \n PyUFuncGenericFunction function;\n void *funcdata; \n int meth;\n int swap;\n \n void *buffer;\n int bufsize;\n\n void *castbuf;\n PyArray_VectorUnaryFunc *cast;\n\n void *bufptr[3];\n intp steps[3];\n\n intp N;\n int instrides;\n int insize;\n char *inptr;\n\n\t/* For copying small arrays */\n\tPyObject *decref;\n \n} PyUFuncReduceObject;\n\n#define PyUFunc_Unbounded 120\n#define PyUFunc_One 1\n#define PyUFunc_Zero 0\n#define PyUFunc_None -1\n\n\ntypedef struct {\n int nin;\n int nout;\n PyObject *callable; \n} PyUFunc_PyFuncData;\n\n\n\n\n#include \"__ufunc_api.h\"\n\n#define UFUNC_ERRMASK_NAME \"_UFUNC_ERRMASK\"\n#define UFUNC_ERRFUNC_NAME \"_UFUNC_ERRFUNC\"\n#define UFUNC_BUFSIZE_NAME \"_UFUNC_BUFSIZE\"\n\n#define UFUNC_CHECK_ERROR() \\\n\tif (PyErr_Occurred() || (loop->errormask &&\t\t\t\\\n\t PyUFunc_checkfperr(loop->errormask,\t\t\t\t\\\n\t\t\t loop->errobj)))\t\t\t\t\\\n\t\tgoto fail\n\n/* This code checks the IEEE status flags in a platform-dependent way */\n/* Adapted from Numarray */\n\n/* OSF/Alpha (Tru64) ---------------------------------------------*/\n#if defined(__osf__) && defined(__alpha)\n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\\\n\tunsigned long fpstatus;\t\t \\\n\t\t\t\t\t\t\\\n\tfpstatus = ieee_get_fp_control();\t\t\t\t\\\n\t/* clear status bits as well as disable exception mode if on */ \\\n\tieee_set_fp_control( 0 );\t\t\t\t\t\\\n\tret = ((IEEE_STATUS_DZE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((IEEE_STATUS_OVF & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_UNF & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((IEEE_STATUS_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \\\n\t}\n\t\n/* MS Windows -----------------------------------------------------*/\n#elif defined(_MSC_VER) \n\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t \\\n\tint fpstatus = (int) _clear87();\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\tret = ((SW_ZERODIVIDE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((SW_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((SW_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((SW_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t}\n\t\n\n/* Solaris --------------------------------------------------------*/\n/* --------ignoring SunOS ieee_flags approach, someone else can\n** deal with that! */\n#elif defined(sun)\n#include \n\n#define UFUNC_CHECK_STATUS(ret) {\t\t\t\t\\\n\tint fpstatus;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n\tfpstatus = (int) fpgetsticky();\t\t\t\t\t\\\n\tret = ((FP_X_DZ & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0)\t\\\n\t\t| ((FP_X_OFL & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_X_UFL & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0)\t\\\n\t\t| ((FP_X_INV & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) fpsetsticky(0);\t\t\t\t\t\t\\\n\t}\n\t\n#elif defined(linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) \n\n#if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__)\n#include \n#elif defined(__CYGWIN__)\n#include \n#endif\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tint fpstatus = (int) fetestexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\\\n\t\t\t\t\t FE_UNDERFLOW | FE_INVALID);\t\\\n\tret = ((FE_DIVBYZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FE_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FE_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FE_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\t\\\n\t(void) feclearexcept(FE_DIVBYZERO | FE_OVERFLOW |\t\t\\\n\t\t\t FE_UNDERFLOW | FE_INVALID);\t\t\\\n}\n\n#define generate_divbyzero_error() feraiseexcept(FE_DIVBYZERO)\n#define generate_overflow_error() feraiseexcept(FE_OVERFLOW)\n\t\n#elif defined(AIX)\n\n#include \n#include \n\n#define UFUNC_CHECK_STATUS(ret) { \\\n\tfpflag_t fpstatus; \\\n \\\n\tfpstatus = fp_read_flag();\n\tret = ((FP_DIV_BY_ZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \\\n\t\t| ((FP_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0)\t\\\n\t\t| ((FP_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \\\n\t\t| ((FP_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0);\n\tfp_clr_flag( FP_DIV_BY_ZERO | FP_OVERFLOW | FP_UNDERFLOW | FP_INVALID); \\\n}\n\n#else\n\n#define UFUNC_CHECK_STATUS(ret) { \\\n printf(\"floating point flags not supported on this platform\\n\"); \\\n ret = 0;\t\t\t\t\t\t\t \\\n }\n\n#endif\n\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* !Py_UFUNCOBJECT_H */\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 91, "complexity": 0, "token_count": 393, "diff_parsed": { "added": [ " int obj; /* This loop calls object functions */", " int obj;", "", "", "#if defined(ALLOW_THREADS)", "#define LOOP_BEGIN_THREADS if (!(loop->obj)) _save = PyEval_SaveThread();", "#define LOOP_END_THREADS if (!(loop->obj)) PyEval_RestoreThread(_save);", "#else", "#define LOOP_BEGIN_THREADS", "#define LOOP_END_THREADS", "#endif", "", "\tif ((loop->obj && PyErr_Occurred()) || \\", " (loop->errormask && \\", " PyUFunc_checkfperr(loop->errormask, \\", " loop->errobj)))\t\t\t\t\\" ], "deleted": [ "", "", "\tif (PyErr_Occurred() || (loop->errormask &&\t\t\t\\", "\t PyUFunc_checkfperr(loop->errormask,\t\t\t\t\\", "\t\t\t loop->errobj)))\t\t\t\t\\" ] } }, { "old_path": "scipy/base/src/arrayobject.c", "new_path": "scipy/base/src/arrayobject.c", "filename": "arrayobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -1675,8 +1675,16 @@ array_subscript(PyArrayObject *self, PyObject *op)\n value = PyArray_PyIntAsIntp(op);\n if (PyErr_Occurred())\n PyErr_Clear();\n- else if ((value <= MAX_INT) || (value >= -MAX_INT))\n- return array_item(self, (int) value);\n+ else if (value >= 0) {\n+ if (value <= MAX_INT)\n+ return array_item(self, (int) value);\n+ }\n+ else if (value < 0) {\n+ if (value >= -MAX_INT) {\n+ if (self->nd > 0) value += self->dimensions[0];\n+ return array_item(self, (int) value);\n+ }\n+ }\n }\n \n \tif (PyArrayMapIter_Check(op)) {\n", "added_lines": 10, "deleted_lines": 2, "source_code": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n if (PyErr_Occurred())\n PyErr_Clear();\n else if (value >= 0) {\n if (value <= MAX_INT)\n return array_item(self, (int) value);\n }\n else if (value < 0) {\n if (value >= -MAX_INT) {\n if (self->nd > 0) value += self->dimensions[0];\n return array_item(self, (int) value);\n }\n }\n }\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_BOOL;\n\t\tchksize = sizeof(Bool);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\tchar *msg = \"Cannot copy-back to a read-only array.\";\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "source_code_before": " /*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 *\n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* $Id: arrayobject.c,v 1.59 2005/09/14 00:14:00 teoliphant Exp $ */\n\n/*\n#include \"Python.h\"\n#include \"structmember.h\"\n\n#define _MULTIARRAYMODULE\n#include \"Numeric3/arrayobject.h\"\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INTP, 0, 0};\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Typecode typecode = {PyArray_INT, 0, 0};\n\tint ret;\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, &typecode);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, &typecode);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj) || PyBigArray_CheckExact(obj)) \n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n char *buf;\n int buf_len;\n PyObject *obj, *ret;\n\n zeroval = PyDataMem_NEW(arr->itemsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n if (PyArray_ISOBJECT(arr)) {\n obj=PyInt_FromLong((long) 0);\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n ret = PyObject_GetAttrString((PyObject *)arr, \"_zero\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_zero not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n return NULL;\n }\n memcpy(zeroval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n memset(zeroval, 0, arr->itemsize);\n return zeroval;\n}\n\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n char *buf;\n int buf_len, ret2;\n PyObject *obj, *ret;\n\n oneval = PyDataMem_NEW(arr->itemsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n \n ret = PyObject_GetAttrString((PyObject *)arr, \"_one\");\n if (ret != NULL) {\n if (PyObject_AsReadBuffer(ret, (const void **)&buf, \n &buf_len) < 0) {\n PyErr_SetString(PyExc_ValueError, \n \"_one not returning \" \\\n \"writeable buffer.\");\n Py_DECREF(ret);\n PyDataMem_FREE(oneval);\n return NULL;\n }\n memcpy(oneval, buf, buf_len);\n Py_DECREF(ret);\n }\n if (PyErr_Occurred()) PyErr_Clear();\n\n ret2 = arr->descr->setitem(obj, oneval, arr);\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->itemsize;\n int copies=1;\n int ret, i;\n int stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, char *, int, int, PyArrayObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, int i) \n{\n\tif (i==0 && (mp->nd == 0 || mp->dimensions[0] > 0)) \n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes;\n\tint ncopies, elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"Cannot write to array.\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Destination number of elements must be\"\\\n \"an integer multiple of the source number of\"\\\n \"elements.\");\n return -1;\n }\n ncopies = dsize / ssize;\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->copyswap;\n\tcopyswapn = dest->descr->copyswapn;\n\n elsize = dest->itemsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src)) \\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->itemsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\tPyArray_Typecode typecode = {dest->descr->type_num, \n\t\t\t\t dest->itemsize, \n\t\t\t\t PyArray_ISFORTRAN(dest)};\n\t\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t &typecode, 0,\n\t\t\t\t\t dest->nd, 0);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data) {\n\tPyObject *ret;\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#else\n\tret = PyArray_New(&PyArray_Type, nd, (intp *)d, \n descr->type_num, NULL, data, descr->elsize, \n\t\t\t CARRAY_FLAGS, NULL);\n#endif\n\tif (descr->type_num != PyArray_OBJECT)\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_SIZE(ret));\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_FromDimsAndData(int nd, int *d, int type, char *data) \n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tintp newd[MAX_DIMS];\n\tint i;\t\n\tfor (i=0; iob_type, m1->nd, \n\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t m1->descr->type_num,\n\t\t\t\t\t NULL, NULL, m1->itemsize,\n\t\t\t\t\t 0, m1);\n\t\n if (PyArray_CopyInto(ret, m1) == -1) return NULL;\n\t\n return (PyObject *)ret;\n}\n\n\nstatic PyObject *array_item(PyArrayObject *, int);\n\nstatic PyObject *\nPyArray_Scalar(char *data, int type_num, int itemsize, int swap)\n{\n PyArray_Descr *descr;\n\tPyTypeObject *type;\n\tPyObject *obj;\t\n\tchar *destptr;\n PyArray_CopySwapFunc *copyswap;\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n type = descr->typeobj;\n copyswap = descr->copyswap;\n\tif (type_num == PyArray_STRING) \n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISFLEXIBLE(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse {\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n\t\t\t\tPyObject_Del(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tif (type_num == PyArray_UNICODE) {\n\t\t\t\tPyUnicode_AS_UNICODE(obj) = \\\n\t\t\t\t\t(Py_UNICODE *)destptr;\n\t\t\t\t((PyUnicodeObject*)obj)->length = itemsize / \\\n\t\t\t\t\tsizeof(Py_UNICODE);\n\t\t\t\t((PyUnicodeObject*)obj)->hash = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t((PyVoidScalarObject *)obj)->obval = destptr;\n\t\t\t\t((PyVoidScalarObject *)obj)->ob_size = itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tdestptr = &(((PyScalarObject*)obj)->obval);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\nstatic PyObject *\nPyArray_ToScalar(char *data, PyArrayObject *arr)\n{\n\tint type_num = arr->descr->type_num;\n\tint itemsize = arr->itemsize;\n int swap = !(PyArray_ISNOTSWAPPED(arr));\n\n\treturn PyArray_Scalar(data, type_num, itemsize, swap);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (PyArray_Check((PyObject *)mp) && mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only register void subtypes.\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = malloc(sizeof(PyArray_Descr));\n\tmemcpy(descr, PyArray_DescrFromType(PyArray_VOID), \n\t sizeof(PyArray_Descr));\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n\tdescr->typeobj = type;\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n frees the copy of the Descr_table already there.\n places a pointer to the new one into the slot.\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\tint i;\n\n\tif (!PyArray_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Data type not registered.\");\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n#define _NULL_CHECK(member) \\\n\tif (descr->member == NULL) descr->member = old->member\n\n\tfor (i=0; imember == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tfree(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n n3 = strlen((const char *)sep);\n if (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"Cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\\\n\t\t\t\t\t\"binary mode.\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->itemsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->itemsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = strlen((const char *)format);\n while(it->index < it->size) {\n obj = self->descr->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller\" \\\n\t\t\t\t\t\" dimensional array\");\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n if (PyArray_TYPE(self) == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"a string for the data\"\\\n\t\t\t\t\"in an object array is not appropriate.\");\n return NULL;\n }\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->itemsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && (self->data != NULL)) {\n\t\t/* Free internal references if an Object array */\n\t\tPyArray_XDECREF(self);\n\n PyDataMem_FREE(self->data);\n }\n\t\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t}\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object.\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_item(PyArrayObject *self, int i) \n{\n char *item;\n PyArrayObject *r;\n\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed.\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tr = (PyArrayObject *)PyArray_New(self->ob_type, \n\t\t\t\t\t self->nd-1, self->dimensions+1, \n\t\t\t\t\t self->descr->type_num, \n\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t self->itemsize, self->flags,\n\t\t\t\t\t self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_item(self, i));\n}\n\n\nstatic int \narray_ass_item(PyArrayObject *self, int i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, int *v)\n{\n\t*v = PyArray_PyIntAsInt(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, int length,\n int *start, int *stop, int *step,\n intp *slicelength)\n{\n\tint defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step can not be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic int\nparse_subindex(PyObject *op, int *step_size, intp *n_steps, int max)\n{\n\tint index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tint stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsInt(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, start, offset, n_add, n_pseudo;\n int step_size;\n\tintp n_steps;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new, *tup;\n\tint n1, n2, n3, val;\n\tint i;\n\n\ttup = PyTuple_New(mit->nd);\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = 0;\n\twhile(val < n1)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tPyTuple_SET_ITEM(tup, i++, PyInt_FromLong((long)val++));\n\n\tnew = PyArray_Transpose(*ret, tup);\n\tPy_DECREF(tup);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tret = (PyArrayObject *)\\\n\t\tPyArray_New(temp->ob_type, mit->nd, mit->dimensions, \n\t\t\t temp->descr->type_num, NULL, NULL, \n\t\t\t temp->itemsize, \n\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) \n\t\treturn NULL;\n\tindex = it->size;\n\tswap = ((temp->flags & NOTSWAPPED) != (ret->flags & NOTSWAPPED));\n copyswap = ret->descr->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->itemsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n\tPyArray_Typecode typecode = {0, 0, 0};\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\ttypecode.type_num = mit->ait->ao->descr->type_num;\n\ttypecode.itemsize = mit->ait->ao->itemsize;\n\n\tarr = PyArray_FromAny(op, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\treturn -1;\n\n\tindex = mit->size;\n\tswap = ((mit->ait->ao->flags & NOTSWAPPED) != \\\n\t\t(PyArray_FLAGS(arr) & NOTSWAPPED));\n\n copyswap = PyArray_DESCR(arr)->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(typecode.type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n copyswap(mit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n return 0;\n }\n\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns 0-dimensional arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n if (PyErr_Occurred())\n PyErr_Clear();\n else if ((value <= MAX_INT) || (value >= -MAX_INT))\n return array_item(self, (int) value);\n }\n\n\tif (PyArrayMapIter_Check(op)) {\n\t\tmit = (PyArrayMapIterObject *)op;\n\t\t/* bind to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\n\t\t/* If the mapiterator was created with standard indexing\n\t\t behavior, fall through to view-based code */\n\t\tif (!mit->view) return PyArray_GetMap(mit);\n\t\top = mit->indexobj;\n\t}\n\telse { /* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n\t\tif (mit == NULL) return NULL;\n\t\tif (!mit->view) { /* fancy indexing */\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tother = (PyArrayObject *)PyArray_GetMap(mit);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn (PyObject *)other;\n\t\t}\n\t\tPy_DECREF(mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_New(self->ob_type, nd, dimensions, self->descr->type_num,\n\t\t\t strides, self->data+offset, \n\t\t\t self->itemsize, self->flags,\n\t\t\t self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret, i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n\n\tif (PyArrayMapIter_Check(index)) {\n\t\tmit = (PyArrayMapIterObject *)index;\n\t\t/* bind behavior to current array */\n\t\tPyArray_MapIterBind(mit, self);\n\t\t\t\n\t\t/* fall through if standard view-based map iterator */\n\t\tif (!mit->view) return PyArray_SetMap(mit, op);\n\t\tindex = mit->indexobj;\n\t}\n\telse {\n\t\tmit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n\t\tif (mit == NULL) return -1;\n\t\tif (!mit->view) {\n\t\t\tPyArray_MapIterBind(mit, self);\n\t\t\tret = PyArray_SetMap(mit, op);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn ret;\n\t\t}\n\t\tPy_DECREF((PyObject*)mit);\n\t}\n\n\ti = PyArray_PyIntAsInt(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n ret = PyArray_CopyObject(tmp, op);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"Array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"Array cannot be \"\\\n \"accessed as a writeable buffer.\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"Non-character array cannot be interpreted \"\\\n \"as character buffer.\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *TRUE_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(TRUE_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (PyDict_SetItemString(dict, #op, n_ops.op)==-1) \\\n\t\tgoto fail;\n\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(TRUE_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse\n\t\targs = Py_BuildValue(\"(Oii)\", m1, axis, rtype);\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OO)\", m1, m2);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(O)\", m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n PyObject *args, *ret;\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n args = Py_BuildValue(\"(OOO)\", m1, m2, m1);\n ret = PyObject_Call(op, args, NULL);\n Py_DECREF(args);\n return ret;\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.TRUE_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_TRUE_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.TRUE_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero */\nstatic int \narray_all_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = 0;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = 1;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int, scalar object is not a number.\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars.\");\n return NULL;\n }\n pv = v->descr->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int, \"\\\n\t\t\t\t\"scalar object is not a number.\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)array_all_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_TRUE_divide,\t /*nb_TRUE_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_TRUE_divide, /*nb_inplace_TRUE_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"can't slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n r = (PyArrayObject *)\\\n\t\tPyArray_New(self->ob_type, self->nd, self->dimensions, \n\t\t\t self->descr->type_num, self->strides, data,\n\t\t\t self->itemsize, self->flags, self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"Can't delete array elements.\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Array is not writeable.\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to any(self == el) */\n\n return PyObject_RichCompareBool((PyObject *)self, el, Py_EQ);\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISFLEXIBLE(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->itemsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tint sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->itemsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tPyBufferProcs *pb;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tpb = base->ob_type->tp_as_buffer;\n\tif (pb == NULL || pb->bf_getwritebuffer == NULL)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by either numbytes or\n a single segment array of the provided dimensions and element size if\n numbytes is 0 */\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n\t\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, char *data, int itemsize, int flags,\n\t PyArrayObject *obj)\n{\n\tPyArrayObject *self;\n\tPyArray_Descr *descr;\n\tregister int i;\n\tintp sd, temp;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions\"\t\\\n\t\t\t\t\t\" are not allowed.\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) return NULL;\t\n\tself->descr = descr;\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\n\tif (PyTypeNum_ISFLEXIBLE(type_num)) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"Type must provide an itemsize.\");\n\t\t\tPyObject_Del(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tself->itemsize = itemsize;\n\t\t/* Guarantee that these kind of arrays are never byteswapped\n\t\t unknowingly. \n\t\t*/\n\t\tif (type_num != PyArray_UNICODE)\n\t\t\tself->flags |= NOTSWAPPED;\n\t}\n\telse self->itemsize = descr->elsize; \n\t\t\n\tsd = self->itemsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"If strides is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too.\");\n\t\t\t\tPyObject_Del(self);\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Make sure we are aligned on void ptrs (without wasting\n\t\t space if we already are). But, also, allocate something \n\t\t even for zero-space arrays e.g. shape=(0,) -- otherwise\n buffer exposure (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\t\telse if ((temp=sd%sizeof(intp))) sd += sizeof(intp) - temp;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyObject_Del(self);\n\t\t\tif (self->dimensions != NULL) \n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\t/* We shouldn't need to check for the OBJECT Letter\n\t\t but perhaps it's best. */\n\t\tif (type_num == PyArray_OBJECT || \\\n\t\t type_num == PyArray_OBJECTLTR) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", (PyObject *)obj);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n}\n\n\n\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"Newsize is zero. Cannot delete an array \"\\\n \"in this way.\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data.\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = (((PyObject *)self)->ob_refcnt);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function.\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->itemsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"can't allocate memory for array.\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->itemsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"can't allocate memory for array \" \\\n \"(array may be corrupted).\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->itemsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ibase = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return PyArray_Return(ret);\n \n fail:\n if (dims.ptr) free(dims.ptr);\n if (strides.ptr) free(strides.ptr);\n return NULL;\n}\n\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n static PyObject *module=NULL;\n\n if (module==NULL) {\n module = PyImport_ImportModule(\"scipy.base._internal\");\n if (module == NULL) return NULL;\n }\n return PyObject_CallMethod(module, \"flagsobj\", \"Oi\", \n self, self->flags);\n}\n\n/*\nstatic int\narray_flags_set(PyArrayObject *self, PyObject *obj) \n{\n\tint flagback = self->flags;\n\n if (PyDict_Check(obj)) {\n PyObject *new;\n\t\tnew = PyDict_GetItemString(obj, \"ALIGNED\");\n\t\tif (new) {\n\t\t\tif (PyObject_Not(new)) self->flags &= ~ALIGNED;\n\t\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\t\telse {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"cannot set aligned flag of \" \\\n\t\t\t\t\t\t\"mis-aligned array to True\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n new = PyDict_GetItemString(obj, \"UPDATEIFCOPY\");\n if (new) {\n if (PyObject_Not(new)) {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n else {\n\t\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return -1;\n }\n }\n new = PyDict_GetItemString(obj, \"WRITEABLE\");\n if (new) {\n\t\t\tif (PyObject_IsTrue(new)) {\n\t\t\t\tif (_IsWriteable(self)) {\n\t\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tself->flags = flagback;\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"cannot set \"\t\\\n\t\t\t\t\t\t\t\"WRITEABLE \"\t\\\n\t\t\t\t\t\t\t\"flag to True of \"\\\n\t\t\t\t\t\t\t\"this array \");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n new = PyDict_GetItemString(obj, \"NOTSWAPPED\");\n if (new) {\n if (PyObject_IsTrue(new))\n self->flags |= NOTSWAPPED;\n else {\n self->flags &= ~NOTSWAPPED;\n\t\t\t}\n\t\t}\n return 0;\n }\n PyErr_SetString(PyExc_ValueError, \n \"Object must be a dictionary\");\n return -1;\n}\n*/\n\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tif (!PyTuple_Check(val)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"shape must be a tuple\");\n\t\treturn -1;\n\t}\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\t\n\tif (self->nd > 0) { /* Free old dimensions and strides */\n\t\tPyDimMem_FREE(self->dimensions);\n\t}\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse self->dimensions=NULL;\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides.\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\treturn -1;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->itemsize;\n\t\n\tif (!PyArray_CheckStrides(self->itemsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\treturn -1;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"Object does not have single-segment\" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"Cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"Not enough data for array.\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->itemsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tlonglong size=PyArray_SIZE(self);\n\tif (size > MAX_INT || size < MIN_INT)\n\t\treturn PyLong_FromLongLong((longlong) size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISFLEXIBLE(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->itemsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\tstatic char endians[] = \"<>\";\n\tchar endian;\n\tint which;\n\tunsigned long val = 1;\n\tchar *s;\n\tchar basic_=self->descr->kind;\n\n\ts = (char *)&val; /* s[0] == 0 implies big-endian */\n\twhich = (PyArray_ISNOTSWAPPED(self) ? 0 : 1);\n\tif (s[0] == 0) which = 1 - which;\n\tendian = endians[which]; \n\t\n\tif ((basic_==PyArray_VOIDLTR) || (basic_==PyArray_STRINGLTR) || \\\n\t (basic_==PyArray_OBJECTLTR) || (self->itemsize == 1))\n\t\treturn PyString_FromFormat(\"|%c%d\", basic_, self->itemsize);\n\telse\n\t\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t\t self->itemsize);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\t/* hand this off to the typeobject */\n\t/* or give default */\n\tif (PyArray_ISUSERDEF(self)) {\n\t\tres = PyObject_GetAttrString((PyObject *)self->descr->typeobj, \n\t\t\t\t\t \"__array_descr__\");\n\t\tif (res) return res;\n\t\tPyErr_Clear();\n\t}\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_typenum_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->type_num);\n}\n\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n\treturn PyArray_TypeObjectFromType(self->descr->type_num);\n}\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n*/\n\nstatic int\narray_type_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Typecode newtype = {PyArray_NOTYPE, 0, 0};\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if ((PyArray_TypecodeConverter(arg, &newtype) < 0) ||\n newtype.type_num == PyArray_NOTYPE) {\n PyErr_SetString(PyExc_TypeError, \"Invalid type for array\");\n return -1;\n }\n if (!(PyArray_ISONESEGMENT(self) ||\t\t\\\n\t (newtype.itemsize != self->itemsize))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1; \n }\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n if (newtype.itemsize < self->itemsize) {\n /* if it is compatible increase the size of the dimension\n at end (or at the front for FORTRAN)\n */\n if (self->itemsize % newtype.itemsize != 0) {\n PyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n newdim = self->itemsize / newtype.itemsize;\n\t\tself->dimensions[index] *= newdim;\n self->strides[index] = newtype.itemsize;\n\t}\n \n else if (newtype.itemsize > self->itemsize) {\n \n /* Determine if last (or first if FORTRAN) dimension\n is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->itemsize;\n if ((newdim % newtype.itemsize) != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n return -1;\n }\n\t\t\n self->dimensions[index] = newdim / newtype.itemsize;\n self->strides[index] = newtype.itemsize;\n\t\t\n }\n\t\n \n /* fall through -- adjust type*/\n\n self->descr = PyArray_DescrFromType(newtype.type_num);\n self->itemsize = newtype.itemsize;\n PyArray_UpdateFlags(self, ALIGNED);\n return 0;\n\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return -1;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n\tint itemsize;\n\tint typenum;\n PyArray_Typecode type = {self->descr->type_num, \n self->itemsize,\t \n PyArray_ISFORTRAN(self)};\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\titemsize = self->itemsize >> 1;\n\t\ttypenum = self->descr->type_num - PyArray_NUM_FLOATTYPE;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t typenum,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data + itemsize,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions, &type);\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides+ \\\n\t\t\t\t\t\t (self->itemsize >> 1) ,\n \t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"Does not have imaginary \" \\\n\t\t\t\t\"part to set.\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Typecode typecode = {self->descr->type_num,\n\t\t\t\t self->itemsize,\n\t\t\t\t PyArray_ISFORTRAN(self)};\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tarr = PyArray_FromAny(val, &typecode, \n\t\t\t 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n copyswap(selfit->dataptr, NULL, swap, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->itemsize);\n copyswap(selfit->dataptr, NULL, swap, self->itemsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t (setter)array_type_set,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypenum\",\n\t (getter)array_typenum_get,\n\t NULL,\n\t \"get array type number code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_data_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array of basic values. It has the folowing data members, m.shape (the size of each dimension in the array), m.itemsize (the size (in bytes) of each element of the array), and m.typecode (a character representing the type of the array elements). Arrays are sequence, mapping and numeric objects. Sequence indexing is similar to lists, with single indices returning a reference that points to the old array data, and slices returning by copy. A array is also allowed to be indexed by a sequence of items.\t Each member of the sequence indexes the corresponding dimension of the array.\";\n\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)0, \t\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n 0,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\n\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e,max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\nstatic void\n_array_small_type(int chktype, int mintype, int chksize, int minsize, \n\t\t PyArray_Typecode *outtype)\n{\n\touttype->type_num = MAX(chktype, mintype);\n\tif (PyTypeNum_ISFLEXIBLE(outtype->type_num) &&\t\\\n\t PyTypeNum_ISFLEXIBLE(mintype)) {\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype == PyArray_STRING) {\n\t\t\touttype->itemsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\touttype->itemsize = MAX(chksize, minsize);\n\t\t}\n\t}\n\telse {\n\t\touttype->itemsize = chksize;\n\t}\n\treturn;\t\n}\n\nstatic void\n_array_find_type(PyObject *op, PyArray_Typecode *minitype, \n\t\t PyArray_Typecode *outtype, int max)\n{\n int l;\n PyObject *ip;\n\tint chktype=0;\n\tint chksize=0;\n\tint mintype, minsize;\n\n\tif (minitype == NULL) {\n\t\tmintype = PyArray_BOOL;\n\t\tminsize = sizeof(Bool);\n\t}\n\telse {\n\t\tmintype = minitype->type_num;\n\t\tminsize = minitype->itemsize;\n\t}\n\n \n if (max < 0 || mintype == -1) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_TYPE(op);\n\t\tchksize = PyArray_ITEMSIZE(op);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tPyArray_TypecodeFromScalar(op, outtype);\n\t\tchktype = outtype->type_num;\n\t\tchksize = outtype->itemsize;\n\t\tgoto finish;\n\t}\n\t\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_TYPE(ip);\n\t\t\tchksize = PyArray_ITEMSIZE(ip);\n\t\t\tgoto finish;\n\t\t}\n } \n\t\n\tif (PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tint swap=0, res;\n\t\tip = PyObject_GetAttrString(op, \"__array_typestr__\");\n\t\tif (ip && PyString_Check(ip)) {\n\t\t\tres = _array_typecode_fromstr(PyString_AS_STRING(ip), \n\t\t\t\t\t\t &swap, outtype); \n\t\t\tif (res >= 0) {\n\t\t\t\tPy_DECREF(ip);\n\t\t\t\tchktype = outtype->type_num;\n\t\t\t\tchksize = outtype->itemsize;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\tPy_XDECREF(ip);\n\t}\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_STRING;\n\t\tchksize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_UNICODE;\n\t\tchksize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_VOID;\n\t\tchksize = op->ob_type->tp_as_sequence->sq_length(op);\n\t\tPyErr_Clear();\n\t\tgoto finish;\n\t}\n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\t\tPyArray_Typecode newtype = {mintype, minsize, 0};\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && mintype == 0) {\n\t\t\tnewtype.type_num = PyArray_INTP;\n\t\t\tnewtype.itemsize = sizeof(intp);\n\t\t}\n while (--l >= 0) {\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\t_array_find_type(ip, &newtype, outtype, max-1);\n\t\t\t_array_small_type(outtype->type_num,\n\t\t\t\t\t newtype.type_num, \n\t\t\t\t\t outtype->itemsize,\n\t\t\t\t\t newtype.itemsize,\n\t\t\t\t\t &newtype);\n Py_DECREF(ip);\n }\n\t\tchktype = newtype.type_num;\n\t\tchksize = newtype.itemsize;\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_BOOL;\n\t\tchksize = sizeof(Bool);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_LONG;\n\t\tchksize = sizeof(long);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DOUBLE;\n\t\tchksize = sizeof(double);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_CDOUBLE;\n\t\tchksize = sizeof(cdouble);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_OBJECT;\n\tchksize = sizeof(void *);\n\n finish:\n\t_array_small_type(chktype, mintype, chksize, minsize, \n\t\t\t outtype);\n\treturn;\n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Typecode *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize = 0;\n\tint type = typecode->type_num;\n\n\tif PyTypeNum_ISFLEXIBLE(type) {\n\t\titemsize = PyObject_Length(op);\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,\n\t\t\t\t\t NULL, NULL, itemsize, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n array_dealloc(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp *d;\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\t\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif ((d=PyDimMem_NEW(nd)) == NULL) {\n\t\treturn PyErr_NoMemory();\n }\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\tPyDimMem_FREE(d);\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISFLEXIBLE(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\tPyDimMem_FREE(d);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n r=(PyArrayObject*)PyArray_New(&PyArray_Type, nd, d, \n\t\t\t\t type, NULL, NULL,\n\t\t\t\t itemsize, \n\t\t\t\t typecode->fortran, NULL);\n\n PyDimMem_FREE(d);\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) return 0;\n\treturn 1;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->itemsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->itemsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->cast[out->descr->type_num];\n in_csn = in->descr->copyswap;\n out_csn = out->descr->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->itemsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n\n}\n\n\n/* For backward compatibility */\n\nstatic PyObject *\nPyArray_Cast(PyArrayObject *mp, int type_num) \n{\n\tPyArray_Typecode type;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\ttype.itemsize = descr->elsize;\n\ttype.type_num = descr->type_num;\n\ttype.fortran = 0;\n\t\n\treturn PyArray_CastToType(mp, &type);\n}\n\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Typecode *at) \n{\n\tPyObject *out;\n\tint ret;\n\n\tif ((mp->descr->type_num == at->type_num) && \\\n\t (at->itemsize==0 || mp->itemsize == at->itemsize) &&\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->itemsize == 0) {\n\t\tif (mp->descr->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->itemsize = mp->itemsize*sizeof(Py_UNICODE);\n\t\tif (mp->descr->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->itemsize = mp->itemsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->itemsize = mp->itemsize;\n\t}\n\n\tout = PyArray_New(mp->ob_type, mp->nd, \n\t\t\t mp->dimensions, \n\t\t\t at->type_num,\n\t\t\t NULL, NULL, at->itemsize, \n\t\t\t at->fortran, mp);\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array is not writeable.\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tsimple = ((PyArray_ISCARRAY(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->itemsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Typecode *typecode, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Typecode oldtype={PyArray_TYPE(arr),PyArray_ITEMSIZE(arr),0};\n\tchar *msg = \"Cannot copy-back to a read-only array.\";\n\t\n\tif (type == PyArray_NOTYPE) type = arr->descr->type_num;\n\tif (itemsize == 0) itemsize = arr->itemsize;\n\ttypecode->type_num = type;\n\ttypecode->itemsize = itemsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivalentTypes(&oldtype, typecode)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| (PyArray_ITEMSIZE(arr) != itemsize) || \\\n\t\t\t((flags & ALIGNED) && (!(arrflags & ALIGNED))) || \\\n\t\t\t((flags & NOTSWAPPED) && (!(arrflags & NOTSWAPPED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_New(arr->ob_type, \n\t\t\t\t\t arr->nd, \n\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t arr->descr->type_num,\n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t itemsize,\n\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t arr);\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) return NULL;\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n\t\t\tPy_INCREF(arr);\n\t\t\tret = arr;\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastSafely(PyArray_TYPE(arr), type)) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_CastToType(arr, typecode);\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"Array can not be safely cast \"\\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic int\n_array_typecode_fromstr(char *str, int *swap, PyArray_Typecode *type)\n{\n int type_num;\n char typechar;\n int size;\n unsigned long number = 1;\n char *s;\n char msg[] = \"unsupported typestring\";\n \n s = (char *)&number; /* s[0] == 0 implies big-endian */\n\n *swap = 0;\n\n if (str[0] == '<' || str[0] == '>') {\n\tif ((str[0] == '<') && (s[0] == 0)) *swap = 1;\n\telse if ((str[0] == '>') && (s[0] != 0)) *swap = 1;\n }\n str += 1;\n \n#define _MY_FAIL {\t\t\t\t \\\n\t PyErr_SetString(PyExc_ValueError, msg); \\\n\t return -1;\t\t\t \\\n }\t\t\n\n typechar = str[0];\n size = atoi(str + 1);\n switch (typechar) {\n case 'b':\n\t if (size == sizeof(Bool))\n\t\t type_num = PyArray_BOOL;\t \n\t else _MY_FAIL \n\t break;\t\t \n case 'u':\n if (size == sizeof(uintp))\n type_num = PyArray_UINTP;\n\t else if (size == sizeof(char))\n\t\t type_num = PyArray_UBYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_USHORT;\n\t else if (size == sizeof(int)) \n\t\t type_num = PyArray_UINT;\n\t else if (size == sizeof(ulong)) \n\t\t type_num = PyArray_ULONG;\n\t else if (size == sizeof(ulonglong))\n\t\t type_num = PyArray_ULONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'i':\n if (size == sizeof(intp))\n type_num = PyArray_INTP;\n\t else if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t else if (size == sizeof(short)) \n\t\t type_num = PyArray_SHORT;\n\t else if (size == sizeof(int))\n\t\t type_num = PyArray_INT;\n\t else if (size == sizeof(long)) \n\t\t type_num = PyArray_LONG;\n\t else if (size == sizeof(longlong))\n\t\t type_num = PyArray_LONGLONG;\n\t else _MY_FAIL\n\t break;\t\t \n case 'f':\n\t if (size == sizeof(float))\n\t\t type_num = PyArray_FLOAT;\n\t else if (size == sizeof(double))\n\t\t type_num = PyArray_DOUBLE;\n\t else if (size == sizeof(longdouble))\n\t\t type_num = PyArray_LONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'c':\n\t if (size == sizeof(float)*2)\n\t\t type_num = PyArray_CFLOAT;\n\t else if (size == sizeof(double)*2)\n\t\t type_num = PyArray_CDOUBLE;\n\t else if (size == sizeof(longdouble)*2)\n\t\t type_num = PyArray_CLONGDOUBLE;\n\t else _MY_FAIL\n\t break;\n case 'O':\n\t if (size == sizeof(PyObject *))\n\t\t type_num = PyArray_OBJECT;\n\t else _MY_FAIL\n\t break;\n case 'S':\n\t type_num = PyArray_STRING;\n\t break;\n case 'U':\n\t type_num = PyArray_UNICODE;\n\t size *= sizeof(Py_UNICODE);\n\t break;\t \n case 'V':\n\t type_num = PyArray_VOID;\n\t break;\n default:\n\t _MY_FAIL\n }\n\n#undef _MY_FAIL\n\n type->type_num = type_num;\n type->itemsize = size;\n type->fortran = 0;\n return 0;\n}\n\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Typecode *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n\tPyArrayObject *ret=NULL;\n\tPyArray_Typecode type;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tint dims[MAX_DIMS], strides[MAX_DIMS];\n\tint swap;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif (attr == NULL) {\n\t\tPy_INCREF(input);\n\t\tattr = input;\n\t}\n\t\n\tres = PyObject_AsWriteBuffer(attr, (void **)&data, &buffer_len);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n\n\tattr = PyObject_GetAttrString(input, \"__array_typestr__\");\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\t\n\t}\n\tres = _array_typecode_fromstr(PyString_AS_STRING(attr), &swap, &type);\n\tPy_DECREF(attr);\n\tif (res < 0) return NULL;\n \n\tattr = PyObject_GetAttrString(input, \"__array_shape__\");\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple.\");\n\t\tPy_DECREF(attr);\n\t\treturn NULL;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__.\");\n\t\t\tPy_DECREF(attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\n\tif (swap) {\n\t\tPyObject *tmp;\n\t\ttmp = PyObject_CallMethod((PyObject *)ret, \"byteswap\", \"\");\n\t\tPy_DECREF(tmp);\n\t}\n\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n}\n\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Typecode *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode->type_num == PyArray_NOTYPE) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n new = PyObject_CallMethod(op, \"__array__\", \"i\", \n typecode->type_num);\n }\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array.\");\n Py_DECREF(new);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n\tint type = typecode->type_num;\n PyObject *r=NULL;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, typecode, flags);\n\telse if (PyObject_HasAttrString(op, \"__array__\")) {\n\t\t/* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, typecode, flags);\n\t}\n\telse if (PyObject_HasAttrString(op, \"__array_shape__\") &&\n\t\t PyObject_HasAttrString(op, \"__array_typestr__\")) {\n\t\tr = array_frominterface(op, typecode, flags);\n\t}\n\telse {\n\t\tif (type == PyArray_NOTYPE) {\n\t\t\t_array_find_type(op, NULL, typecode, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op))\n\t\t\tr = Array_FromSequence(op, typecode, \n\t\t\t\t\t min_depth, max_depth);\n\t\telse\n\t\t\tr = Array_FromScalar(op, typecode);\n\t}\n\n /* If we didn't succed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Internal error array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object of too small depth for desired array\");\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n Py_DECREF(r);\n PyErr_SetString(PyExc_ValueError, \n \"Object too deep for desired array\");\n return NULL;\n }\n return r;\n}\n\nstatic void\nPyArray_ArrayType(PyObject *op, PyArray_Typecode *intype, \n\t\t PyArray_Typecode *outtype) \n{\n\t_array_find_type(op, intype, outtype, MAX_DIMS);\n\treturn;\n}\n\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Typecode intype, outtype;\n\tintype.type_num = minimum_type;\n\t_array_find_type(op, &intype, &outtype, MAX_DIMS);\n\treturn outtype.type_num;\n}\n\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN, (or set typecode->fortran=1)\n ALIGNED, \n NOTSWAPPED, \n WRITEABLE, \n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED, NOTSWAPPED, and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | NOTSWAPPED | WRITEABLE\n BEHAVED_FLAGS_RO == ALIGNED | NOTSWAPPED\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n By default, the returned array will be a copy of the object, \n (C) contiguous in memory, aligned, notswapped, and writeable.\n \n So CONTIGUOUS | ENSURECOPY passed in means that the returned\n array does not have to be CONTIGUOUS or a COPY but should be\n ALIGNED, NOTSWAPPED and WRITEABLE. \n\n typecode->fortran can be set to request a\n fortran-contiguous array. Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS. Note that either\n FORTRAN in the flag or typecode->fortran = 1 is enough to request\n a FORTRAN-style array. \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Typecode *typecode, int min_depth, \n\t\tint max_depth, int requires) \n{\n \tPyArray_Typecode mine = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode *type;\n\t\n\tif (typecode == NULL) type = &mine;\n\telse type = typecode;\n\t\t\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\t/* Ensure that type->fortran and flags & FORTRAN are the\n\t same */\n\tif (requires & FORTRAN) typecode->fortran = 1;\n\tif (type->fortran == 1) {\n\t\trequires |= FARRAY_FLAGS;\n\t\tif (min_depth > 2) requires &= ~CONTIGUOUS;\n\t}\n\n\t/* make sure itemsize is not 0 unless warranted. */\n\tif ((type->itemsize == 0) && (type->type_num != PyArray_NOTYPE)) {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(type->type_num);\n\t\tif (descr != NULL) type->itemsize = descr->elsize;\n\t\telse return NULL;\n\t}\n\t\n\treturn array_fromobject(op, type, min_depth, max_depth, \n\t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, 0) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It steals a reference to the object */\n\n/* Because it decrefs op if any conversion needs to take place \n -- so it can be used like PyArray_EnsureArray(some_function(...)) */\n\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_Check(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, 0);\n Py_DECREF(op);\n return new;\n}\n\n/* These are all compressed into a single API */\n/* Deprecated calls -- Use PyArray_FromAny */\n\nstatic PyObject *\nPyArray_FromObject(PyObject *op, int type, int min_depth, int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, BEHAVED_FLAGS);\n}\n\nstatic PyObject *\nPyArray_ContiguousFromObject(PyObject *op, int type, int min_depth, \n\t\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth,\n\t\t\t max_depth, DEFAULT_FLAGS);\n}\n\nstatic PyObject *\nPyArray_CopyFromObject(PyObject *op, int type, int min_depth, \n\t\t int max_depth) \n{\n\tPyArray_Typecode typecode = {type, 0, 0};\n return PyArray_FromAny(op, &typecode, min_depth, max_depth,\n\t\t\t ENSURECOPY);\n}\n\n/* End of deprecated */\n\n\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n \n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (to->elsize > from->elsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (to->elsize >= from->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n\t\t\treturn (to->elsize > from->elsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n\t\t\treturn ((to->elsize >> 1) > from->elsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((to->elsize >> 1) >= from->elsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\nstatic Bool\nPyArray_CanCastTo(PyArray_Typecode *from, PyArray_Typecode *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->itemsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->itemsize <= to->itemsize);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = PyObject_GC_New(PyArrayIterObject, &PyArrayIter_Type);\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n PyObject_GC_Track(it);\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n PyObject_GC_UnTrack(it);\n Py_XDECREF(it->ao);\n PyObject_GC_Del(it);\n }\n\nstatic int\narrayiter_traverse(PyArrayIterObject *it, visitproc visit, void *arg)\n{\n if (it->ao != NULL)\n return visit((PyObject *)(it->ao), arg);\n return 0;\n}\n\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->itemsize;\n\tr = PyArray_New(self->ao->ob_type, 1, &count, \n\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\titemsize, 0, self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->itemsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tr = PyArray_New(self->ao->ob_type, ind->nd, ind->dimensions,\n\t\t\tself->ao->descr->type_num, NULL, \n\t\t\tNULL, self->ao->itemsize, \n\t\t\t0, self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\t\t\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tr = PyArray_New(self->ao->ob_type, 1, &ii, \n\t\t\t\t\tself->ao->descr->type_num, NULL, \n\t\t\t\t\tNULL, self->ao->itemsize, 0,\n\t\t\t\t\tself->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->itemsize;\n\t\tr = PyArray_New(self->ao->ob_type, 1, &n_steps, \n\t\t\t\tself->ao->descr->type_num, NULL, NULL,\n\t\t\t\tsize, 0, self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Boolean index array should have 1 dim\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->itemsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Typecode typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = typecode.itemsize = self->ao->itemsize;\n\ttypecode.type_num = self->ao->descr->type_num;\n copyswap = self->ao->descr->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"Index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", num, self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Typecode type;\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tint swap;\n\tint itemsize;\n\tint start, step_size;\n\tintp n_steps;\n\tPyObject *obj;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\t\n\ttype.type_num = self->ao->descr->type_num;\n\titemsize = type.itemsize = self->ao->itemsize;\n\t\n\tarrval = PyArray_FromAny(val, &type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto fail;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tgoto succeed;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tgoto succeed;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tgoto succeed;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tif (PyArray_IsScalar(ind, Integer))\n\t\tobj = PyArray_FromScalar(ind, &indtype);\n\telse if (PyList_Check(ind)) {\n\t\tobj = PyArray_FromAny(ind, &indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, &indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tif (new==NULL) goto fail;\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto fail;\n\t\t}\n\t\telse goto fail;\n\t\tPy_DECREF(obj);\n\t\tgoto succeed;\n\t}\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tgoto fail;\n\n succeed:\n\tPy_DECREF(val_it);\n\tPy_DECREF(arrval);\n\treturn 0;\n\n fail:\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn -1;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, it->ao->data, it->ao->itemsize, \n\t\t\t\tit->ao->flags,\n it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_New(it->ao->ob_type, 1, &size, \n\t\t\t\tit->ao->descr->type_num,\n NULL, NULL, it->ao->itemsize, 0, it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arrayiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tarr = PyArray_FromAny(obj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape.\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub=NULL, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\t/* Remove old binding if any */\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\n\tPy_XDECREF(mit->subspace);\n\tmit->subspace = NULL;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Too many indices for array.\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tif (mit->subspace == NULL) goto fail;\n\tPy_DECREF(sub);\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, '\\0', sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tint start=0;\n\t\t\tint stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t *indptr, dimsize-1, \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(sub);\n\tPy_XDECREF(mit->ait);\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Typecode typecode = {PyArray_BOOL, 0, 0};\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, &typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) return nd;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_TypeError,\t\t\t\\\n\t\t\t\t\"Arrays used as indexes must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_TypeError,\"Too many indicies\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyList_Check(indexobj) || PyArray_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tarr = PyArray_FromAny(indexobj, &indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (mit->iters[0] == NULL) goto fail;\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n PyObject_GC_Track(mit);\n return (PyObject *)mit;\n \n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n\treturn NULL;\n}\n\n\n/* return unbound mapiter object */\n\nstatic PyObject *\narraymapiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) \n{\n\tPyObject *newtup, *res;\n\tint n;\n\n\tif (!PyTuple_Check(args)) {\n\t\tPyErr_BadInternalCall();\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_GET_SIZE(args);\n\t\n\tif (n < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"must be initialized with >= 1 argument\");\n\t\treturn NULL;\n\t}\n\t\n\tif (n > 1) {\n\t\tnewtup = PyTuple_GetSlice(args, 0, n);\n\t\tif (newtup == NULL) return NULL;\n\t\tres = PyArray_MapIterNew(newtup);\n\t\tPy_DECREF(newtup);\n\t}\n\telse { /* n == 1 */\n\t\tnewtup = PyTuple_GET_ITEM(args, 0);\n\t\tres = PyArray_MapIterNew(newtup);\n\t}\n\n\treturn res; \t\n}\n\n\n/* Returns a 0-dim array holding the element desired */\n\nstatic PyObject *\narraymapiter_next(PyArrayMapIterObject *mit)\n{\n\tPyObject *ret;\n\tif (mit->ait == NULL) return NULL;\n\tif (mit->view) return NULL;\n\tif (mit->index < mit->size) {\n\t\tret = PyArray_ToScalar(mit->dataptr, mit->ait->ao);\n\t\tPyArray_MapIterNext(mit);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n PyObject_GC_UnTrack(mit);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->indexobj);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n PyObject_GC_Del(mit);\n}\n\nstatic int\narraymapiter_traverse(PyArrayMapIterObject *mit, visitproc visit, void *arg)\n{\n\tint ret, i;\n if (mit->ait != NULL)\n if ((ret = visit((PyObject *)(mit->ait), arg)) != 0) \n\t\t\treturn ret;\t\n\n\tif (mit->iters != NULL) \n\t\tfor (i=0; inumiter; i++) \n\t\t\tif (mit->iters[i] != NULL) \n\t\t\t\tif ((ret=visit((PyObject *)mit->iters[i], \n\t\t\t\t\t arg)) != 0)\n\t\t\t\t\treturn ret;\n\n\tif (mit->indexobj != NULL)\n\t\tif ((ret = visit(mit->indexobj, arg)) != 0) return ret;\n\t\n return 0;\n}\n\n/* \nstatic char doc_mapiter_bind[] = \"obj.bind(a)\\n Bind an array to the \"\\\n\t\"mapiter object\";\n\nstatic PyObject *\nmapiter_bind(PyArrayMapIterObject *mit, PyObject *args)\n{\n\tPyObject *r;\n intp size, strides;\n int nd;\n\tPyArrayObject *arr;\n\n if (!PyArg_ParseTuple(args, \"O!\", &PyArray_Type, &arr)) return NULL;\n\n\tPyArray_MapIterBind(mit, arr);\n\n\tif (mit->ait == NULL) return NULL;\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef mapiter_methods[] = {\n\t{\"bind\", (PyCFunction)mapiter_bind, 1, doc_mapiter_bind},\n {NULL,\t\tNULL}\t\t\n};\n*/\n\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)arraymapiter_traverse,\t/* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)arraymapiter_next,\t/* tp_iternext */\n 0,\t \t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n (newfunc)arraymapiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n\n", "methods": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1194, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1206, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1240, "end_line": 1270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1274, "end_line": 1282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1288, "end_line": 1338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1345, "end_line": 1390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1394, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1492, "end_line": 1526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1531, "end_line": 1581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1584, "end_line": 1643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 19, "token_count": 421, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1739, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 76, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1752, "end_line": 1804, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1812, "end_line": 1815, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1834, "end_line": 1846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1849, "end_line": 1864, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1868, "end_line": 1877, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1880, "end_line": 1891, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1959, "end_line": 1992, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1998, "end_line": 2037, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2040, "end_line": 2059, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2063, "end_line": 2082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2086, "end_line": 2097, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2100, "end_line": 2111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2114, "end_line": 2126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2129, "end_line": 2132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2135, "end_line": 2138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2141, "end_line": 2144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2147, "end_line": 2150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2153, "end_line": 2156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2159, "end_line": 2162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2165, "end_line": 2168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2171, "end_line": 2174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2177, "end_line": 2180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2183, "end_line": 2186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2189, "end_line": 2192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2195, "end_line": 2198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2201, "end_line": 2204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2207, "end_line": 2210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2213, "end_line": 2216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2219, "end_line": 2222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2225, "end_line": 2228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2231, "end_line": 2234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2237, "end_line": 2240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2243, "end_line": 2246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2249, "end_line": 2252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2255, "end_line": 2258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2261, "end_line": 2264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2267, "end_line": 2270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2273, "end_line": 2276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2279, "end_line": 2282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2285, "end_line": 2288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2291, "end_line": 2295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2298, "end_line": 2302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2306, "end_line": 2324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2327, "end_line": 2342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2346, "end_line": 2372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2375, "end_line": 2400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2403, "end_line": 2425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2428, "end_line": 2450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2453, "end_line": 2475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2478, "end_line": 2482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2543, "end_line": 2581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2585, "end_line": 2606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2609, "end_line": 2614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2635, "end_line": 2682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2685, "end_line": 2721, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2727, "end_line": 2744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2747, "end_line": 2759, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2762, "end_line": 2774, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2778, "end_line": 2855, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2858, "end_line": 2887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2893, "end_line": 2909, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2914, "end_line": 2937, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2943, "end_line": 2959, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2963, "end_line": 2979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2983, "end_line": 2999, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 3002, "end_line": 3035, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3039, "end_line": 3061, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3068, "end_line": 3083, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3103, "end_line": 3127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3131, "end_line": 3275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3280, "end_line": 3385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3389, "end_line": 3406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3410, "end_line": 3525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3532, "end_line": 3535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3538, "end_line": 3548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3621, "end_line": 3624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3628, "end_line": 3662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3666, "end_line": 3669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3672, "end_line": 3705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3709, "end_line": 3716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3719, "end_line": 3727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3731, "end_line": 3745, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3748, "end_line": 3792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3796, "end_line": 3799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3802, "end_line": 3809, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3813, "end_line": 3820, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3823, "end_line": 3843, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3846, "end_line": 3868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3871, "end_line": 3874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3878, "end_line": 3881, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3893, "end_line": 3951, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3956, "end_line": 3966, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3970, "end_line": 3995, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3999, "end_line": 4031, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4034, "end_line": 4067, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4070, "end_line": 4107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4110, "end_line": 4113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4116, "end_line": 4168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4344, "end_line": 4369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4372, "end_line": 4394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4401, "end_line": 4427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4430, "end_line": 4450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 123, "complexity": 28, "token_count": 661, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4453, "end_line": 4591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4594, "end_line": 4617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4621, "end_line": 4644, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4648, "end_line": 4705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4709, "end_line": 4716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4722, "end_line": 4812, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4818, "end_line": 4829, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4832, "end_line": 4867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4874, "end_line": 4920, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4923, "end_line": 5013, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 5017, "end_line": 5122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5125, "end_line": 5219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5222, "end_line": 5243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5247, "end_line": 5309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5312, "end_line": 5317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5320, "end_line": 5326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5380, "end_line": 5410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5420, "end_line": 5436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5442, "end_line": 5447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5450, "end_line": 5456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5459, "end_line": 5465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5471, "end_line": 5542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5545, "end_line": 5569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5579, "end_line": 5616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5621, "end_line": 5631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5634, "end_line": 5639, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5642, "end_line": 5647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5651, "end_line": 5654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5658, "end_line": 5706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5709, "end_line": 5761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5765, "end_line": 5884, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5888, "end_line": 5920, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5923, "end_line": 5964, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5968, "end_line": 6090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6103, "end_line": 6144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6149, "end_line": 6153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6218, "end_line": 6279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6287, "end_line": 6302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6308, "end_line": 6377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6381, "end_line": 6417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6423, "end_line": 6467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6485, "end_line": 6621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6627, "end_line": 6696, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6699, "end_line": 6832, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6838, "end_line": 6868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6874, "end_line": 6885, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6888, "end_line": 6897, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6900, "end_line": 6918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyArray_PyIntAsIntp", "long_name": "PyArray_PyIntAsIntp( PyObject * o)", "filename": "arrayobject.c", "nloc": 59, "complexity": 19, "token_count": 385, "parameters": [ "o" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "PyArray_PyIntAsInt", "long_name": "PyArray_PyIntAsInt( PyObject * o)", "filename": "arrayobject.c", "nloc": 57, "complexity": 19, "token_count": 389, "parameters": [ "o" ], "start_line": 109, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "PyArray_GetPriority", "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 81, "parameters": [ "obj", "default_" ], "start_line": 173, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_Zero", "long_name": "PyArray_Zero( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 190, "parameters": [ "arr" ], "start_line": 206, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_One", "long_name": "PyArray_One( PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 40, "complexity": 7, "token_count": 222, "parameters": [ "arr" ], "start_line": 244, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "do_sliced_copy", "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", "filename": "arrayobject.c", "nloc": 48, "complexity": 13, "token_count": 313, "parameters": [ "dest", "dest_strides", "dest_dimensions", "dest_nd", "src", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 293, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "optimize_slices", "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", "filename": "arrayobject.c", "nloc": 32, "complexity": 8, "token_count": 214, "parameters": [ "dest_strides", "dest_dimensions", "dest_nd", "src_strides", "src_dimensions", "src_nd", "elsize", "copies" ], "start_line": 366, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "contiguous_data", "long_name": "contiguous_data( PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 29, "complexity": 4, "token_count": 213, "parameters": [ "src" ], "start_line": 400, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_INCREF", "long_name": "PyArray_INCREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 447, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_XDECREF", "long_name": "PyArray_XDECREF( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 6, "token_count": 125, "parameters": [ "mp" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "byte_swap_vector", "long_name": "byte_swap_vector( * p , int n , int size)", "filename": "arrayobject.c", "nloc": 38, "complexity": 10, "token_count": 340, "parameters": [ "p", "n", "size" ], "start_line": 497, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "copy_and_swap", "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", "filename": "arrayobject.c", "nloc": 18, "complexity": 5, "token_count": 120, "parameters": [ "dst", "src", "itemsize", "numitems", "srcstrides", "swap" ], "start_line": 540, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "index2ptr", "long_name": "index2ptr( PyArrayObject * mp , int i)", "filename": "arrayobject.c", "nloc": 10, "complexity": 7, "token_count": 86, "parameters": [ "mp", "i" ], "start_line": 568, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyArray_Size", "long_name": "PyArray_Size( PyObject * op)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 33, "parameters": [ "op" ], "start_line": 581, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyArray_CopyInto", "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", "filename": "arrayobject.c", "nloc": 71, "complexity": 16, "token_count": 425, "parameters": [ "dest", "src" ], "start_line": 602, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "PyArray_CopyObject", "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", "filename": "arrayobject.c", "nloc": 15, "complexity": 2, "token_count": 88, "parameters": [ "dest", "src_object" ], "start_line": 686, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndDataAndDescr", "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 144, "parameters": [ "nd", "d", "descr", "data" ], "start_line": 710, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "PyArray_FromDimsAndData", "long_name": "PyArray_FromDimsAndData( int nd , int * d , int type , char * data)", "filename": "arrayobject.c", "nloc": 16, "complexity": 4, "token_count": 133, "parameters": [ "nd", "d", "type", "data" ], "start_line": 735, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_FromDims", "long_name": "PyArray_FromDims( int nd , int * d , int type)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 129, "parameters": [ "nd", "d", "type" ], "start_line": 758, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "PyArray_Copy", "long_name": "PyArray_Copy( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 73, "parameters": [ "m1" ], "start_line": 781, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "PyArray_Scalar", "long_name": "PyArray_Scalar( char * data , int type_num , int itemsize , int swap)", "filename": "arrayobject.c", "nloc": 48, "complexity": 8, "token_count": 289, "parameters": [ "data", "type_num", "itemsize", "swap" ], "start_line": 799, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyArray_ToScalar", "long_name": "PyArray_ToScalar( char * data , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "data", "arr" ], "start_line": 855, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyArray_Return", "long_name": "PyArray_Return( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 17, "complexity": 5, "token_count": 85, "parameters": [ "mp" ], "start_line": 868, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDataType", "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", "filename": "arrayobject.c", "nloc": 27, "complexity": 5, "token_count": 158, "parameters": [ "type" ], "start_line": 898, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_RegisterDescrForType", "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", "filename": "arrayobject.c", "nloc": 32, "complexity": 3, "token_count": 167, "parameters": [ "typenum", "descr" ], "start_line": 936, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 0 }, { "name": "PyArray_ToFile", "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", "filename": "arrayobject.c", "nloc": 87, "complexity": 16, "token_count": 571, "parameters": [ "self", "fp", "sep", "format" ], "start_line": 983, "end_line": 1072, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 90, "top_nesting_level": 0 }, { "name": "PyArray_ToList", "long_name": "PyArray_ToList( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 24, "complexity": 5, "token_count": 151, "parameters": [ "self" ], "start_line": 1075, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "PyArray_ToString", "long_name": "PyArray_ToString( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 191, "parameters": [ "self" ], "start_line": 1106, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "array_dealloc", "long_name": "array_dealloc( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 20, "complexity": 7, "token_count": 144, "parameters": [ "self" ], "start_line": 1150, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_length", "long_name": "array_length( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 1194, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_item", "long_name": "array_item( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 22, "complexity": 4, "token_count": 146, "parameters": [ "self", "i" ], "start_line": 1206, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "array_item_nice", "long_name": "array_item_nice( PyArrayObject * self , int i)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "i" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_ass_item", "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", "filename": "arrayobject.c", "nloc": 27, "complexity": 8, "token_count": 177, "parameters": [ "self", "i", "v" ], "start_line": 1240, "end_line": 1270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "slice_coerce_index", "long_name": "slice_coerce_index( PyObject * o , int * v)", "filename": "arrayobject.c", "nloc": 9, "complexity": 2, "token_count": 40, "parameters": [ "o", "v" ], "start_line": 1274, "end_line": 1282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "slice_GetIndices", "long_name": "slice_GetIndices( PySliceObject * r , int length , int * start , int * stop , int * step , intp * slicelength)", "filename": "arrayobject.c", "nloc": 45, "complexity": 24, "token_count": 376, "parameters": [ "r", "length", "start", "stop", "step", "slicelength" ], "start_line": 1288, "end_line": 1338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "parse_subindex", "long_name": "parse_subindex( PyObject * op , int * step_size , intp * n_steps , int max)", "filename": "arrayobject.c", "nloc": 45, "complexity": 11, "token_count": 223, "parameters": [ "op", "step_size", "n_steps", "max" ], "start_line": 1345, "end_line": 1390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "parse_index", "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", "filename": "arrayobject.c", "nloc": 89, "complexity": 20, "token_count": 540, "parameters": [ "self", "op", "dimensions", "strides", "offset_ptr" ], "start_line": 1394, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 96, "top_nesting_level": 0 }, { "name": "_swap_axes", "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", "filename": "arrayobject.c", "nloc": 24, "complexity": 4, "token_count": 187, "parameters": [ "mit", "ret" ], "start_line": 1492, "end_line": 1526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "PyArray_GetMap", "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 36, "complexity": 8, "token_count": 248, "parameters": [ "mit" ], "start_line": 1531, "end_line": 1581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "PyArray_SetMap", "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", "filename": "arrayobject.c", "nloc": 50, "complexity": 12, "token_count": 392, "parameters": [ "mit", "op" ], "start_line": 1584, "end_line": 1643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 53, "complexity": 16, "token_count": 376, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 0 }, { "name": "array_ass_sub", "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", "filename": "arrayobject.c", "nloc": 43, "complexity": 9, "token_count": 251, "parameters": [ "self", "index", "op" ], "start_line": 1744, "end_line": 1796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "array_subscript_nice", "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "op" ], "start_line": 1804, "end_line": 1807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_getsegcount", "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", "filename": "arrayobject.c", "nloc": 11, "complexity": 4, "token_count": 48, "parameters": [ "self", "lenp" ], "start_line": 1826, "end_line": 1838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_getreadbuf", "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 72, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1841, "end_line": 1856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_getwritebuf", "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1860, "end_line": 1869, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "array_getcharbuf", "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 3, "token_count": 65, "parameters": [ "self", "segment", "ptrptr" ], "start_line": 1872, "end_line": 1883, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_SetNumericOps", "long_name": "PyArray_SetNumericOps( PyObject * dict)", "filename": "arrayobject.c", "nloc": 34, "complexity": 1, "token_count": 162, "parameters": [ "dict" ], "start_line": 1951, "end_line": 1984, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_GetNumericOps", "long_name": "PyArray_GetNumericOps()", "filename": "arrayobject.c", "nloc": 39, "complexity": 2, "token_count": 183, "parameters": [], "start_line": 1990, "end_line": 2029, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "PyArray_GenericReduceFunction", "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2032, "end_line": 2051, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericAccumulateFunction", "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", "filename": "arrayobject.c", "nloc": 20, "complexity": 5, "token_count": 121, "parameters": [ "m1", "op", "axis", "rtype" ], "start_line": 2055, "end_line": 2074, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "PyArray_GenericBinaryFunction", "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "m1", "m2", "op" ], "start_line": 2078, "end_line": 2089, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericUnaryFunction", "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 63, "parameters": [ "m1", "op" ], "start_line": 2092, "end_line": 2103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_GenericInplaceBinaryFunction", "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", "filename": "arrayobject.c", "nloc": 13, "complexity": 2, "token_count": 71, "parameters": [ "m1", "m2", "op" ], "start_line": 2106, "end_line": 2118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_add", "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2121, "end_line": 2124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_subtract", "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2127, "end_line": 2130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_multiply", "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2133, "end_line": 2136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_divide", "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2139, "end_line": 2142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_remainder", "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2145, "end_line": 2148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_power", "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2151, "end_line": 2154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_negative", "long_name": "array_negative( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2157, "end_line": 2160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_absolute", "long_name": "array_absolute( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2163, "end_line": 2166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_invert", "long_name": "array_invert( PyArrayObject * m1)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "m1" ], "start_line": 2169, "end_line": 2172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_left_shift", "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2175, "end_line": 2178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_right_shift", "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2181, "end_line": 2184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_and", "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2187, "end_line": 2190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_or", "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2193, "end_line": 2196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_bitwise_xor", "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2199, "end_line": 2202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_add", "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2205, "end_line": 2208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_subtract", "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2211, "end_line": 2214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_multiply", "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2217, "end_line": 2220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_divide", "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2223, "end_line": 2226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_remainder", "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2229, "end_line": 2232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_power", "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2235, "end_line": 2238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_left_shift", "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2241, "end_line": 2244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_right_shift", "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2247, "end_line": 2250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_and", "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2253, "end_line": 2256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_or", "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2259, "end_line": 2262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_bitwise_xor", "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2265, "end_line": 2268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_floor_divide", "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2271, "end_line": 2274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_TRUE_divide", "long_name": "array_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2277, "end_line": 2280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_inplace_floor_divide", "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2283, "end_line": 2287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_inplace_TRUE_divide", "long_name": "array_inplace_TRUE_divide( PyArrayObject * m1 , PyObject * m2)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "m1", "m2" ], "start_line": 2290, "end_line": 2294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_all_nonzero", "long_name": "array_all_nonzero( PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 93, "parameters": [ "mp" ], "start_line": 2298, "end_line": 2316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "array_divmod", "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 89, "parameters": [ "op1", "op2" ], "start_line": 2319, "end_line": 2334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "array_int", "long_name": "array_int( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2338, "end_line": 2364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "array_float", "long_name": "array_float( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 143, "parameters": [ "v" ], "start_line": 2367, "end_line": 2392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_long", "long_name": "array_long( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2395, "end_line": 2417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_oct", "long_name": "array_oct( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2420, "end_line": 2442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_hex", "long_name": "array_hex( PyArrayObject * v)", "filename": "arrayobject.c", "nloc": 23, "complexity": 4, "token_count": 124, "parameters": [ "v" ], "start_line": 2445, "end_line": 2467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "_array_copy_nice", "long_name": "_array_copy_nice( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 2470, "end_line": 2474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "array_slice", "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", "filename": "arrayobject.c", "nloc": 34, "complexity": 11, "token_count": 254, "parameters": [ "self", "ilow", "ihigh" ], "start_line": 2535, "end_line": 2573, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "array_ass_slice", "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", "filename": "arrayobject.c", "nloc": 20, "complexity": 4, "token_count": 108, "parameters": [ "self", "ilow", "ihigh", "v" ], "start_line": 2577, "end_line": 2598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_contains", "long_name": "array_contains( PyArrayObject * self , PyObject * el)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self", "el" ], "start_line": 2601, "end_line": 2606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dump_data", "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 41, "complexity": 7, "token_count": 308, "parameters": [ "string", "n", "max_n", "data", "nd", "dimensions", "strides", "self" ], "start_line": 2627, "end_line": 2674, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "array_repr_builtin", "long_name": "array_repr_builtin( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 30, "complexity": 4, "token_count": 222, "parameters": [ "self" ], "start_line": 2677, "end_line": 2713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_SetStringFunction", "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 48, "parameters": [ "op", "repr" ], "start_line": 2719, "end_line": 2736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_repr", "long_name": "array_repr( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2739, "end_line": 2751, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_str", "long_name": "array_str( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 12, "complexity": 2, "token_count": 59, "parameters": [ "self" ], "start_line": 2754, "end_line": 2766, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "array_richcompare", "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 13, "token_count": 273, "parameters": [ "self", "other", "cmp_op" ], "start_line": 2770, "end_line": 2847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 78, "top_nesting_level": 0 }, { "name": "_check_axis", "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", "filename": "arrayobject.c", "nloc": 29, "complexity": 8, "token_count": 164, "parameters": [ "arr", "axis", "flags" ], "start_line": 2850, "end_line": 2879, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyArray_IntTupleFromIntp", "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", "filename": "arrayobject.c", "nloc": 17, "complexity": 4, "token_count": 91, "parameters": [ "len", "vals" ], "start_line": 2885, "end_line": 2901, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_IntpFromSequence", "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", "filename": "arrayobject.c", "nloc": 21, "complexity": 7, "token_count": 161, "parameters": [ "seq", "vals", "maxvals" ], "start_line": 2906, "end_line": 2929, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "_IsContiguous", "long_name": "_IsContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 109, "parameters": [ "ap" ], "start_line": 2935, "end_line": 2951, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsFortranContiguous", "long_name": "_IsFortranContiguous( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 6, "token_count": 107, "parameters": [ "ap" ], "start_line": 2955, "end_line": 2971, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsAligned", "long_name": "_IsAligned( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 110, "parameters": [ "ap" ], "start_line": 2975, "end_line": 2991, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "_IsWriteable", "long_name": "_IsWriteable( PyArrayObject * ap)", "filename": "arrayobject.c", "nloc": 16, "complexity": 8, "token_count": 109, "parameters": [ "ap" ], "start_line": 2994, "end_line": 3027, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "PyArray_UpdateFlags", "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", "filename": "arrayobject.c", "nloc": 22, "complexity": 9, "token_count": 129, "parameters": [ "ret", "flagmask" ], "start_line": 3031, "end_line": 3053, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "PyArray_CheckStrides", "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", "filename": "arrayobject.c", "nloc": 13, "complexity": 4, "token_count": 84, "parameters": [ "elsize", "nd", "numbytes", "dims", "newstrides" ], "start_line": 3060, "end_line": 3075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_array_fill_strides", "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 171, "parameters": [ "strides", "dims", "nd", "itemsize", "inflag", "objflags" ], "start_line": 3095, "end_line": 3119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_New", "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , char * data , int itemsize , int flags , PyArrayObject * obj)", "filename": "arrayobject.c", "nloc": 112, "complexity": 28, "token_count": 676, "parameters": [ "subtype", "nd", "dims", "type_num", "strides", "data", "itemsize", "flags", "obj" ], "start_line": 3123, "end_line": 3267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 145, "top_nesting_level": 0 }, { "name": "PyArray_Resize", "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", "filename": "arrayobject.c", "nloc": 87, "complexity": 15, "token_count": 501, "parameters": [ "self", "newshape" ], "start_line": 3272, "end_line": 3377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "PyArray_FillObjectArray", "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", "filename": "arrayobject.c", "nloc": 18, "complexity": 4, "token_count": 98, "parameters": [ "arr", "obj" ], "start_line": 3381, "end_line": 3398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "array_new", "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 100, "complexity": 20, "token_count": 593, "parameters": [ "subtype", "args", "kwds" ], "start_line": 3402, "end_line": 3517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "array_ndim_get", "long_name": "array_ndim_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 3524, "end_line": 3527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flags_get", "long_name": "array_flags_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 3530, "end_line": 3540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_shape_get", "long_name": "array_shape_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3613, "end_line": 3616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_shape_set", "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 33, "complexity": 6, "token_count": 206, "parameters": [ "self", "val" ], "start_line": 3620, "end_line": 3654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "array_strides_get", "long_name": "array_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 3658, "end_line": 3661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_strides_set", "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", "filename": "arrayobject.c", "nloc": 32, "complexity": 7, "token_count": 209, "parameters": [ "self", "obj" ], "start_line": 3664, "end_line": 3697, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_protocol_strides_get", "long_name": "array_protocol_strides_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 3701, "end_line": 3708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_priority_get", "long_name": "array_priority_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 9, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 3711, "end_line": 3719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "array_data_get", "long_name": "array_data_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 15, "complexity": 3, "token_count": 82, "parameters": [ "self" ], "start_line": 3723, "end_line": 3737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "array_data_set", "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 44, "complexity": 9, "token_count": 229, "parameters": [ "self", "op" ], "start_line": 3740, "end_line": 3784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "array_itemsize_get", "long_name": "array_itemsize_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 3788, "end_line": 3791, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_size_get", "long_name": "array_size_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "self" ], "start_line": 3794, "end_line": 3801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typechar_get", "long_name": "array_typechar_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 3805, "end_line": 3812, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "array_typestr_get", "long_name": "array_typestr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 7, "token_count": 141, "parameters": [ "self" ], "start_line": 3815, "end_line": 3835, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "array_descr_get", "long_name": "array_descr_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 128, "parameters": [ "self" ], "start_line": 3838, "end_line": 3860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "array_typenum_get", "long_name": "array_typenum_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 3863, "end_line": 3866, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_get", "long_name": "array_type_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 3870, "end_line": 3873, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_type_set", "long_name": "array_type_set( PyArrayObject * self , PyObject * arg)", "filename": "arrayobject.c", "nloc": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "arg" ], "start_line": 3885, "end_line": 3943, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "array_base_get", "long_name": "array_base_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 11, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 3948, "end_line": 3958, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "array_real_get", "long_name": "array_real_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 25, "complexity": 3, "token_count": 125, "parameters": [ "self" ], "start_line": 3962, "end_line": 3987, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "array_real_set", "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 31, "complexity": 4, "token_count": 173, "parameters": [ "self", "val" ], "start_line": 3991, "end_line": 4023, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "array_imag_get", "long_name": "array_imag_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 33, "complexity": 3, "token_count": 186, "parameters": [ "self" ], "start_line": 4026, "end_line": 4059, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "array_imag_set", "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 37, "complexity": 4, "token_count": 199, "parameters": [ "self", "val" ], "start_line": 4062, "end_line": 4099, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "array_flat_get", "long_name": "array_flat_get( PyArrayObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 4102, "end_line": 4105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "array_flat_set", "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", "filename": "arrayobject.c", "nloc": 50, "complexity": 9, "token_count": 358, "parameters": [ "self", "val" ], "start_line": 4108, "end_line": 4160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "discover_depth", "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", "filename": "arrayobject.c", "nloc": 23, "complexity": 14, "token_count": 169, "parameters": [ "s", "max", "stop_at_string" ], "start_line": 4336, "end_line": 4361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "discover_itemsize", "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", "filename": "arrayobject.c", "nloc": 21, "complexity": 9, "token_count": 161, "parameters": [ "s", "nd", "itemsize" ], "start_line": 4364, "end_line": 4386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "discover_dimensions", "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", "filename": "arrayobject.c", "nloc": 24, "complexity": 10, "token_count": 188, "parameters": [ "s", "nd", "d", "check_it" ], "start_line": 4393, "end_line": 4419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_array_small_type", "long_name": "_array_small_type( int chktype , int mintype , int chksize , int minsize , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 19, "complexity": 5, "token_count": 100, "parameters": [ "chktype", "mintype", "chksize", "minsize", "outtype" ], "start_line": 4422, "end_line": 4442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_array_find_type", "long_name": "_array_find_type( PyObject * op , PyArray_Typecode * minitype , PyArray_Typecode * outtype , int max)", "filename": "arrayobject.c", "nloc": 123, "complexity": 28, "token_count": 661, "parameters": [ "op", "minitype", "outtype", "max" ], "start_line": 4445, "end_line": 4583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "Assign_Array", "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", "filename": "arrayobject.c", "nloc": 21, "complexity": 6, "token_count": 121, "parameters": [ "self", "v" ], "start_line": 4586, "end_line": 4609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromScalar", "long_name": "Array_FromScalar( PyObject * op , PyArray_Typecode * typecode)", "filename": "arrayobject.c", "nloc": 19, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode" ], "start_line": 4613, "end_line": 4636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "Array_FromSequence", "long_name": "Array_FromSequence( PyObject * s , PyArray_Typecode * typecode , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 51, "complexity": 17, "token_count": 313, "parameters": [ "s", "typecode", "min_depth", "max_depth" ], "start_line": 4640, "end_line": 4697, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 }, { "name": "PyArray_ValidType", "long_name": "PyArray_ValidType( int type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 2, "token_count": 30, "parameters": [ "type" ], "start_line": 4701, "end_line": 4708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_bufferedcast", "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", "filename": "arrayobject.c", "nloc": 75, "complexity": 16, "token_count": 477, "parameters": [ "out", "in" ], "start_line": 4714, "end_line": 4804, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "PyArray_Cast", "long_name": "PyArray_Cast( PyArrayObject * mp , int type_num)", "filename": "arrayobject.c", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "mp", "type_num" ], "start_line": 4810, "end_line": 4821, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyArray_CastToType", "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Typecode * at)", "filename": "arrayobject.c", "nloc": 31, "complexity": 13, "token_count": 229, "parameters": [ "mp", "at" ], "start_line": 4824, "end_line": 4859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "PyArray_CastTo", "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", "filename": "arrayobject.c", "nloc": 40, "complexity": 10, "token_count": 214, "parameters": [ "out", "mp" ], "start_line": 4866, "end_line": 4912, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "array_fromarray", "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 77, "complexity": 26, "token_count": 508, "parameters": [ "arr", "typecode", "flags" ], "start_line": 4915, "end_line": 5005, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 91, "top_nesting_level": 0 }, { "name": "_array_typecode_fromstr", "long_name": "_array_typecode_fromstr( char * str , int * swap , PyArray_Typecode * type)", "filename": "arrayobject.c", "nloc": 94, "complexity": 36, "token_count": 533, "parameters": [ "str", "swap", "type" ], "start_line": 5009, "end_line": 5114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 106, "top_nesting_level": 0 }, { "name": "array_frominterface", "long_name": "array_frominterface( PyObject * input , PyArray_Typecode * intype , int flags)", "filename": "arrayobject.c", "nloc": 82, "complexity": 18, "token_count": 549, "parameters": [ "input", "intype", "flags" ], "start_line": 5117, "end_line": 5211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "array_fromattr", "long_name": "array_fromattr( PyObject * op , PyArray_Typecode * typecode , int flags)", "filename": "arrayobject.c", "nloc": 21, "complexity": 4, "token_count": 120, "parameters": [ "op", "typecode", "flags" ], "start_line": 5214, "end_line": 5235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "array_fromobject", "long_name": "array_fromobject( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int flags)", "filename": "arrayobject.c", "nloc": 46, "complexity": 13, "token_count": 270, "parameters": [ "op", "typecode", "min_depth", "max_depth", "flags" ], "start_line": 5239, "end_line": 5301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "PyArray_ArrayType", "long_name": "PyArray_ArrayType( PyObject * op , PyArray_Typecode * intype , PyArray_Typecode * outtype)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "op", "intype", "outtype" ], "start_line": 5304, "end_line": 5309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ObjectType", "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "op", "minimum_type" ], "start_line": 5312, "end_line": 5318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_FromAny", "long_name": "PyArray_FromAny( PyObject * op , PyArray_Typecode * typecode , int min_depth , int max_depth , int requires)", "filename": "arrayobject.c", "nloc": 24, "complexity": 9, "token_count": 165, "parameters": [ "op", "typecode", "min_depth", "max_depth", "requires" ], "start_line": 5372, "end_line": 5402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "PyArray_EnsureArray", "long_name": "PyArray_EnsureArray( PyObject * op)", "filename": "arrayobject.c", "nloc": 14, "complexity": 4, "token_count": 82, "parameters": [ "op" ], "start_line": 5412, "end_line": 5428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "PyArray_FromObject", "long_name": "PyArray_FromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5434, "end_line": 5439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PyArray_ContiguousFromObject", "long_name": "PyArray_ContiguousFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5442, "end_line": 5448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CopyFromObject", "long_name": "PyArray_CopyFromObject( PyObject * op , int type , int min_depth , int max_depth)", "filename": "arrayobject.c", "nloc": 7, "complexity": 1, "token_count": 43, "parameters": [ "op", "type", "min_depth", "max_depth" ], "start_line": 5451, "end_line": 5457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PyArray_CanCastSafely", "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", "filename": "arrayobject.c", "nloc": 69, "complexity": 35, "token_count": 386, "parameters": [ "fromtype", "totype" ], "start_line": 5463, "end_line": 5534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyArray_CanCastTo", "long_name": "PyArray_CanCastTo( PyArray_Typecode * from , PyArray_Typecode * to)", "filename": "arrayobject.c", "nloc": 24, "complexity": 7, "token_count": 134, "parameters": [ "from", "to" ], "start_line": 5537, "end_line": 5561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "PyArray_IterNew", "long_name": "PyArray_IterNew( PyObject * obj)", "filename": "arrayobject.c", "nloc": 34, "complexity": 6, "token_count": 258, "parameters": [ "obj" ], "start_line": 5571, "end_line": 5608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "arrayiter_next", "long_name": "arrayiter_next( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "it" ], "start_line": 5613, "end_line": 5623, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "arrayiter_dealloc", "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", "filename": "arrayobject.c", "nloc": 6, "complexity": 1, "token_count": 25, "parameters": [ "it" ], "start_line": 5626, "end_line": 5631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "arrayiter_traverse", "long_name": "arrayiter_traverse( PyArrayIterObject * it , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "it", "visit", "arg" ], "start_line": 5634, "end_line": 5639, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iter_length", "long_name": "iter_length( PyArrayIterObject * self)", "filename": "arrayobject.c", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 5643, "end_line": 5646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "iter_subscript_Bool", "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 42, "complexity": 7, "token_count": 268, "parameters": [ "self", "ind" ], "start_line": 5650, "end_line": 5698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "iter_subscript_int", "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", "filename": "arrayobject.c", "nloc": 50, "complexity": 8, "token_count": 337, "parameters": [ "self", "ind" ], "start_line": 5701, "end_line": 5753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "iter_subscript", "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", "filename": "arrayobject.c", "nloc": 97, "complexity": 20, "token_count": 585, "parameters": [ "self", "ind" ], "start_line": 5757, "end_line": 5876, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 0 }, { "name": "iter_ass_sub_Bool", "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 31, "complexity": 5, "token_count": 176, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5880, "end_line": 5912, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "iter_ass_sub_int", "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", "filename": "arrayobject.c", "nloc": 41, "complexity": 8, "token_count": 283, "parameters": [ "self", "ind", "val", "swap" ], "start_line": 5915, "end_line": 5956, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_ass_subscript", "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", "filename": "arrayobject.c", "nloc": 103, "complexity": 24, "token_count": 636, "parameters": [ "self", "ind", "val" ], "start_line": 5960, "end_line": 6082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "iter_array", "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", "filename": "arrayobject.c", "nloc": 29, "complexity": 5, "token_count": 213, "parameters": [ "it", "op" ], "start_line": 6095, "end_line": 6136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "iter_copy", "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", "filename": "arrayobject.c", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "it", "args" ], "start_line": 6141, "end_line": 6145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "fancy_indexing_check", "long_name": "fancy_indexing_check( PyObject * args)", "filename": "arrayobject.c", "nloc": 55, "complexity": 22, "token_count": 293, "parameters": [ "args" ], "start_line": 6210, "end_line": 6271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 0 }, { "name": "_convert_obj", "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", "filename": "arrayobject.c", "nloc": 15, "complexity": 5, "token_count": 105, "parameters": [ "obj", "iter" ], "start_line": 6279, "end_line": 6294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyArray_Broadcast", "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", "filename": "arrayobject.c", "nloc": 58, "complexity": 13, "token_count": 464, "parameters": [ "mit" ], "start_line": 6300, "end_line": 6369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterReset", "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 35, "complexity": 4, "token_count": 261, "parameters": [ "mit" ], "start_line": 6373, "end_line": 6409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNext", "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 41, "complexity": 6, "token_count": 296, "parameters": [ "mit" ], "start_line": 6415, "end_line": 6459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "PyArray_MapIterBind", "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", "filename": "arrayobject.c", "nloc": 102, "complexity": 22, "token_count": 682, "parameters": [ "mit", "arr" ], "start_line": 6477, "end_line": 6613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 137, "top_nesting_level": 0 }, { "name": "_nonzero_indices", "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", "filename": "arrayobject.c", "nloc": 57, "complexity": 15, "token_count": 454, "parameters": [ "myBool", "iters" ], "start_line": 6619, "end_line": 6688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyArray_MapIterNew", "long_name": "PyArray_MapIterNew( PyObject * indexobj)", "filename": "arrayobject.c", "nloc": 111, "complexity": 24, "token_count": 745, "parameters": [ "indexobj" ], "start_line": 6691, "end_line": 6824, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 0 }, { "name": "arraymapiter_new", "long_name": "arraymapiter_new( PyTypeObject * type , PyObject * args , PyObject * kwds)", "filename": "arrayobject.c", "nloc": 26, "complexity": 5, "token_count": 130, "parameters": [ "type", "args", "kwds" ], "start_line": 6830, "end_line": 6860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "arraymapiter_next", "long_name": "arraymapiter_next( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 12, "complexity": 4, "token_count": 70, "parameters": [ "mit" ], "start_line": 6866, "end_line": 6877, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "arraymapiter_dealloc", "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", "filename": "arrayobject.c", "nloc": 10, "complexity": 2, "token_count": 60, "parameters": [ "mit" ], "start_line": 6880, "end_line": 6889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "arraymapiter_traverse", "long_name": "arraymapiter_traverse( PyArrayMapIterObject * mit , visitproc visit , * arg)", "filename": "arrayobject.c", "nloc": 16, "complexity": 9, "token_count": 146, "parameters": [ "mit", "visit", "arg" ], "start_line": 6892, "end_line": 6910, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "array_subscript", "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", "filename": "arrayobject.c", "nloc": 61, "complexity": 19, "token_count": 421, "parameters": [ "self", "op" ], "start_line": 1664, "end_line": 1739, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 76, "top_nesting_level": 0 } ], "nloc": 5474, "complexity": 1204, "token_count": 32706, "diff_parsed": { "added": [ " else if (value >= 0) {", " if (value <= MAX_INT)", " return array_item(self, (int) value);", " }", " else if (value < 0) {", " if (value >= -MAX_INT) {", " if (self->nd > 0) value += self->dimensions[0];", " return array_item(self, (int) value);", " }", " }" ], "deleted": [ " else if ((value <= MAX_INT) || (value >= -MAX_INT))", " return array_item(self, (int) value);" ] } }, { "old_path": "scipy/base/src/ufuncobject.c", "new_path": "scipy/base/src/ufuncobject.c", "filename": "ufuncobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -990,6 +990,7 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \n loop->bufcnt = 0;\n \n+ loop->obj = 0;\n \n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n@@ -1018,6 +1019,8 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n+ if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT)\n+ loop->obj = 1;\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n@@ -1268,10 +1271,12 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \tPyUFuncLoopObject *loop;\n \tint i;\n \tint temp;\n+ BEGIN_THREADS_DEF\n \n \tif (!(loop = construct_loop(self, args, mps))) return -1;\n \n-\tBEGIN_THREADS\n+ if (!loop->obj)\n+ BEGIN_THREADS\n \n \tswitch(loop->meth) {\n \tcase ONE_UFUNCLOOP:\n@@ -1308,7 +1313,9 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\t/* Make local copies of all loop variables */\n \t\t/* Optimizations needed:\n \t\t 1) move data better into the buffer better\n-\t\t --- not one at a time. \n+\t\t --- not one at a time -- this requires some \n+ pre-analysis and is only possible over \n+ the largest dimension.\n \t\t*/\n \n \t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n@@ -1327,7 +1334,8 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t\tfor (i=0; inargs; i++) {\n \t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n \t\t\tmpselsize[i] = mps[i]->itemsize;\n-\t\t\tpyobject[i] = (mps[i]->descr->type_num == PyArray_OBJECT);\n+\t\t\tpyobject[i] = (loop->obj && \\\n+ (mps[i]->descr->type_num == PyArray_OBJECT));\n \t\t}\n \t\t/* Do generic buffered looping here (works for any kind of\n \t\t arrays): Everything uses a buffer. \n@@ -1419,14 +1427,14 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args,\n \t}\n \t}\t\n \t\n-\tEND_THREADS\n+ LOOP_END_THREADS\n \t\n Py_DECREF(loop);\n \treturn 0;\n \n fail:\n-\tEND_THREADS_FAIL\n-\n+ LOOP_END_THREADS\n+ \n \tPy_XDECREF(loop);\n \treturn -1;\n }\n@@ -1709,6 +1717,12 @@ construct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis,\n \t\t\t\t\t\t Py_None));\n \tif (loop->errobj == NULL) goto fail;\n \n+ /* Determine if object arrays are involved */\n+ if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n+ loop->obj = 1;\n+ else\n+ loop->obj = 0;\n+\n \tPyUFunc_clearfperr();\n \treturn loop;\n \n@@ -1733,13 +1747,14 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n+ BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n \t\t\t\t\"reduce\");\n \tif (!loop) return NULL;\n \n-\tBEGIN_THREADS\n+ LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n \t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n@@ -1843,7 +1858,7 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n }\n }\n \n-\tEND_THREADS\n+ LOOP_END_THREADS\n \n ret = loop->ret;\n \t/* Hang on to this reference -- will be decref'd with loop */\n@@ -1852,7 +1867,7 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n return (PyObject *)ret;\n \n fail:\n-\tEND_THREADS_FAIL\n+ LOOP_END_THREADS\n \n Py_XDECREF(loop);\n return NULL;\n@@ -1873,7 +1888,7 @@ PyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis,\n \t\t\t\t\"accumulate\");\n \tif (!loop) return NULL;\n \n-\tBEGIN_THREADS\n+\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n \t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n@@ -1978,7 +1993,7 @@ PyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis,\n }\n }\n \n-\tEND_THREADS\n+\tLOOP_END_THREADS\n ret = loop->ret;\n \t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n@@ -1986,7 +2001,7 @@ PyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis,\n return (PyObject *)ret;\n \n fail:\n-\tEND_THREADS_FAIL\n+\tLOOP_END_THREADS\n \n Py_XDECREF(loop);\n return NULL;\n@@ -2040,7 +2055,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind,\n \t\t\t\t\"reduceat\");\n \tif (!loop) return NULL;\n \n-\tBEGIN_THREADS\n+\tLOOP_BEGIN_THREADS\n \tswitch(loop->meth) {\n \t/* zero-length index -- return array immediately */\n \tcase ZERODIM_REDUCELOOP:\n@@ -2126,7 +2141,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind,\n \t\tbreak;\n \t}\n \n-\tEND_THREADS\n+\tLOOP_END_THREADS\n \t\n ret = loop->ret;\n \t/* Hang on to this reference -- will be decref'd with loop */\n@@ -2135,7 +2150,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind,\n return (PyObject *)ret;\n \t\n fail:\n-\tEND_THREADS_FAIL\n+\tLOOP_END_THREADS\n \n \tPy_XDECREF(loop);\n \treturn NULL;\n", "added_lines": 30, "deleted_lines": 15, "source_code": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n\t\t\tatype.type_num = arg_types[i];\n\t\t\tatype.itemsize = \\\n\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\tif (loop->size < loop->bufsize) {\n\t\t\t\tPyObject *new;\n\t\t\t\t/* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t*/\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | \n\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n\t\t\t\t\t\t UPDATEIFCOPY);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n loop->obj = 0;\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\tcntcast += descr->elsize;\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n BEGIN_THREADS_DEF\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n if (!loop->obj)\n BEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time -- this requires some \n pre-analysis and is only possible over \n the largest dimension.\n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tBool pyobject[MAX_ARGS];\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t\tpyobject[i] = (loop->obj && \\\n (mps[i]->descr->type_num == PyArray_OBJECT));\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t\tfprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t\titers[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t}\n\t\t\t\t/*\t\t\t\tfprintf(stderr, \"index = %d, i=%d, writing to %p\\n\", index, i, dptr[i]); */\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping...\\n\");*/\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping back...\\n\"); */\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\t/* fprintf(stderr, \"temp=%d, i=%d; reading from %p\\n\", temp, i, dptr[i]);*/\n\t\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t\t\t\tPy_INCREF(*((PyObject **)dptr[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = buffer[i];\n\t\t\t\t\n\t\t\t} \n\t\t}\n\t}\n\t}\t\n\t\n LOOP_END_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n LOOP_END_THREADS\n \n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n /* Determine if object arrays are involved */\n if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n else\n loop->obj = 0;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n LOOP_END_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n LOOP_END_THREADS\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tLOOP_END_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tLOOP_END_THREADS\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tLOOP_END_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tLOOP_END_THREADS\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n\t\t\tatype.type_num = arg_types[i];\n\t\t\tatype.itemsize = \\\n\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\tif (loop->size < loop->bufsize) {\n\t\t\t\tPyObject *new;\n\t\t\t\t/* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t*/\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | \n\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n\t\t\t\t\t\t UPDATEIFCOPY);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\tcntcast += descr->elsize;\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tBEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time. \n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tBool pyobject[MAX_ARGS];\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t\tpyobject[i] = (mps[i]->descr->type_num == PyArray_OBJECT);\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t\tfprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t\titers[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t}\n\t\t\t\t/*\t\t\t\tfprintf(stderr, \"index = %d, i=%d, writing to %p\\n\", index, i, dptr[i]); */\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping...\\n\");*/\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping back...\\n\"); */\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\t/* fprintf(stderr, \"temp=%d, i=%d; reading from %p\\n\", temp, i, dptr[i]);*/\n\t\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t\t\t\tPy_INCREF(*((PyObject **)dptr[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = buffer[i];\n\t\t\t\t\n\t\t\t} \n\t\t}\n\t}\n\t}\t\n\t\n\tEND_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n\tEND_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tEND_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tEND_THREADS_FAIL\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tBEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tEND_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tEND_THREADS_FAIL\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "methods": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 246, "complexity": 59, "token_count": 1912, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 343, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1151, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 118, "complexity": 25, "token_count": 845, "parameters": [ "self", "args", "mps" ], "start_line": 1268, "end_line": 1440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 173, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1443, "end_line": 1463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1466, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 191, "complexity": 38, "token_count": 1408, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1497, "end_line": 1732, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 236, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 100, "complexity": 16, "token_count": 660, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1744, "end_line": 1874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1878, "end_line": 2008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 2030, "end_line": 2157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2166, "end_line": 2276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2283, "end_line": 2335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2338, "end_line": 2403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2411, "end_line": 2480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2484, "end_line": 2515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2518, "end_line": 2559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2562, "end_line": 2574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2577, "end_line": 2589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2593, "end_line": 2599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2602, "end_line": 2609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2621, "end_line": 2690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2694, "end_line": 2698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2701, "end_line": 2705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2708, "end_line": 2711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2731, "end_line": 2753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2758, "end_line": 2841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2846, "end_line": 2849, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 243, "complexity": 57, "token_count": 1882, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 340, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1148, "end_line": 1197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 115, "complexity": 23, "token_count": 830, "parameters": [ "self", "args", "mps" ], "start_line": 1265, "end_line": 1432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 168, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1435, "end_line": 1455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1458, "end_line": 1480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 187, "complexity": 36, "token_count": 1381, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1489, "end_line": 1718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 230, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 99, "complexity": 16, "token_count": 659, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1730, "end_line": 1859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 130, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1863, "end_line": 1993, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 2015, "end_line": 2142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2151, "end_line": 2261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2268, "end_line": 2320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2323, "end_line": 2388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2396, "end_line": 2465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2469, "end_line": 2500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2503, "end_line": 2544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2547, "end_line": 2559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2562, "end_line": 2574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2578, "end_line": 2584, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2587, "end_line": 2594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2606, "end_line": 2675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2679, "end_line": 2683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2686, "end_line": 2690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2693, "end_line": 2696, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2716, "end_line": 2738, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2743, "end_line": 2826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2831, "end_line": 2834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 246, "complexity": 59, "token_count": 1912, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 343, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1878, "end_line": 2008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 100, "complexity": 16, "token_count": 660, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1744, "end_line": 1874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 2030, "end_line": 2157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 191, "complexity": 38, "token_count": 1408, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1497, "end_line": 1732, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 236, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 118, "complexity": 25, "token_count": 845, "parameters": [ "self", "args", "mps" ], "start_line": 1268, "end_line": 1440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 173, "top_nesting_level": 0 } ], "nloc": 2134, "complexity": 439, "token_count": 15648, "diff_parsed": { "added": [ " loop->obj = 0;", " if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT)", " loop->obj = 1;", " BEGIN_THREADS_DEF", " if (!loop->obj)", " BEGIN_THREADS", "\t\t --- not one at a time -- this requires some", " pre-analysis and is only possible over", " the largest dimension.", "\t\t\tpyobject[i] = (loop->obj && \\", " (mps[i]->descr->type_num == PyArray_OBJECT));", " LOOP_END_THREADS", " LOOP_END_THREADS", "", " /* Determine if object arrays are involved */", " if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)", " loop->obj = 1;", " else", " loop->obj = 0;", "", " BEGIN_THREADS_DEF", " LOOP_BEGIN_THREADS", " LOOP_END_THREADS", " LOOP_END_THREADS", "\tLOOP_BEGIN_THREADS", "\tLOOP_END_THREADS", "\tLOOP_END_THREADS", "\tLOOP_BEGIN_THREADS", "\tLOOP_END_THREADS", "\tLOOP_END_THREADS" ], "deleted": [ "\tBEGIN_THREADS", "\t\t --- not one at a time.", "\t\t\tpyobject[i] = (mps[i]->descr->type_num == PyArray_OBJECT);", "\tEND_THREADS", "\tEND_THREADS_FAIL", "", "\tBEGIN_THREADS", "\tEND_THREADS", "\tEND_THREADS_FAIL", "\tBEGIN_THREADS", "\tEND_THREADS", "\tEND_THREADS_FAIL", "\tBEGIN_THREADS", "\tEND_THREADS", "\tEND_THREADS_FAIL" ] } } ] }, { "hash": "0a8d3a1020037f58846aa3851cad8097a9af1a09", "msg": "Fixed vectorize segfault...", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-07T02:45:16+00:00", "author_timezone": 0, "committer_date": "2005-10-07T02:45:16+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d52d900dc6551e59cd679365723ff8e1dd7dfd9e" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 15, "insertions": 18, "lines": 33, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy/base/src/ufuncobject.c", "new_path": "scipy/base/src/ufuncobject.c", "filename": "ufuncobject.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -351,7 +351,7 @@ PyUFunc_O_O_method(char **args, intp *dimensions, intp *steps, void *func)\n \n \n \n-/* a general-purpose ufunc that deals with general-purpose callable \n+/* a general-purpose ufunc that deals with general-purpose Python callable.\n func is a structure with nin, nout, and a Python callable function\n */\n \n@@ -359,6 +359,7 @@ static void\n PyUFunc_On_Om(char **args, intp *dimensions, intp *steps, void *func)\n {\n \tint i, j;\n+\tintp n=dimensions[0];\n PyUFunc_PyFuncData *data = (PyUFunc_PyFuncData *)func;\n int nin = data->nin, nout=data->nout;\n int ntot;\n@@ -370,8 +371,9 @@ PyUFunc_On_Om(char **args, intp *dimensions, intp *steps, void *func)\n ntot = nin+nout;\n \n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n-\tfor(i=0; i<*dimensions; i++) {\n- arglist = PyTuple_New(nin);\n+\tfor(i=0; iobj)\n- BEGIN_THREADS\n+\tLOOP_BEGIN_THREADS\n \n \tswitch(loop->meth) {\n \tcase ONE_UFUNCLOOP:\n@@ -2429,6 +2430,7 @@ ufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n \t\treturn NULL;\n \t\n \n+\tself->userloops = NULL;\n \tself->nin = nin;\n \tself->nout = nout;\n \tself->nargs = nin+nout;\n@@ -2450,10 +2452,11 @@ ufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n Py_XDECREF(pyname);\n \n \n- Py_INCREF(function);\n- self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n+\tif (self->ptr == NULL) return PyErr_NoMemory();\n+ Py_INCREF(function);\n+ self->obj = function;\n \tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n", "added_lines": 18, "deleted_lines": 15, "source_code": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\t\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n\t\t\tatype.type_num = arg_types[i];\n\t\t\tatype.itemsize = \\\n\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\tif (loop->size < loop->bufsize) {\n\t\t\t\tPyObject *new;\n\t\t\t\t/* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t*/\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | \n\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n\t\t\t\t\t\t UPDATEIFCOPY);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n loop->obj = 0;\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\tcntcast += descr->elsize;\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n BEGIN_THREADS_DEF\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n\tLOOP_BEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time -- this requires some \n pre-analysis and is only possible over \n the largest dimension.\n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tBool pyobject[MAX_ARGS];\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t\tpyobject[i] = (loop->obj && \\\n (mps[i]->descr->type_num == PyArray_OBJECT));\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t\tfprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t\titers[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t}\n\t\t\t\t/*\t\t\t\tfprintf(stderr, \"index = %d, i=%d, writing to %p\\n\", index, i, dptr[i]); */\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping...\\n\");*/\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping back...\\n\"); */\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\t/* fprintf(stderr, \"temp=%d, i=%d; reading from %p\\n\", temp, i, dptr[i]);*/\n\t\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t\t\t\tPy_INCREF(*((PyObject **)dptr[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = buffer[i];\n\t\t\t\t\n\t\t\t} \n\t\t}\n\t}\n\t}\t\n\t\n LOOP_END_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n LOOP_END_THREADS\n \n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n /* Determine if object arrays are involved */\n if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n else\n loop->obj = 0;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n LOOP_END_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n LOOP_END_THREADS\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tLOOP_END_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tLOOP_END_THREADS\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tLOOP_END_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tLOOP_END_THREADS\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->userloops = NULL;\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tif (self->ptr == NULL) return PyErr_NoMemory();\n Py_INCREF(function);\n self->obj = function;\n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tintp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i<*dimensions; i++) {\n arglist = PyTuple_New(nin);\n for (j=0; j < nin; j++) {\n in = *((PyObject **)ptrs[j]);\n if (in == NULL) {Py_DECREF(arglist); return;}\n PyTuple_SET_ITEM(arglist, j, in);\n Py_INCREF(in);\n } \n result = PyEval_CallObject(tocall, arglist);\n Py_DECREF(arglist);\n if (result == NULL) return;\n if PyTuple_Check(result) {\n if (nout != PyTuple_Size(result)) {\n Py_DECREF(result);\n return;\n }\n for (j=0; j < nout; j++) {\n op = (PyObject **)ptrs[j+nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = PyTuple_GET_ITEM(result, j);\n Py_INCREF(*op);\n }\n Py_DECREF(result);\n }\n else {\n op = (PyObject **)ptrs[nin];\n if (*op != NULL) {Py_DECREF(*op);}\n *op = result;\n\t\t}\n for (j=0; j < ntot; j++) ptrs[j] += steps[j];\n\t} \n\n}\n\n\n\n\n/* ---------------------------------------------------------------- */\n\n\n/* fpstatus is the ufunc_formatted hardware status \n errmask is the handling mask specified by the user.\n errobj is a Python object with (string, callable object or None)\n or NULL\n*/\n\n/*\n 2. for each of the flags \n determine whether to ignore, warn, raise error, or call Python function.\n If ignore, do nothing\n If warn, print a warning and continue\n If raise return an error\n If call, call a user-defined function with string\n*/\t \n\nstatic int\n_error_handler(int method, PyObject *errobj, char *errtype, int retstatus)\n{\n\tPyObject *pyfunc, *ret, *args;\n\tchar *name=PyString_AS_STRING(PyTuple_GET_ITEM(errobj,0));\n\tchar msg[100];\n\n\tALLOW_C_API_DEF\n\n\tALLOW_C_API\n\n\tswitch(method) {\n\tcase UFUNC_ERR_WARN:\n\t\tsnprintf(msg, 100, \"%s encountered in %s\", errtype, name);\n\t\tif (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;\n\t\tbreak;\n\tcase UFUNC_ERR_RAISE:\n\t\tPyErr_Format(PyExc_FloatingPointError, \n\t\t\t \"%s encountered in %s\",\n\t\t\t errtype, name);\n\t\tgoto fail;\n\tcase UFUNC_ERR_CALL:\n\t\tpyfunc = PyTuple_GET_ITEM(errobj, 1);\n\n\t\tif (pyfunc == Py_None) {\n\t\t\tPyErr_Format(PyExc_NameError, \n\t\t\t\t \"python callback specified for %s (in \" \\\n\t\t\t\t \" %s) but no function found.\", \n\t\t\t\t errtype, name);\n\t\t\tgoto fail;\n\t\t}\n\t\targs = Py_BuildValue(\"NN\", PyString_FromString(errtype), \n PyInt_FromLong((long) retstatus));\n\t\tif (args == NULL) goto fail;\n\t\tret = PyObject_CallObject(pyfunc, args);\n\t\tPy_DECREF(args);\n\t\tif (ret == NULL) goto fail;\n\t\tPy_DECREF(ret);\n\n\t\tbreak;\n\t}\n\tDISABLE_C_API\n\treturn 0;\n\n fail:\t\n\tDISABLE_C_API\n\treturn -1;\t\n}\n\n\nstatic int\nPyUFunc_checkfperr(int errmask, PyObject *errobj)\n{\n\tint retstatus;\n\tint handle;\n\n\t/* 1. check hardware flag --- this is platform dependent code */\n\n\tUFUNC_CHECK_STATUS(retstatus) /* no semicolon */\n\t\n\t/* End platform dependent code */\n\n#define HANDLEIT(NAME, str) {if (retstatus & UFUNC_FPE_##NAME) { \\\n\t\t\thandle = errmask & UFUNC_MASK_##NAME;\\\n\t\t\tif (handle && \\\n\t\t\t _error_handler(handle >> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\n#define UFUNC_REDUCE 0\n#define UFUNC_ACCUMULATE 1\n#define UFUNC_REDUCEAT 2\n#define UFUNC_OUTER 3\n\n\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion.\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\t\t\n\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\tif (key == NULL) return -1;\n\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\tif (obj == NULL) {\n\t\t\tPy_DECREF(key);\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type.\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n\t\tPy_DECREF(key);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n\t*data = self->data[i];\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\n\n\nstatic int\n_getintfromvar(char *str, int deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tint retval=deflt;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n thedict = PyEval_GetGlobals();\n ref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = (int) PyInt_AsLong(ref);\n if (ref == NULL || retval == -1) retval = deflt;\n PyErr_Clear();\n\treturn retval;\n}\n\nstatic PyObject *\n_getfuncfromvar(char *str, PyObject *deflt)\n{\n PyObject *thedict;\n PyObject *ref;\n\tPyObject *retval;\n\n thedict = PyEval_GetLocals();\n ref = PyDict_GetItemString(thedict, str);\n if (ref == NULL) {\n\t\tthedict = PyEval_GetGlobals();\n\t\tref = PyDict_GetItemString(thedict, str);\n }\n if (ref == NULL) {\n thedict = PyEval_GetBuiltins();\n ref = PyDict_GetItemString(thedict, str);\n\t}\n if (ref != NULL) retval = ref;\n\telse retval = deflt;\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s if provided must be callable\", str);\n\t\treturn NULL;\n\t}\n\tPy_INCREF(retval);\n\treturn retval;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\n\tfor (i=0; ielsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST |\t\\\n\t\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, cnt, cntcast, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"ufuncs do not support\"\t\\\n \" flexible arrays\");\n return -1;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n\t/* This is the buffer size in number of elements.*/\n loop->bufsize = _getintfromvar(UFUNC_BUFSIZE_NAME, PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \"The buffer size (%d) is not \" \\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Typecode ntype = {PyArray_NOTYPE, 0, 0};\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\tif (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\tPyArray_Typecode atype = {PyArray_NOTYPE, 0, 0};\n\t\t\tntype.type_num = PyArray_TYPE(mps[i]);\n\t\t\tntype.itemsize = PyArray_ITEMSIZE(mps[i]);\n\t\t\tatype.type_num = arg_types[i];\n\t\t\tatype.itemsize = \\\n\t\t\t\tPyArray_DescrFromType(arg_types[i])->elsize;\n\t\t\tif (PyArray_EquivalentTypes(&atype, &ntype)) {\n\t\t\t\targ_types[i] = PyArray_TYPE(mps[i]);\n\t\t\t}\n\t\t}\n\n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\tif (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\tif (loop->size < loop->bufsize) {\n\t\t\t\tPyObject *new;\n\t\t\t\t/* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t*/\n\t\t\t\tntype.type_num = arg_types[i];\n\t\t\t\tntype.itemsize = 0;\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | \n\t\t\t\t\t\t BEHAVED_FLAGS_RO |\n\t\t\t\t\t\t UPDATEIFCOPY);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n loop->obj = 0;\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tcnt = cntcast = 0; /* keeps track of bytes to allocate */\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tcnt += mps[i]->itemsize;\n if (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\tPyArray_Descr *descr;\n\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\tcntcast += descr->elsize;\n if (i < self->nin) {\n loop->cast[i] = \\\n\t\t\t\t\tmps[i]->descr->cast[arg_types[i]];\n\t\t\t}\n else {\n loop->cast[i] = descr->\\\n\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t}\n\n }\n loop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n if (!PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n }\n if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth == NOBUFFER_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n }\n else if (loop->meth == BUFFER_UFUNCLOOP) {\n for (i=0; inargs; i++) {\n\t\t\tloop->steps[i] = mps[i]->itemsize; \n\t\t}\n }\n\telse { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (mps[i]->nd == 0)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse \n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tchar *castptr;\n\t\tint oldsize=0;\n\t\tloop->buffer[0] = (char *)malloc(loop->bufsize*(cnt+cntcast));\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\t\tif (loop->buffer[0] == NULL) return -1;\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt;\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (i > 0)\n\t\t\t\tloop->buffer[i] = loop->buffer[i-1] + \\\n\t\t\t\t\tloop->bufsize * mps[i-1]->itemsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tloop->castbuf[i] = castptr + \n\t\t\t\t\tloop->bufsize*oldsize;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n#define _PyD PyArray_DescrFromType\n\t\t\t\toldsize = _PyD(arg_types[i])->elsize;\n#undef _PyD\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\tloop->dptr[i] = loop->buffer[i];\n\t\t}\n\t}\n\n return nargs;\n}\n\nstatic PyTypeObject PyUFuncLoop_Type;\n\nstatic void ufuncloop_dealloc(PyUFuncLoopObject *);\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n\n\tif ((loop=PyObject_NEW(PyUFuncLoopObject, &PyUFuncLoop_Type)) == NULL)\n\t\treturn NULL;\n\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString((self->name ? \\\n self->name : \"\")), \n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n\tufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n something besides NULL, NULL \n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\tint temp;\n BEGIN_THREADS_DEF\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n\n if (!loop->obj)\n BEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /* fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR();\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /* fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\t/* Make local copies of all loop variables */\n\t\t/* Optimizations needed:\n\t\t 1) move data better into the buffer better\n\t\t --- not one at a time -- this requires some \n pre-analysis and is only possible over \n the largest dimension.\n\t\t*/\n\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufcnt=loop->bufcnt, bufsize=loop->bufsize;\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tBool pyobject[MAX_ARGS];\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->itemsize;\n\t\t\tpyobject[i] = (loop->obj && \\\n (mps[i]->descr->type_num == PyArray_OBJECT));\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays): Everything uses a buffer. \n\n\t\t 1. fill the input buffers.\n\t\t 2. If buffer is filled then \n\t\t a. cast any input buffers needing it. \n\t\t b. call inner function (which loops over the buffer).\n\t\t\t c. cast any output buffers needing it.\n\t\t\t d. copy output buffer back to output arrays.\n 3. goto next position\n\t\t*/ \n\t\tfprintf(stderr, \"BUFFER...%d\\n\", loop->size);\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t\tfprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t\titers[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\t\twhile (index < size) {\n\t\t\t/*copy input data */\n\t\t\tfor (i=0; inin; i++) {\n\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t}\n\t\t\t\t/*\t\t\t\tfprintf(stderr, \"index = %d, i=%d, writing to %p\\n\", index, i, dptr[i]); */\n\t\t\t\tmemcpy(dptr[i], iters[i]->dataptr,\n\t\t\t\t mpselsize[i]);\n\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t}\n\t\t\tbufcnt++;\n\t\t\tindex++; \n\t\t\tif ((bufcnt == bufsize) || \\\n\t\t\t (index == size)) {\n\t\t\t\t\n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping...\\n\");*/\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\tloop->function((char **)bufptr, \n\t\t\t\t\t &bufcnt, \n\t\t\t\t\t steps, loop->funcdata);\n \n\t\t\t\tUFUNC_CHECK_ERROR();\n\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t bufcnt,\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\t/* fprintf(stderr, \"swapping back...\\n\"); */\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t bufcnt, 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (temp = 0; temp < bufcnt; temp++) {\n\t\t\t\t\t\t/* fprintf(stderr, \"temp=%d, i=%d; reading from %p\\n\", temp, i, dptr[i]);*/\n\t\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)iters[i]->dataptr));\n\t\t\t\t\t\t\tPy_INCREF(*((PyObject **)dptr[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(iters[i]->dataptr,\n\t\t\t\t\t\t dptr[i], mpselsize[i]);\n\t\t\t\t\t\tPyArray_ITER_NEXT(iters[i]);\n\t\t\t\t\t\tdptr[i] += mpselsize[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbufcnt = 0;\n\t\t\t\tfor (i=0; inargs; i++) \n\t\t\t\t\tdptr[i] = buffer[i];\n\t\t\t\t\n\t\t\t} \n\t\t}\n\t}\n\t}\t\n\t\n LOOP_END_THREADS\n\t\n Py_DECREF(loop);\n\treturn 0;\n\n fail:\n LOOP_END_THREADS\n \n\tPy_XDECREF(loop);\n\treturn -1;\n }\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Typecode typecode = {otype, 0, 0};\n\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\t\n arr = PyArray_FromAny(obj, &typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Typecode ntype = {rtype, 0, 0};\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t &ntype, 0, 0,\n\t\t\t\t\t FORCECAST |\t\t\\\n\t\t\t\t\t BEHAVED_FLAGS_RO);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n\n\nstatic PyTypeObject PyUFuncReduce_Type;\n\nstatic void ufuncreduce_dealloc(PyUFuncReduceObject *);\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n\n\tif ((loop=PyObject_NEW(PyUFuncReduceObject, \n\t\t\t &PyUFuncReduce_Type)) == NULL)\n\t\treturn NULL;\n\n\n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\n\t/* Make bufsize depend on a local then module-level variable */\n\tloop->bufsize = _getintfromvar(\"UFUNC_BUFSIZE\", \n\t\t\t\t PyArray_BUFSIZE);\n\tif ((loop->bufsize < PyArray_MIN_BUFSIZE) ||\t\t\\\n\t (loop->bufsize > PyArray_MAX_BUFSIZE)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"The buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d)\", \n\t\t\t loop->bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\tgoto fail;\n\t}\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->itemsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->itemsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->itemsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->itemsize;\n loop->outsize = loop->ret->itemsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n (loop->outsize + \\\n aar->itemsize));\n if (loop->buffer == NULL) goto fail;\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->itemsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->cast[otype];\n }\n else {\n loop->buffer = (char *)malloc(loop->bufsize*\\\n loop->outsize);\n if (loop->buffer == NULL) goto fail;\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\t\n\tloop->errormask = _getintfromvar(UFUNC_ERRMASK_NAME,\n\t\t\t\t\t UFUNC_ERR_DEFAULT);\n\tif (loop->errormask < 0) {\n\t\tPyErr_Format(PyExc_ValueError, \\\n\t\t\t \"Invalid error mask (%d)\", \n\t\t\t loop->errormask);\n\t\tgoto fail;\n\t\t\t \n\t}\n\n\tloop->errobj = Py_BuildValue(\"NN\", \n\t\t\t\t PyString_FromString(str),\n\t\t\t\t _getfuncfromvar(UFUNC_ERRFUNC_NAME,\n\t\t\t\t\t\t Py_None));\n\tif (loop->errobj == NULL) goto fail;\n\n /* Determine if object arrays are involved */\n if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n else\n loop->obj = 0;\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n\t\t\tif (PyErr_Occurred()) goto fail;\n }\n break;\n case BUFFER_UFUNCLOOP:\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n LOOP_END_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n LOOP_END_THREADS\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR();\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR();\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tLOOP_END_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\n fail:\n\tLOOP_END_THREADS\n\n Py_XDECREF(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i;\n\tint j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR();\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tLOOP_END_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret); \n Py_DECREF(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tLOOP_END_THREADS\n\n\tPy_XDECREF(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Typecode otype= {PyArray_NOTYPE, 0, 0};\n PyArray_Typecode indtype = {PyArray_INTP, 0, 0};\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, &indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_TypecodeConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_ValueError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || PyTypeNum_ISFLEXIBLE(otype.type_num)) {\n PyErr_Format(PyExc_ValueError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\n if (otype.type_num == PyArray_NOTYPE)\n otype.type_num = mp->descr->type_num;\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype.type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype.type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t}\n\tif (res == NULL) PyErr_Clear();\n\telse if (res == Py_None) Py_DECREF(res);\n\telse {\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\t\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n\t\n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n\tif (PyUFunc_GenericFunction(self, args, mps) == -1) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\treturn NULL;\n\t}\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"Function must be callable.\");\n return NULL;\n }\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n Py_INCREF(function);\n self->obj = function;\n self->ptr = malloc((self->nargs)+sizeof(PyUFunc_PyFuncData)+sizeof(void *)+(fname_len+14));\n \n\tfdata = (PyUFunc_PyFuncData *)(self->ptr + (nin+nout) + sizeof(void *));\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + (nin+nout));\n self->data[0] = (void *)fdata;\n\n\n\tself->types = (char *)self->ptr;\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = (char *)(fdata + 1);\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\t\n\tif ((self = PyObject_NEW(PyUFuncObject, &PyUFunc_Type)) == NULL) \n\t\treturn NULL;\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr=PyArray_DescrFromType(usertype);\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Cannot register typenumber\");\n\t\treturn -1;\n\t}\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong(usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n PyObject_DEL(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n\tPyObject_DEL(self);\n}\n\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n\tPyObject_DEL(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype)\n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\nstatic PyTypeObject PyUFuncLoop_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncloop\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncLoopObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncloop_dealloc\t/*tp_dealloc*/\n};\n\nstatic PyTypeObject PyUFuncReduce_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"ufuncreduce\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncReduceObject),\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufuncreduce_dealloc\t/*tp_dealloc*/\n};\n\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", "methods": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 47, "complexity": 11, "token_count": 357, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 431, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 481, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 515, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 550, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 579, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 604, "end_line": 685, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 690, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 713, "end_line": 738, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 742, "end_line": 750, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 759, "end_line": 801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 246, "complexity": 59, "token_count": 1912, "parameters": [ "loop", "args", "mps" ], "start_line": 804, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 343, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1153, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 117, "complexity": 24, "token_count": 838, "parameters": [ "self", "args", "mps" ], "start_line": 1270, "end_line": 1441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 172, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1444, "end_line": 1464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1467, "end_line": 1489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 191, "complexity": 38, "token_count": 1408, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1498, "end_line": 1733, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 236, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 100, "complexity": 16, "token_count": 660, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1745, "end_line": 1875, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1879, "end_line": 2009, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 2031, "end_line": 2158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2167, "end_line": 2277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2284, "end_line": 2336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2339, "end_line": 2404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 50, "complexity": 8, "token_count": 432, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2412, "end_line": 2483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2487, "end_line": 2518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2521, "end_line": 2562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2565, "end_line": 2577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2580, "end_line": 2592, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2596, "end_line": 2602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2605, "end_line": 2612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2624, "end_line": 2693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2697, "end_line": 2701, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2704, "end_line": 2708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2711, "end_line": 2714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2734, "end_line": 2756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2761, "end_line": 2844, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2849, "end_line": 2852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PyUFunc_ff_f_As_dd_d", "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 145, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 39, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_ff_f", "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 52, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_dd_d", "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 136, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 66, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_gg_g", "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 10, "complexity": 2, "token_count": 135, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 80, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F_As_DD_D", "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 227, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 94, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_DD_D", "long_name": "PyUFunc_DD_D( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 112, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_FF_F", "long_name": "PyUFunc_FF_F( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 128, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "PyUFunc_GG_G", "long_name": "PyUFunc_GG_G( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 15, "complexity": 2, "token_count": 219, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 144, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "PyUFunc_OO_O", "long_name": "PyUFunc_OO_O( char ** args , int * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 238, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 162, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f_As_d_d", "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 106, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_d_d", "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 210, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_f_f", "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 8, "complexity": 2, "token_count": 93, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 220, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "PyUFunc_g_g", "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 2, "token_count": 94, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F_As_D_D", "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 164, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 242, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_F_F", "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 256, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_D_D", "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 271, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_G_G", "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 2, "token_count": 150, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 286, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O", "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 18, "complexity": 5, "token_count": 152, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 300, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "PyUFunc_O_O_method", "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 24, "complexity": 6, "token_count": 193, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 323, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 44, "complexity": 12, "token_count": 358, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_error_handler", "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 211, "parameters": [ "method", "errobj", "errtype", "retstatus" ], "start_line": 429, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "PyUFunc_checkfperr", "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 60, "parameters": [ "errmask", "errobj" ], "start_line": 479, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "PyUFunc_clearfperr", "long_name": "PyUFunc_clearfperr()", "filename": "ufuncobject.c", "nloc": 5, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "_lowest_type", "long_name": "_lowest_type( char intype)", "filename": "ufuncobject.c", "nloc": 23, "complexity": 13, "token_count": 66, "parameters": [ "intype" ], "start_line": 548, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "_cancoerce", "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", "filename": "ufuncobject.c", "nloc": 21, "complexity": 9, "token_count": 101, "parameters": [ "thistype", "neededtype", "scalar" ], "start_line": 577, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "select_types", "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", "filename": "ufuncobject.c", "nloc": 70, "complexity": 17, "token_count": 455, "parameters": [ "self", "arg_types", "function", "data", "scalars" ], "start_line": 602, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 82, "top_nesting_level": 0 }, { "name": "_getintfromvar", "long_name": "_getintfromvar( char * str , int deflt)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 6, "token_count": 123, "parameters": [ "str", "deflt" ], "start_line": 688, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_getfuncfromvar", "long_name": "_getfuncfromvar( char * str , PyObject * deflt)", "filename": "ufuncobject.c", "nloc": 25, "complexity": 6, "token_count": 134, "parameters": [ "str", "deflt" ], "start_line": 711, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "_scalar_kind", "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", "filename": "ufuncobject.c", "nloc": 9, "complexity": 6, "token_count": 64, "parameters": [ "typenum", "arr" ], "start_line": 740, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "_create_copies", "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 37, "complexity": 8, "token_count": 285, "parameters": [ "loop", "arg_types", "mps" ], "start_line": 757, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 246, "complexity": 59, "token_count": 1912, "parameters": [ "loop", "args", "mps" ], "start_line": 802, "end_line": 1144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 343, "top_nesting_level": 0 }, { "name": "construct_loop", "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 40, "complexity": 8, "token_count": 238, "parameters": [ "self", "args", "mps" ], "start_line": 1151, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 118, "complexity": 25, "token_count": 845, "parameters": [ "self", "args", "mps" ], "start_line": 1268, "end_line": 1440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 173, "top_nesting_level": 0 }, { "name": "_getidentity", "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", "filename": "ufuncobject.c", "nloc": 19, "complexity": 3, "token_count": 118, "parameters": [ "self", "otype", "str" ], "start_line": 1443, "end_line": 1463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_create_reduce_copy", "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 5, "token_count": 127, "parameters": [ "loop", "arr", "rtype" ], "start_line": 1466, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "construct_reduce", "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", "filename": "ufuncobject.c", "nloc": 191, "complexity": 38, "token_count": 1408, "parameters": [ "self", "arr", "axis", "otype", "operation", "ind_size", "str" ], "start_line": 1497, "end_line": 1732, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 236, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduce", "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 100, "complexity": 16, "token_count": 660, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1744, "end_line": 1874, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Accumulate", "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 101, "complexity": 15, "token_count": 683, "parameters": [ "self", "arr", "axis", "otype" ], "start_line": 1878, "end_line": 2008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 131, "top_nesting_level": 0 }, { "name": "PyUFunc_Reduceat", "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", "filename": "ufuncobject.c", "nloc": 108, "complexity": 20, "token_count": 763, "parameters": [ "self", "arr", "ind", "axis", "otype" ], "start_line": 2030, "end_line": 2157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 128, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericReduction", "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", "filename": "ufuncobject.c", "nloc": 97, "complexity": 23, "token_count": 613, "parameters": [ "self", "args", "kwds", "operation" ], "start_line": 2166, "end_line": 2276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 111, "top_nesting_level": 0 }, { "name": "_find_array_wrap", "long_name": "_find_array_wrap( PyObject * args)", "filename": "ufuncobject.c", "nloc": 49, "complexity": 12, "token_count": 260, "parameters": [ "args" ], "start_line": 2283, "end_line": 2335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ufunc_generic_call", "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 46, "complexity": 12, "token_count": 356, "parameters": [ "self", "args" ], "start_line": 2338, "end_line": 2403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 48, "complexity": 7, "token_count": 413, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2411, "end_line": 2480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "PyUFunc_FromFuncAndData", "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", "filename": "ufuncobject.c", "nloc": 26, "complexity": 4, "token_count": 181, "parameters": [ "func", "data", "types", "ntypes", "nin", "nout", "identity", "name", "doc", "check_return" ], "start_line": 2484, "end_line": 2515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "PyUFunc_RegisterLoopForType", "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", "filename": "ufuncobject.c", "nloc": 41, "complexity": 8, "token_count": 241, "parameters": [ "ufunc", "usertype", "function", "data" ], "start_line": 2518, "end_line": 2559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "ufuncreduce_dealloc", "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", "filename": "ufuncobject.c", "nloc": 13, "complexity": 3, "token_count": 76, "parameters": [ "self" ], "start_line": 2562, "end_line": 2574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufuncloop_dealloc", "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", "filename": "ufuncobject.c", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 2577, "end_line": 2589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "ufunc_dealloc", "long_name": "ufunc_dealloc( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 2593, "end_line": 2599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ufunc_repr", "long_name": "ufunc_repr( PyUFuncObject * self)", "filename": "ufuncobject.c", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 2602, "end_line": 2609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "ufunc_outer", "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", "filename": "ufuncobject.c", "nloc": 59, "complexity": 13, "token_count": 428, "parameters": [ "self", "args" ], "start_line": 2621, "end_line": 2690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "ufunc_reduce", "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2694, "end_line": 2698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_accumulate", "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2701, "end_line": 2705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "ufunc_reduceat", "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "args", "kwds" ], "start_line": 2708, "end_line": 2711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_makeargs", "long_name": "_makeargs( int num , char ltr , char * str)", "filename": "ufuncobject.c", "nloc": 20, "complexity": 3, "token_count": 117, "parameters": [ "num", "ltr", "str" ], "start_line": 2731, "end_line": 2753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "ufunc_getattr", "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", "filename": "ufuncobject.c", "nloc": 74, "complexity": 16, "token_count": 520, "parameters": [ "self", "name" ], "start_line": 2758, "end_line": 2841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 84, "top_nesting_level": 0 }, { "name": "ufunc_setattr", "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", "filename": "ufuncobject.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self", "name", "v" ], "start_line": 2846, "end_line": 2849, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "construct_matrices", "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 246, "complexity": 59, "token_count": 1912, "parameters": [ "loop", "args", "mps" ], "start_line": 804, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 343, "top_nesting_level": 0 }, { "name": "PyUFunc_On_Om", "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", "filename": "ufuncobject.c", "nloc": 47, "complexity": 11, "token_count": 357, "parameters": [ "args", "dimensions", "steps", "func" ], "start_line": 359, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "ufunc_frompyfunc", "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", "filename": "ufuncobject.c", "nloc": 50, "complexity": 8, "token_count": 432, "parameters": [ "dummy", "args", "kwds" ], "start_line": 2412, "end_line": 2483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 }, { "name": "PyUFunc_GenericFunction", "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", "filename": "ufuncobject.c", "nloc": 117, "complexity": 24, "token_count": 838, "parameters": [ "self", "args", "mps" ], "start_line": 1270, "end_line": 1441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 172, "top_nesting_level": 0 } ], "nloc": 2138, "complexity": 438, "token_count": 15659, "diff_parsed": { "added": [ "/* a general-purpose ufunc that deals with general-purpose Python callable.", "\tintp n=dimensions[0];", "\tfor(i=0; iuserloops = NULL;", "\tif (self->ptr == NULL) return PyErr_NoMemory();", " Py_INCREF(function);", " self->obj = function;" ], "deleted": [ "/* a general-purpose ufunc that deals with general-purpose callable", "\tfor(i=0; i<*dimensions; i++) {", " arglist = PyTuple_New(nin);", " Py_DECREF(arglist);", " return;", " }", " if (*op != NULL) {Py_DECREF(*op);}", " if (*op != NULL) {Py_DECREF(*op);}", "\t}", "", "", " if (!loop->obj)", " BEGIN_THREADS", " Py_INCREF(function);", " self->obj = function;" ] } } ] }, { "hash": "1c8e6d935cf0053dee0bbcf006f3646cd00b482b", "msg": "r164@Blasphemy: kern | 2005-10-06 22:01:39 -0700\n Typo", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-07T05:02:35+00:00", "author_timezone": 0, "committer_date": "2005-10-07T05:02:35+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0a8d3a1020037f58846aa3851cad8097a9af1a09" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/base/function_base.py", "new_path": "scipy/base/function_base.py", "filename": "function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -678,7 +678,7 @@ def __call__(self,*args):\n \n \n def round_(x, decimals=0):\n- \"\"\"round_(m, decimals=0) Rounds x to decimplas places.\n+ \"\"\"round_(m, decimals=0) Rounds x to decimals places.\n \n Returns x if array is not floating point and rounds both the real\n and imaginary parts separately if array is complex. Rounds in the\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import types\nimport math, operator\nimport numeric as _nx\nfrom numeric import ones, zeros, arange, concatenate, array, asarray, empty\nfrom numeric import ScalarType\nfrom umath import pi, multiply, add, arctan2, maximum, minimum, frompyfunc, \\\n isnan, absolute\nfrom oldnumeric import ravel, nonzero, choose, \\\n sometrue, alltrue, reshape, any, all, typecodes \nfrom type_check import ScalarType, isscalar\nfrom shape_base import squeeze, atleast_1d\nfrom _compiled_base import digitize, bincount, _insert\nfrom ufunclike import sign\n\n__all__ = ['logspace','linspace', 'round_',\n 'select','piecewise','trim_zeros','alen','amax', 'amin', 'ptp',\n 'copy', 'iterable', 'base_repr', 'binary_repr', \n 'prod','cumprod', 'diff','gradient','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin', 'vectorize','asarray_chkfinite',\n 'average','histogram','bincount','digitize']\n\n_lkup = {'0':'000',\n '1':'001',\n '2':'010',\n '3':'011',\n '4':'100',\n '5':'101',\n '6':'110',\n '7':'111',\n 'L':''}\n\ndef binary_repr(num):\n \"\"\"Return the binary representation of the input number as a string.\n\n This is abuut 25x faster than using base_repr with base 2.\n \"\"\"\n ostr = oct(num)\n bin = ''\n for ch in ostr[1:]:\n bin += _lkup[ch]\n ind = 0\n while bin[ind] == '0':\n ind += 1\n return bin[ind:]\n\ndef base_repr (number, base=2, padding=0):\n \"\"\"Return the representation of a number in any given base.\n \"\"\"\n chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n lnb = math.log(base)\n res = padding*chars[0]\n if number == 0:\n return res + chars[0]\n exponent = int (math.log (number)/lnb)\n while(exponent >= 0):\n term = long(base)**exponent\n lead_digit = int(number / term)\n res += chars[lead_digit]\n number -= term*lead_digit\n exponent -= 1\n return res\n#end Fernando's utilities\n\n\n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = _nx.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = _nx.arange(0,num) * step + start\n return _nx.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = _nx.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = _nx.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef iterable(y):\n try: iter(y)\n except: return 0\n return 1\n\ndef histogram(x, bins=10, range=None, normed=0):\n x = asarray(x).ravel()\n if not iterable(bins):\n if range is None:\n range = (x.min(), x.max())\n mn, mx = [x+0.0 for x in range]\n if mn == mx:\n mn -= 0.5\n mx += 0.5\n bins = linspace(mn, mx, bins)\n\n n = x.sort().searchsorted(bins)\n n = concatenate([n, [len(x)]])\n n = n[1:]-n[:-1]\n\n if normed:\n db = bins[1] - bins[0]\n return 1.0/(x.size*db) * n, bins\n else:\n return n, bins\n\ndef average (a, axis=0, weights=None, returned=0):\n \"\"\"average(a, axis=0, weights=None)\n Computes average along indicated axis. \n If axis is None, average over the entire array.\n Inputs can be integer or floating types; result is type Float.\n \n If weights are given, result is:\n sum(a*weights)/(sum(weights))\n weights must have a's shape or be the 1-d with length the size\n of a in the given axis. Integer weights are converted to Float.\n\n Not supplying weights is equivalent to supply weights that are\n all 1.\n\n If returned, return a tuple: the result and the sum of the weights \n or count of values. The shape of these two results will be the same.\n\n raises ZeroDivisionError if appropriate when result is scalar.\n (The version in MA does not -- it returns masked values).\n \"\"\"\n if axis is None:\n a = array(a).ravel()\n if weights is None:\n n = add.reduce(a)\n d = len(a) * 1.0\n else:\n w = array(weights).ravel() * 1.0\n n = add.reduce(multiply(a,w))\n d = add.reduce(w) \n else:\n a = array(a)\n ash = a.shape\n if ash == ():\n a.shape = (1,)\n if weights is None:\n n = add.reduce(a, axis) \n d = ash[axis] * 1.0\n if returned:\n d = ones(shape(n)) * d\n else:\n w = array(weights, copy=0) * 1.0\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis) \n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*ni\n r[axis] = slice(None,None,1)\n w1 = eval(\"w[\"+repr(tuple(r))+\"]*ones(ash, Float)\")\n n = add.reduce(a*w1, axis)\n d = add.reduce(w1, axis)\n else:\n raise ValueError, 'average: weights wrong shape.'\n \n if not isinstance(d, ArrayType):\n if d == 0.0: \n raise ZeroDivisionError, 'Numeric.average, zero denominator'\n if returned:\n return n/d, d\n else:\n return n/d\n\n\ndef isaltered():\n val = str(type(_nx.array([1])))\n return 'scipy' in val\n\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if (x.dtypechar in _nx.typecodes['AllFloat']) \\\n and (_nx.isnan(x).any() or _nx.isinf(x).any()):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\n\n\n\ndef piecewise(x, condlist, funclist, *args, **kw):\n \"\"\"Returns a piecewise-defined function.\n\n x is the domain\n\n condlist is a list of boolean arrays or a single boolean array\n The length of the condition list must be n2 or n2-1 where n2\n is the length of the function list. If len(condlist)==n2-1, then\n an 'otherwise' condition is formed by |'ing all the conditions\n and inverting. \n\n funclist is a list of functions to call of length (n2).\n Each function should return an array output for an array input\n Each function can take (the same set) of extra arguments and\n keyword arguments which are passed in after the function list.\n\n The output is the same shape and type as x and is found by\n calling the functions on the appropriate portions of x.\n\n Note: This is similar to choose or select, except\n the the functions are only evaluated on elements of x\n that satisfy the corresponding condition.\n\n The result is\n |--\n | f1(x) for condition1\n y = --| f2(x) for condition2\n | ...\n | fn(x) for conditionn\n |--\n \n \"\"\"\n n2 = len(funclist)\n if not isinstance(condlist, type([])):\n condlist = [condlist]\n n = len(condlist)\n if n == n2-1: # compute the \"otherwise\" condition.\n totlist = condlist[0]\n for k in range(1,n):\n totlist |= condlist\n condlist.append(~totlist)\n n += 1\n if (n != n2):\n raise ValueError, \"function list and condition list must be the same.\"\n y = empty(x.shape, x.dtype)\n for k in range(n):\n item = funclist[k]\n if not callable(item):\n y[condlist[k]] = item\n else:\n y[condlist[k]] = item(x[condlist[k]], *args, **kw)\n return y\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice arrays (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\ndef _asarray1d(arr,copy=0):\n \"\"\"Ensure 1d array for one array.\n \"\"\"\n if copy:\n return asarray(arr).flatten()\n else:\n return asarray(arr).ravel()\n\ndef copy(a):\n \"\"\"Return an array copy of the object.\n \"\"\"\n return array(a,copy=1)\n \n# Basic operations\ndef amax(m,axis=-1): \n \"\"\"Returns the maximum of m along dimension axis. \n \"\"\"\n return asarray(m).max(axis)\n\ndef amin(m,axis=-1):\n \"\"\"Returns the minimum of m along dimension axis.\n \"\"\"\n return asarray(m).min(axis)\n\ndef alen(m):\n \"\"\"Returns the length of a Python object interpreted as an array\n \"\"\"\n return len(asarray(m))\n\ndef ptp(m,axis=-1):\n \"\"\"Returns the maximum - minimum along the the given dimension\n \"\"\"\n return asarray(m).ptp(axis)\n\ndef prod(m,axis=-1):\n \"\"\"Returns the product of the elements along the given axis\n \"\"\"\n return asarray(m).prod(axis)\n\ndef cumprod(m,axis=-1):\n \"\"\"Returns the cumulative product of the elments along the given axis\n \"\"\"\n return asarray(m).cumprod(axis)\n\ndef gradient(f,*varargs):\n \"\"\"Calculate the gradient of an N-dimensional scalar function.\n\n Uses central differences on the interior and first differences on boundaries\n to give the same shape.\n\n Inputs:\n\n f -- An N-dimensional array giving samples of a scalar function\n\n varargs -- 0, 1, or N scalars giving the sample distances in each direction\n\n Outputs:\n\n N arrays of the same shape as f giving the derivative of f with respect\n to each dimension.\n \"\"\"\n N = len(f.shape) # number of dimensions\n n = len(varargs)\n if n==0:\n dx = [1.0]*N\n elif n==1:\n dx = [varargs[0]]*N\n elif n==N:\n dx = list(varargs)\n else:\n raise SyntaxError, \"Invalid number of arguments\"\n\n # use central differences on interior and first differences on endpoints\n\n print dx\n outvals = []\n\n # create slice objects --- initially all are [:,:,...,:]\n slice1 = [slice(None)]*N\n slice2 = [slice(None)]*N\n slice3 = [slice(None)]*N\n\n otype = f.dtypechar\n if otype not in ['f','d','F','D']:\n otype = 'd'\n\n for axis in range(N):\n # select out appropriate parts for this dimension\n out = zeros(f.shape, f.dtypechar)\n slice1[axis] = slice(1,-1)\n slice2[axis] = slice(2,None)\n slice3[axis] = slice(None,-2)\n # 1d equivalent -- out[1:-1] = (f[2:] - f[:-2])/2.0\n out[slice1] = (f[slice2] - f[slice3])/2.0 \n slice1[axis] = 0\n slice2[axis] = 1\n slice3[axis] = 0\n # 1d equivalent -- out[0] = (f[1] - f[0])\n out[slice1] = (f[slice2] - f[slice3])\n slice1[axis] = -1\n slice2[axis] = -1\n slice3[axis] = -2\n # 1d equivalent -- out[-1] = (f[-1] - f[-2])\n out[slice1] = (f[slice2] - f[slice3])\n \n # divide by step size\n outvals.append(out / dx[axis])\n \n # reset the slice object in this dimension to \":\"\n slice1[axis] = slice(None)\n slice2[axis] = slice(None)\n slice3[axis] = slice(None)\n\n if N == 1:\n return outvals[0]\n else:\n return outvals\n \n\ndef diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n if n==0:\n return x\n if n<0:\n raise ValueError,'Order must be non-negative but got ' + `n`\n x = asarray(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n slice1 = tuple(slice1)\n slice2 = tuple(slice2)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if (issubclass(z.dtype, _nx.complexfloating)):\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n _nx.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n _nx.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n trim = trim.upper()\n if 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n # Dictionary setting is quite fast.\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(arr) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return _nx.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _nx._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as 0\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = 0\n return y.sum(axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = _nx.inf\n return y.min(axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = _nx.inf \n return y.argmin(axis) \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = -_nx.inf \n return y.max(axis) \n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = -_nx.inf \n return y.argmax(axis) \n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nclass vectorize:\n \"\"\"\n vectorize(somefunction, otypes=None, doc=None)\n Generalized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or scipy arrays as inputs and returns a\n scipy array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of scipy. \n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes='',doc=None):\n try:\n fcode = pyfunc.func_code\n except AttributeError:\n raise TypeError, \"Object is not a callable Python object\"\n\n self.thefunc = pyfunc\n self.ufunc = None\n self.nin = len(fcode.co_varnames)\n self.nout = None\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n for char in self.otypes:\n if char not in typecodes['All']:\n raise ValueError, \"Invalid typecode specified\"\n\n def __call__(self,*args):\n # get number of outputs and output types by calling\n # the function on the first entries of args\n if len(args) != self.nin:\n raise ValueError, \"mismatch between python function inputs\"\\\n \" and received arguments\"\n if self.nout is None or self.otypes == '':\n newargs = []\n for arg in args:\n newargs.append(asarray(arg).flat[0])\n theout = self.thefunc(*newargs)\n if isinstance(theout, types.TupleType):\n self.nout = len(theout)\n else:\n self.nout = 1\n theout = (theout,)\n if self.otypes == '':\n otypes = []\n for k in range(self.nout):\n otypes.append(asarray(theout[k]).dtypechar)\n self.otypes = ''.join(otypes)\n\n if self.ufunc is None:\n self.ufunc = frompyfunc(self.thefunc, self.nin, self.nout)\n\n if self.nout == 1:\n return self.ufunc(*args).astype(self.otypes[0])\n else:\n return tuple([x.astype(c) for x,c in zip(self.ufunc(*args), self.otypes)])\n\n\ndef round_(x, decimals=0):\n \"\"\"round_(m, decimals=0) Rounds x to decimals places.\n\n Returns x if array is not floating point and rounds both the real\n and imaginary parts separately if array is complex. Rounds in the\n same way as standard Python.\n \"\"\"\n x = asarray(x)\n if not issubclass(x.dtype, _nx.inexact):\n return x\n if issubclass(x.dtype, _nx.complexfloating):\n return round_(x.real, decimals) + 1j*round_(x.imag, decimals)\n if decimals is not 0:\n decimals = asarray(decimals)\n s = sign(x)\n if decimals is not 0:\n x = absolute(multiply(x,10.**decimals))\n else:\n x = absolute(x)\n rem = x-asarray(x).astype(_nx.intp)\n x = _nx.where(_nx.less(rem,0.5), _nx.floor(x), _nx.ceil(x))\n # convert back\n if decimals is not 0:\n return multiply(x,s/(10.**decimals))\n else:\n return multiply(x,s)\n\n", "source_code_before": "import types\nimport math, operator\nimport numeric as _nx\nfrom numeric import ones, zeros, arange, concatenate, array, asarray, empty\nfrom numeric import ScalarType\nfrom umath import pi, multiply, add, arctan2, maximum, minimum, frompyfunc, \\\n isnan, absolute\nfrom oldnumeric import ravel, nonzero, choose, \\\n sometrue, alltrue, reshape, any, all, typecodes \nfrom type_check import ScalarType, isscalar\nfrom shape_base import squeeze, atleast_1d\nfrom _compiled_base import digitize, bincount, _insert\nfrom ufunclike import sign\n\n__all__ = ['logspace','linspace', 'round_',\n 'select','piecewise','trim_zeros','alen','amax', 'amin', 'ptp',\n 'copy', 'iterable', 'base_repr', 'binary_repr', \n 'prod','cumprod', 'diff','gradient','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin', 'vectorize','asarray_chkfinite',\n 'average','histogram','bincount','digitize']\n\n_lkup = {'0':'000',\n '1':'001',\n '2':'010',\n '3':'011',\n '4':'100',\n '5':'101',\n '6':'110',\n '7':'111',\n 'L':''}\n\ndef binary_repr(num):\n \"\"\"Return the binary representation of the input number as a string.\n\n This is abuut 25x faster than using base_repr with base 2.\n \"\"\"\n ostr = oct(num)\n bin = ''\n for ch in ostr[1:]:\n bin += _lkup[ch]\n ind = 0\n while bin[ind] == '0':\n ind += 1\n return bin[ind:]\n\ndef base_repr (number, base=2, padding=0):\n \"\"\"Return the representation of a number in any given base.\n \"\"\"\n chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n lnb = math.log(base)\n res = padding*chars[0]\n if number == 0:\n return res + chars[0]\n exponent = int (math.log (number)/lnb)\n while(exponent >= 0):\n term = long(base)**exponent\n lead_digit = int(number / term)\n res += chars[lead_digit]\n number -= term*lead_digit\n exponent -= 1\n return res\n#end Fernando's utilities\n\n\n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = _nx.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = _nx.arange(0,num) * step + start\n return _nx.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = _nx.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = _nx.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef iterable(y):\n try: iter(y)\n except: return 0\n return 1\n\ndef histogram(x, bins=10, range=None, normed=0):\n x = asarray(x).ravel()\n if not iterable(bins):\n if range is None:\n range = (x.min(), x.max())\n mn, mx = [x+0.0 for x in range]\n if mn == mx:\n mn -= 0.5\n mx += 0.5\n bins = linspace(mn, mx, bins)\n\n n = x.sort().searchsorted(bins)\n n = concatenate([n, [len(x)]])\n n = n[1:]-n[:-1]\n\n if normed:\n db = bins[1] - bins[0]\n return 1.0/(x.size*db) * n, bins\n else:\n return n, bins\n\ndef average (a, axis=0, weights=None, returned=0):\n \"\"\"average(a, axis=0, weights=None)\n Computes average along indicated axis. \n If axis is None, average over the entire array.\n Inputs can be integer or floating types; result is type Float.\n \n If weights are given, result is:\n sum(a*weights)/(sum(weights))\n weights must have a's shape or be the 1-d with length the size\n of a in the given axis. Integer weights are converted to Float.\n\n Not supplying weights is equivalent to supply weights that are\n all 1.\n\n If returned, return a tuple: the result and the sum of the weights \n or count of values. The shape of these two results will be the same.\n\n raises ZeroDivisionError if appropriate when result is scalar.\n (The version in MA does not -- it returns masked values).\n \"\"\"\n if axis is None:\n a = array(a).ravel()\n if weights is None:\n n = add.reduce(a)\n d = len(a) * 1.0\n else:\n w = array(weights).ravel() * 1.0\n n = add.reduce(multiply(a,w))\n d = add.reduce(w) \n else:\n a = array(a)\n ash = a.shape\n if ash == ():\n a.shape = (1,)\n if weights is None:\n n = add.reduce(a, axis) \n d = ash[axis] * 1.0\n if returned:\n d = ones(shape(n)) * d\n else:\n w = array(weights, copy=0) * 1.0\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis) \n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*ni\n r[axis] = slice(None,None,1)\n w1 = eval(\"w[\"+repr(tuple(r))+\"]*ones(ash, Float)\")\n n = add.reduce(a*w1, axis)\n d = add.reduce(w1, axis)\n else:\n raise ValueError, 'average: weights wrong shape.'\n \n if not isinstance(d, ArrayType):\n if d == 0.0: \n raise ZeroDivisionError, 'Numeric.average, zero denominator'\n if returned:\n return n/d, d\n else:\n return n/d\n\n\ndef isaltered():\n val = str(type(_nx.array([1])))\n return 'scipy' in val\n\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if (x.dtypechar in _nx.typecodes['AllFloat']) \\\n and (_nx.isnan(x).any() or _nx.isinf(x).any()):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\n\n\n\ndef piecewise(x, condlist, funclist, *args, **kw):\n \"\"\"Returns a piecewise-defined function.\n\n x is the domain\n\n condlist is a list of boolean arrays or a single boolean array\n The length of the condition list must be n2 or n2-1 where n2\n is the length of the function list. If len(condlist)==n2-1, then\n an 'otherwise' condition is formed by |'ing all the conditions\n and inverting. \n\n funclist is a list of functions to call of length (n2).\n Each function should return an array output for an array input\n Each function can take (the same set) of extra arguments and\n keyword arguments which are passed in after the function list.\n\n The output is the same shape and type as x and is found by\n calling the functions on the appropriate portions of x.\n\n Note: This is similar to choose or select, except\n the the functions are only evaluated on elements of x\n that satisfy the corresponding condition.\n\n The result is\n |--\n | f1(x) for condition1\n y = --| f2(x) for condition2\n | ...\n | fn(x) for conditionn\n |--\n \n \"\"\"\n n2 = len(funclist)\n if not isinstance(condlist, type([])):\n condlist = [condlist]\n n = len(condlist)\n if n == n2-1: # compute the \"otherwise\" condition.\n totlist = condlist[0]\n for k in range(1,n):\n totlist |= condlist\n condlist.append(~totlist)\n n += 1\n if (n != n2):\n raise ValueError, \"function list and condition list must be the same.\"\n y = empty(x.shape, x.dtype)\n for k in range(n):\n item = funclist[k]\n if not callable(item):\n y[condlist[k]] = item\n else:\n y[condlist[k]] = item(x[condlist[k]], *args, **kw)\n return y\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice arrays (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\ndef _asarray1d(arr,copy=0):\n \"\"\"Ensure 1d array for one array.\n \"\"\"\n if copy:\n return asarray(arr).flatten()\n else:\n return asarray(arr).ravel()\n\ndef copy(a):\n \"\"\"Return an array copy of the object.\n \"\"\"\n return array(a,copy=1)\n \n# Basic operations\ndef amax(m,axis=-1): \n \"\"\"Returns the maximum of m along dimension axis. \n \"\"\"\n return asarray(m).max(axis)\n\ndef amin(m,axis=-1):\n \"\"\"Returns the minimum of m along dimension axis.\n \"\"\"\n return asarray(m).min(axis)\n\ndef alen(m):\n \"\"\"Returns the length of a Python object interpreted as an array\n \"\"\"\n return len(asarray(m))\n\ndef ptp(m,axis=-1):\n \"\"\"Returns the maximum - minimum along the the given dimension\n \"\"\"\n return asarray(m).ptp(axis)\n\ndef prod(m,axis=-1):\n \"\"\"Returns the product of the elements along the given axis\n \"\"\"\n return asarray(m).prod(axis)\n\ndef cumprod(m,axis=-1):\n \"\"\"Returns the cumulative product of the elments along the given axis\n \"\"\"\n return asarray(m).cumprod(axis)\n\ndef gradient(f,*varargs):\n \"\"\"Calculate the gradient of an N-dimensional scalar function.\n\n Uses central differences on the interior and first differences on boundaries\n to give the same shape.\n\n Inputs:\n\n f -- An N-dimensional array giving samples of a scalar function\n\n varargs -- 0, 1, or N scalars giving the sample distances in each direction\n\n Outputs:\n\n N arrays of the same shape as f giving the derivative of f with respect\n to each dimension.\n \"\"\"\n N = len(f.shape) # number of dimensions\n n = len(varargs)\n if n==0:\n dx = [1.0]*N\n elif n==1:\n dx = [varargs[0]]*N\n elif n==N:\n dx = list(varargs)\n else:\n raise SyntaxError, \"Invalid number of arguments\"\n\n # use central differences on interior and first differences on endpoints\n\n print dx\n outvals = []\n\n # create slice objects --- initially all are [:,:,...,:]\n slice1 = [slice(None)]*N\n slice2 = [slice(None)]*N\n slice3 = [slice(None)]*N\n\n otype = f.dtypechar\n if otype not in ['f','d','F','D']:\n otype = 'd'\n\n for axis in range(N):\n # select out appropriate parts for this dimension\n out = zeros(f.shape, f.dtypechar)\n slice1[axis] = slice(1,-1)\n slice2[axis] = slice(2,None)\n slice3[axis] = slice(None,-2)\n # 1d equivalent -- out[1:-1] = (f[2:] - f[:-2])/2.0\n out[slice1] = (f[slice2] - f[slice3])/2.0 \n slice1[axis] = 0\n slice2[axis] = 1\n slice3[axis] = 0\n # 1d equivalent -- out[0] = (f[1] - f[0])\n out[slice1] = (f[slice2] - f[slice3])\n slice1[axis] = -1\n slice2[axis] = -1\n slice3[axis] = -2\n # 1d equivalent -- out[-1] = (f[-1] - f[-2])\n out[slice1] = (f[slice2] - f[slice3])\n \n # divide by step size\n outvals.append(out / dx[axis])\n \n # reset the slice object in this dimension to \":\"\n slice1[axis] = slice(None)\n slice2[axis] = slice(None)\n slice3[axis] = slice(None)\n\n if N == 1:\n return outvals[0]\n else:\n return outvals\n \n\ndef diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n if n==0:\n return x\n if n<0:\n raise ValueError,'Order must be non-negative but got ' + `n`\n x = asarray(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n slice1 = tuple(slice1)\n slice2 = tuple(slice2)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if (issubclass(z.dtype, _nx.complexfloating)):\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n _nx.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n _nx.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n trim = trim.upper()\n if 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n # Dictionary setting is quite fast.\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(arr) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return _nx.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _nx._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as 0\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = 0\n return y.sum(axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = _nx.inf\n return y.min(axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = _nx.inf \n return y.argmin(axis) \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = -_nx.inf \n return y.max(axis) \n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n y = array(x)\n if not issubclass(y.dtype, _nx.integer):\n y[isnan(x)] = -_nx.inf \n return y.argmax(axis) \n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nclass vectorize:\n \"\"\"\n vectorize(somefunction, otypes=None, doc=None)\n Generalized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or scipy arrays as inputs and returns a\n scipy array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of scipy. \n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes='',doc=None):\n try:\n fcode = pyfunc.func_code\n except AttributeError:\n raise TypeError, \"Object is not a callable Python object\"\n\n self.thefunc = pyfunc\n self.ufunc = None\n self.nin = len(fcode.co_varnames)\n self.nout = None\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n for char in self.otypes:\n if char not in typecodes['All']:\n raise ValueError, \"Invalid typecode specified\"\n\n def __call__(self,*args):\n # get number of outputs and output types by calling\n # the function on the first entries of args\n if len(args) != self.nin:\n raise ValueError, \"mismatch between python function inputs\"\\\n \" and received arguments\"\n if self.nout is None or self.otypes == '':\n newargs = []\n for arg in args:\n newargs.append(asarray(arg).flat[0])\n theout = self.thefunc(*newargs)\n if isinstance(theout, types.TupleType):\n self.nout = len(theout)\n else:\n self.nout = 1\n theout = (theout,)\n if self.otypes == '':\n otypes = []\n for k in range(self.nout):\n otypes.append(asarray(theout[k]).dtypechar)\n self.otypes = ''.join(otypes)\n\n if self.ufunc is None:\n self.ufunc = frompyfunc(self.thefunc, self.nin, self.nout)\n\n if self.nout == 1:\n return self.ufunc(*args).astype(self.otypes[0])\n else:\n return tuple([x.astype(c) for x,c in zip(self.ufunc(*args), self.otypes)])\n\n\ndef round_(x, decimals=0):\n \"\"\"round_(m, decimals=0) Rounds x to decimplas places.\n\n Returns x if array is not floating point and rounds both the real\n and imaginary parts separately if array is complex. Rounds in the\n same way as standard Python.\n \"\"\"\n x = asarray(x)\n if not issubclass(x.dtype, _nx.inexact):\n return x\n if issubclass(x.dtype, _nx.complexfloating):\n return round_(x.real, decimals) + 1j*round_(x.imag, decimals)\n if decimals is not 0:\n decimals = asarray(decimals)\n s = sign(x)\n if decimals is not 0:\n x = absolute(multiply(x,10.**decimals))\n else:\n x = absolute(x)\n rem = x-asarray(x).astype(_nx.intp)\n x = _nx.where(_nx.less(rem,0.5), _nx.floor(x), _nx.ceil(x))\n # convert back\n if decimals is not 0:\n return multiply(x,s/(10.**decimals))\n else:\n return multiply(x,s)\n\n", "methods": [ { "name": "binary_repr", "long_name": "binary_repr( num )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 50, "parameters": [ "num" ], "start_line": 33, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "base_repr", "long_name": "base_repr( number , base = 2 , padding = 0 )", "filename": "function_base.py", "nloc": 14, "complexity": 3, "token_count": 97, "parameters": [ "number", "base", "padding" ], "start_line": 47, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 68, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 83, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "iterable", "long_name": "iterable( y )", "filename": "function_base.py", "nloc": 4, "complexity": 2, "token_count": 17, "parameters": [ "y" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "histogram", "long_name": "histogram( x , bins = 10 , range = None , normed = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 6, "token_count": 171, "parameters": [ "x", "bins", "range", "normed" ], "start_line": 106, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "average", "long_name": "average( a , axis = 0 , weights = None , returned = 0 )", "filename": "function_base.py", "nloc": 44, "complexity": 12, "token_count": 335, "parameters": [ "a", "axis", "weights", "returned" ], "start_line": 127, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "isaltered", "long_name": "isaltered( )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 193, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 6, "complexity": 4, "token_count": 57, "parameters": [ "x" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "piecewise", "long_name": "piecewise( x , condlist , funclist , * args , ** kw )", "filename": "function_base.py", "nloc": 21, "complexity": 7, "token_count": 163, "parameters": [ "x", "condlist", "funclist", "args", "kw" ], "start_line": 210, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 263, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_asarray1d", "long_name": "_asarray1d( arr , copy = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "arr", "copy" ], "start_line": 311, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "copy", "long_name": "copy( a )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 319, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 325, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 330, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "alen", "long_name": "alen( m )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "m" ], "start_line": 335, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 340, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 345, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 350, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "gradient", "long_name": "gradient( f , * varargs )", "filename": "function_base.py", "nloc": 41, "complexity": 7, "token_count": 325, "parameters": [ "f", "varargs" ], "start_line": 355, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 73, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 17, "complexity": 4, "token_count": 142, "parameters": [ "x", "n", "axis" ], "start_line": 430, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 72, "parameters": [ "z", "deg" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 465, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 11, "complexity": 4, "token_count": 70, "parameters": [ "a" ], "start_line": 482, "end_line": 497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 13, "complexity": 7, "token_count": 86, "parameters": [ "filt", "trim" ], "start_line": 499, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 521, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 530, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 537, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 46, "parameters": [ "x", "axis" ], "start_line": 543, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 48, "parameters": [ "x", "axis" ], "start_line": 551, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 48, "parameters": [ "x", "axis" ], "start_line": 559, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 567, "end_line": 573, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 575, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 583, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = '' , doc = None )", "filename": "function_base.py", "nloc": 20, "complexity": 6, "token_count": 114, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 627, "end_line": 647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 25, "complexity": 11, "token_count": 228, "parameters": [ "self", "args" ], "start_line": 649, "end_line": 677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "round_", "long_name": "round_( x , decimals = 0 )", "filename": "function_base.py", "nloc": 19, "complexity": 6, "token_count": 184, "parameters": [ "x", "decimals" ], "start_line": 680, "end_line": 705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 } ], "methods_before": [ { "name": "binary_repr", "long_name": "binary_repr( num )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 50, "parameters": [ "num" ], "start_line": 33, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "base_repr", "long_name": "base_repr( number , base = 2 , padding = 0 )", "filename": "function_base.py", "nloc": 14, "complexity": 3, "token_count": 97, "parameters": [ "number", "base", "padding" ], "start_line": 47, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 68, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 83, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "iterable", "long_name": "iterable( y )", "filename": "function_base.py", "nloc": 4, "complexity": 2, "token_count": 17, "parameters": [ "y" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "histogram", "long_name": "histogram( x , bins = 10 , range = None , normed = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 6, "token_count": 171, "parameters": [ "x", "bins", "range", "normed" ], "start_line": 106, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "average", "long_name": "average( a , axis = 0 , weights = None , returned = 0 )", "filename": "function_base.py", "nloc": 44, "complexity": 12, "token_count": 335, "parameters": [ "a", "axis", "weights", "returned" ], "start_line": 127, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 0 }, { "name": "isaltered", "long_name": "isaltered( )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 193, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 6, "complexity": 4, "token_count": 57, "parameters": [ "x" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "piecewise", "long_name": "piecewise( x , condlist , funclist , * args , ** kw )", "filename": "function_base.py", "nloc": 21, "complexity": 7, "token_count": 163, "parameters": [ "x", "condlist", "funclist", "args", "kw" ], "start_line": 210, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 263, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_asarray1d", "long_name": "_asarray1d( arr , copy = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "arr", "copy" ], "start_line": 311, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "copy", "long_name": "copy( a )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 319, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 325, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 330, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "alen", "long_name": "alen( m )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "m" ], "start_line": 335, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 340, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 345, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "m", "axis" ], "start_line": 350, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "gradient", "long_name": "gradient( f , * varargs )", "filename": "function_base.py", "nloc": 41, "complexity": 7, "token_count": 325, "parameters": [ "f", "varargs" ], "start_line": 355, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 73, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 17, "complexity": 4, "token_count": 142, "parameters": [ "x", "n", "axis" ], "start_line": 430, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 72, "parameters": [ "z", "deg" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 465, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 11, "complexity": 4, "token_count": 70, "parameters": [ "a" ], "start_line": 482, "end_line": 497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 13, "complexity": 7, "token_count": 86, "parameters": [ "filt", "trim" ], "start_line": 499, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 521, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 530, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 537, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 46, "parameters": [ "x", "axis" ], "start_line": 543, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 48, "parameters": [ "x", "axis" ], "start_line": 551, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 48, "parameters": [ "x", "axis" ], "start_line": 559, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 567, "end_line": 573, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 575, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 583, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = '' , doc = None )", "filename": "function_base.py", "nloc": 20, "complexity": 6, "token_count": 114, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 627, "end_line": 647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 25, "complexity": 11, "token_count": 228, "parameters": [ "self", "args" ], "start_line": 649, "end_line": 677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "round_", "long_name": "round_( x , decimals = 0 )", "filename": "function_base.py", "nloc": 19, "complexity": 6, "token_count": 184, "parameters": [ "x", "decimals" ], "start_line": 680, "end_line": 705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "round_", "long_name": "round_( x , decimals = 0 )", "filename": "function_base.py", "nloc": 19, "complexity": 6, "token_count": 184, "parameters": [ "x", "decimals" ], "start_line": 680, "end_line": 705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 } ], "nloc": 453, "complexity": 127, "token_count": 3440, "diff_parsed": { "added": [ " \"\"\"round_(m, decimals=0) Rounds x to decimals places." ], "deleted": [ " \"\"\"round_(m, decimals=0) Rounds x to decimplas places." ] } } ] }, { "hash": "04a98ff28bceccd16622a99f2b7780cd86376470", "msg": "r165@Blasphemy: kern | 2005-10-06 22:02:09 -0700\n More distributions!", "author": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "committer": { "name": "Robert Kern", "email": "robert.kern@gmail.com" }, "author_date": "2005-10-07T05:02:43+00:00", "author_timezone": 0, "committer_date": "2005-10-07T05:02:43+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1c8e6d935cf0053dee0bbcf006f3646cd00b482b" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 1077, "insertions": 2516, "lines": 3593, "files": 5, "dmm_unit_size": 0.08126410835214447, "dmm_unit_complexity": 0.1613995485327314, "dmm_unit_interfacing": 0.14446952595936793, "modified_files": [ { "old_path": "scipy/corelib/mtrand/distributions.c", "new_path": "scipy/corelib/mtrand/distributions.c", "filename": "distributions.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -20,6 +20,27 @@\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n \n+/* The implementations of rk_hypergeometric_hyp(), rk_hypergeometric_hrua(),\n+ * and rk_triangular() were adapted from Ivan Frohne's rv.py which has this \n+ * license:\n+ * \n+ * Copyright 1998 by Ivan Frohne; Wasilla, Alaska, U.S.A.\n+ * All Rights Reserved\n+ *\n+ * Permission to use, copy, modify and distribute this software and its\n+ * documentation for any purpose, free of charge, is granted subject to the\n+ * following conditions:\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the software.\n+ *\n+ * THE SOFTWARE AND DOCUMENTATION IS PROVIDED WITHOUT WARRANTY OF ANY KIND,\n+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO MERCHANTABILITY, FITNESS\n+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR\n+ * OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM OR DAMAGES IN A CONTRACT\n+ * ACTION, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n+ * SOFTWARE OR ITS DOCUMENTATION.\n+ */\n+\n #include \n #include \"distributions.h\"\n #include \"mconf.h\"\n@@ -527,3 +548,228 @@ double rk_power(rk_state *state, double a)\n {\n return pow(1 - exp(-rk_standard_exponential(state)), 1./a);\n }\n+\n+double rk_laplace(rk_state *state, double loc, double scale)\n+{\n+ double U;\n+ \n+ U = rk_double(state);\n+ if (U < 0.5)\n+ {\n+ U = loc + scale * log(U + U);\n+ } else \n+ {\n+ U = loc - scale * log(2.0 - U - U);\n+ }\n+ return U;\n+}\n+\n+double rk_gumbel(rk_state *state, double loc, double scale)\n+{\n+ double U;\n+ \n+ U = 1.0 - rk_double(state);\n+ return loc - scale * log(-log(U));\n+}\n+\n+double rk_logistic(rk_state *state, double loc, double scale)\n+{\n+ double U;\n+ \n+ U = rk_double(state);\n+ return loc + scale * log(U/(1.0 - U));\n+}\n+\n+double rk_lognormal(rk_state *state, double mean, double sigma)\n+{\n+ return exp(rk_normal(state, mean, sigma));\n+}\n+\n+double rk_rayleigh(rk_state *state, double mode)\n+{\n+ return mode*sqrt(-2.0 * log(1.0 - rk_double(state)));\n+}\n+\n+double rk_wald(rk_state *state, double mean, double scale)\n+{\n+ double U, X, Y;\n+ double mu_2l;\n+ \n+ mu_2l = mean / (2*scale);\n+ Y = rk_gauss(state);\n+ Y = mean*Y*Y;\n+ X = mean + mu_2l*(Y - sqrt(4*scale*Y + Y*Y));\n+ U = rk_double(state);\n+ if (U <= mean/(mean+X))\n+ {\n+ return X;\n+ } else\n+ {\n+ return mean*mean/X;\n+ }\n+}\n+\n+long rk_zipf(rk_state *state, double a)\n+{\n+ double T, U, V;\n+ long X;\n+ double b;\n+ \n+ b = pow(2.0, a-1.0);\n+ do\n+ {\n+ U = rk_double(state);\n+ V = rk_double(state);\n+ X = (long)floor(pow(U, -1.0/(a-1.0)));\n+ T = pow(1.0 + 1.0/X, a-1.0); \n+ } while ((V *X*(T-1.0)/(b-1.0)) > (T/b));\n+ return X;\n+}\n+\n+long rk_geometric_search(rk_state *state, double p)\n+{\n+ double U;\n+ long X;\n+ double sum, prod, q;\n+ \n+ X = 1;\n+ sum = prod = p;\n+ q = 1.0 - p;\n+ U = rk_double(state);\n+ while (U > sum)\n+ {\n+ prod *= q;\n+ sum += prod;\n+ X++;\n+ }\n+ return X;\n+}\n+\n+long rk_geometric_inversion(rk_state *state, double p)\n+{\n+ return (long)ceil(log(1.0-rk_double(state))/log(1.0-p));\n+}\n+\n+long rk_geometric(rk_state *state, double p)\n+{\n+ if (p >= 0.333333333333333333333333)\n+ {\n+ return rk_geometric_search(state, p);\n+ } else\n+ {\n+ return rk_geometric_inversion(state, p);\n+ }\n+}\n+\n+long rk_hypergeometric_hyp(rk_state *state, long good, long bad, long sample)\n+{\n+ long d1, K, Z;\n+ double d2, U, Y;\n+ \n+ d1 = bad + good - sample;\n+ d2 = (double)min(bad, good);\n+ \n+ Y = d2;\n+ K = sample;\n+ while (Y > 0.0)\n+ {\n+ U = rk_double(state);\n+ Y -= (long)floor(U + Y/(d1 + K));\n+ K--;\n+ if (K == 0) break;\n+ }\n+ Z = (long)(d2 - Y);\n+ if (bad > good) Z = sample - Z;\n+ return Z;\n+}\n+\n+/* D1 = 2*sqrt(2/e) */\n+/* D2 = 3 - 2*sqrt(3/e) */\n+#define D1 1.7155277699214135\n+#define D2 0.8989161620588988\n+long rk_hypergeometric_hrua(rk_state *state, long good, long bad, long sample)\n+{\n+ long mingoodbad, maxgoodbad, popsize, m, d9;\n+ double d4, d5, d6, d7, d8, d10, d11;\n+ long Z;\n+ double T, W, X, Y;\n+ \n+ mingoodbad = min(good, bad);\n+ popsize = good + bad;\n+ maxgoodbad = max(good, bad);\n+ m = min(sample, popsize - sample);\n+ d4 = ((double)mingoodbad) / popsize;\n+ d5 = 1.0 - d4;\n+ d6 = m*d4 + 0.5;\n+ d7 = sqrt((popsize - m) * sample * d4 *d5 / (popsize-1) + 0.5);\n+ d8 = D1*d7 + D2;\n+ d9 = (long)floor((double)((m+1)*(mingoodbad+1))/(popsize+2));\n+ d10 = (lgam(d9+1) + lgam(mingoodbad-d9+1) + lgam(m-d9+1) + \n+ lgam(maxgoodbad-m+d9+1));\n+ d11 = min(min(m, mingoodbad)+1.0, floor(d6+16*d7));\n+ /* 16 for 16-decimal-digit precision in D1 and D2 */\n+ \n+ while (1)\n+ {\n+ X = rk_double(state);\n+ Y = rk_double(state);\n+ W = d6 + d8*(Y- 0.5)/X;\n+ \n+ /* fast rejection: */\n+ if ((W < 0.0) || (W >= d11)) continue;\n+ \n+ Z = (long)floor(W);\n+ T = d10 - (lgam(Z+1) + lgam(mingoodbad-Z+1) + lgam(m-Z+1) +\n+ lgam(maxgoodbad-m+Z+1));\n+ \n+ /* fast acceptance: */\n+ if ((X*(4.0-X)-3.0) <= T) break;\n+ \n+ /* fast rejection: */\n+ if (X*(X-T) >= 1) continue;\n+\n+ if (2.0*log(X) <= T) break; /* acceptance */\n+ }\n+ \n+ /* this is a correction to HRUA* by Ivan Frohne in rv.py */\n+ if (bad > good) Z = m - Z;\n+ \n+ /* another fix from rv.py to allow sample to exceed popsize/2 */\n+ if (m < sample) Z = bad - Z;\n+ \n+ return Z;\n+}\n+#undef D1\n+#undef D2\n+\n+long rk_hypergeometric(rk_state *state, long good, long bad, long sample)\n+{\n+ if (sample > 10)\n+ {\n+ return rk_hypergeometric_hrua(state, good, bad, sample);\n+ } else\n+ {\n+ return rk_hypergeometric_hyp(state, good, bad, sample);\n+ }\n+}\n+\n+double rk_triangular(rk_state *state, double left, double mode, double right)\n+{\n+ double base, leftbase, ratio, leftprod, rightprod;\n+ double U;\n+ \n+ base = right - left;\n+ leftbase = mode - left;\n+ ratio = leftbase / base;\n+ leftprod = leftbase*base;\n+ rightprod = (right - mode)*base;\n+ \n+ U = rk_double(state);\n+ if (U <= ratio)\n+ {\n+ return left + sqrt(U*leftprod);\n+ } else \n+ {\n+ return right - sqrt((1.0 - U) * rightprod); \n+ }\n+}\n\\ No newline at end of file\n", "added_lines": 246, "deleted_lines": 0, "source_code": "/* Copyright 2005 Robert Kern (robert.kern@gmail.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n * \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/* The implementations of rk_hypergeometric_hyp(), rk_hypergeometric_hrua(),\n * and rk_triangular() were adapted from Ivan Frohne's rv.py which has this \n * license:\n * \n * Copyright 1998 by Ivan Frohne; Wasilla, Alaska, U.S.A.\n * All Rights Reserved\n *\n * Permission to use, copy, modify and distribute this software and its\n * documentation for any purpose, free of charge, is granted subject to the\n * following conditions:\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the software.\n *\n * THE SOFTWARE AND DOCUMENTATION IS PROVIDED WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO MERCHANTABILITY, FITNESS\n * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR\n * OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM OR DAMAGES IN A CONTRACT\n * ACTION, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR ITS DOCUMENTATION.\n */\n\n#include \n#include \"distributions.h\"\n#include \"mconf.h\"\n#include \n\n#ifndef min\n#define min(x,y) ((xy)?x:y)\n#endif\n\ndouble rk_normal(rk_state *state, double loc, double scale)\n{\n return loc + scale*rk_gauss(state);\n}\n\ndouble rk_standard_exponential(rk_state *state)\n{\n /* We use -log(1-U) since U is [0, 1) */\n return -log(1.0 - rk_double(state));\n}\n\ndouble rk_exponential(rk_state *state, double scale)\n{\n return scale * rk_standard_exponential(state);\n}\n\ndouble rk_uniform(rk_state *state, double loc, double scale)\n{\n return loc + scale*rk_double(state);\n}\n\n#define LOG4 1.3862943611198906\n#define ONELOG92 2.5040773967762742\n\ndouble rk_standard_gamma(rk_state *state, double shape)\n{\n double b, c, lam;\n double U, V, X, Y, Z, R;\n\n if (shape == 1.0)\n {\n return rk_standard_exponential(state);\n }\n else if (shape < 1.0)\n {\n while (1)\n {\n U = rk_double(state);\n V = rk_standard_exponential(state);\n if (U <= 1.0 - shape)\n {\n X = pow(U, 1./shape);\n if (X <= V)\n {\n return X;\n }\n }\n else\n {\n Y = -log((1-U)/shape);\n X = pow(1.0 - shape + shape*Y, 1./shape);\n if (X <= (V + Y))\n {\n return X;\n }\n }\n }\n }\n else\n {\n b = shape - LOG4;\n lam = sqrt(2.0*shape - 1.0);\n c = shape + lam;\n \n while (1)\n {\n U = rk_double(state);\n V = rk_double(state);\n Y = log(V/(1.0-V))/lam;\n X = shape*exp(Y); \n Z = U*V*V;\n R = b + c*Y - X;\n if ((R >= 4.5*Z - ONELOG92) || (R >= log(Z)))\n {\n break;\n }\n }\n return X;\n }\n}\n\n#undef LOG4\n#undef ONELOG92\n\ndouble rk_gamma(rk_state *state, double shape, double scale)\n{\n return scale * rk_standard_gamma(state, shape);\n}\n\ndouble rk_beta(rk_state *state, double a, double b)\n{\n double Ga, Gb;\n\n if ((a <= 1.0) && (b <= 1.0))\n {\n double U, V, X, Y;\n /* Use Jonk's algorithm */\n\n while (1)\n {\n U = rk_double(state);\n V = rk_double(state);\n X = pow(U, 1.0/a);\n Y = pow(V, 1.0/b);\n\n if ((X + Y) <= 1.0)\n {\n return X;\n }\n }\n }\n else\n {\n Ga = rk_standard_gamma(state, a);\n Gb = rk_standard_gamma(state, b);\n return Ga/(Ga + Gb);\n }\n}\n\ndouble rk_chisquare(rk_state *state, double df)\n{\n return 2.0*rk_standard_gamma(state, df/2.0);\n}\n\ndouble rk_noncentral_chisquare(rk_state *state, double df, double nonc)\n{\n double Chi2, N;\n\n Chi2 = rk_chisquare(state, df-1);\n N = rk_gauss(state) + sqrt(nonc);\n return Chi2 + N*N;\n}\n\ndouble rk_f(rk_state *state, double dfnum, double dfden)\n{\n return rk_chisquare(state, dfnum) / rk_chisquare(state, dfden);\n}\n\ndouble rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc)\n{\n return ((rk_noncentral_chisquare(state, dfnum, nonc)*dfden) /\n (rk_chisquare(state, dfden)*dfnum));\n}\n\nlong rk_binomial_btpe(rk_state *state, long n, double p)\n{\n double r,q,fm,p1,xm,xl,xr,c,laml,lamr,p2,p3,p4;\n double a,u,v,s,F,rho,t,A,nrq,x1,x2,f1,f2,z,z2,w,w2,x;\n long m,y,k,i;\n\n if (!(state->has_binomial) || \n (state->nsave != n) ||\n (state->psave != p))\n {\n /* initialize */\n state->nsave = n;\n state->psave = p;\n state->has_binomial = 1;\n state->r = r = min(p, 1.0-p);\n state->q = q = 1.0 - r;\n state->fm = fm = n*r+r;\n state->m = m = (long)floor(state->fm);\n state->p1 = p1 = floor(2.195*sqrt(n*r*q)-4.6*q) + 0.5;\n state->xm = xm = m + 0.5;\n state->xl = xl = xm - p1;\n state->xr = xr = xm + p1;\n state->c = c = 0.134 + 20.5/(15.3 + m);\n a = (fm - xl)/(fm-xl*r);\n state->laml = laml = a*(1.0 + a/2.0);\n a = (xr - fm)/(xr*q);\n state->lamr = lamr = a*(1.0 + a/2.0);\n state->p2 = p2 = p1*(1.0 + 2.0*c);\n state->p3 = p3 = p2 + c/laml;\n state->p4 = p4 = p3 + c/lamr;\n }\n else\n {\n r = state->r;\n q = state->q;\n fm = state->fm;\n m = state->m;\n p1 = state->p1;\n xm = state->xm;\n xl = state->xl;\n xr = state->xr;\n c = state->c;\n laml = state->laml;\n lamr = state->lamr;\n p2 = state->p2;\n p3 = state->p3;\n p4 = state->p4;\n }\n\n /* sigh ... */\n Step10:\n nrq = n*r*q;\n u = rk_double(state)*p4;\n v = rk_double(state);\n if (u > p1) goto Step20;\n y = (long)floor(xm - p1*v + u);\n goto Step60;\n\n Step20:\n if (u > p2) goto Step30;\n x = xl + (u - p1)/c;\n v = v*c + 1.0 - fabs(m - x + 0.5)/p1;\n if (v > 1.0) goto Step10;\n y = (long)floor(x);\n goto Step50;\n\n Step30:\n if (u > p3) goto Step40;\n y = (long)floor(xl + log(v)/laml);\n if (y < 0) goto Step10;\n v = v*(u-p2)*laml;\n goto Step50;\n\n Step40:\n y = (int)floor(xr - log(v)/lamr);\n if (y > n) goto Step10;\n v = v*(u-p3)*lamr;\n\n Step50:\n k = fabs(y - m);\n if ((k > 20) && (k < ((nrq)/2.0 - 1))) goto Step52;\n\n s = r/q;\n a = s*(n+1);\n F = 1.0;\n if (m < y)\n {\n for (i=m; i<=y; i++)\n {\n F *= (a/i - s);\n }\n }\n else if (m > y)\n {\n for (i=y; i<=m; i++)\n {\n F /= (a/i - s);\n }\n }\n else\n {\n if (v > F) goto Step10;\n goto Step60;\n }\n\n Step52:\n rho = (k/(nrq))*((k*(k/3.0 + 0.625) + 0.16666666666666666)/nrq + 0.5);\n t = -k*k/(2*nrq);\n A = log(v);\n if (A < (t - rho)) goto Step60;\n if (A > (t + rho)) goto Step10;\n\n x1 = y+1;\n f1 = m+1;\n z = n+1-m;\n w = n-y+1;\n x2 = x1*x1;\n f2 = f1*f1;\n z2 = z*z;\n w2 = w*w;\n if (A > (xm*log(f1/x1)\n + (n-m+0.5)*log(z/w)\n + (y-m)*log(w*r/(x1*q))\n + (13680.-(462.-(132.-(99.-140./f2)/f2)/f2)/f2)/f1/166320.\n + (13680.-(462.-(132.-(99.-140./z2)/z2)/z2)/z2)/z/166320.\n + (13680.-(462.-(132.-(99.-140./x2)/x2)/x2)/x2)/x1/166320.\n + (13680.-(462.-(132.-(99.-140./w2)/w2)/w2)/w2)/w/166320.))\n {\n goto Step10;\n }\n\n Step60:\n if (p > 0.5)\n {\n y = n - y;\n }\n\n return y;\n}\n\nlong rk_binomial_waiting(rk_state *state, long n, double p)\n{\n double q, E, Sum;\n long X;\n\n q = -log(1.0 - p);\n\n X = 0;\n Sum = 0.0;\n\n while (Sum <= q)\n {\n if (X == n)\n {\n X += 1;\n break;\n }\n E = rk_standard_exponential(state);\n Sum += E / (n - X);\n X++;\n }\n return X-1;\n}\n\nlong rk_binomial(rk_state *state, long n, double p)\n{\n double q;\n\n if (p <= 0.5)\n {\n if (p*n <= 30.0)\n {\n return rk_binomial_waiting(state, n, p);\n }\n else\n {\n return rk_binomial_btpe(state, n, p);\n }\n }\n else\n {\n q = 1.0-p;\n if (q*n <= 30.0)\n {\n return n - rk_binomial_waiting(state, n, q);\n }\n else\n {\n return n - rk_binomial_btpe(state, n, q);\n }\n }\n\n}\n\nlong rk_negative_binomial(rk_state *state, long n, double p)\n{\n double Y;\n\n Y = rk_gamma(state, n, (1-p)/p);\n return rk_poisson(state, Y);\n}\n\nlong rk_poisson_mult(rk_state *state, double lam)\n{\n long X;\n double prod, U, enlam;\n\n enlam = exp(-lam);\n X = 0;\n prod = 1.0;\n while (1)\n {\n U = rk_double(state);\n prod *= U;\n if (prod > enlam)\n {\n X += 1;\n }\n else\n {\n return X;\n }\n }\n}\n\n#define LS2PI 0.91893853320467267\n#define TWELFTH 0.083333333333333333333333\nlong rk_poisson_ptrs(rk_state *state, double lam)\n{\n long k;\n double U, V, slam, loglam, a, b, invalpha, vr, us;\n\n slam = sqrt(lam);\n loglam = log(lam);\n b = 0.931 + 2.53*slam;\n a = -0.059 + 0.02483*b;\n invalpha = 1.1239 + 1.1328/(b-3.4);\n vr = 0.9277 - 3.6224/(b-2);\n\n while (1)\n {\n U = rk_double(state) - 0.5;\n V = rk_double(state);\n us = 0.5 - fabs(U);\n k = (long)floor((2*a/us + b)*U + lam + 0.43);\n if ((us >= 0.07) && (V <= vr))\n {\n return k;\n }\n if ((k < 0) ||\n ((us < 0.013) && (V > us)))\n {\n continue;\n }\n if ((log(V) + log(invalpha) - log(a/(us*us)+b)) <=\n (-lam + k*loglam - lgam(k+1)))\n {\n return k;\n }\n\n \n }\n\n}\n\nlong rk_poisson(rk_state *state, double lam)\n{\n if (lam >= 10)\n {\n return rk_poisson_ptrs(state, lam);\n }\n else\n {\n return rk_poisson_mult(state, lam);\n }\n}\n\ndouble rk_standard_cauchy(rk_state *state)\n{\n return rk_gauss(state) / rk_gauss(state);\n}\n\ndouble rk_standard_t(rk_state *state, double df)\n{\n double N, G, X;\n\n N = rk_gauss(state);\n G = rk_standard_gamma(state, df/2);\n X = sqrt(df/2)*N/sqrt(G);\n return X;\n}\n\ndouble rk_vonmises(rk_state *state, double mu, double kappa)\n{\n double r, rho, s;\n double U, V, W, Y, Z;\n double result, mod;\n\n if (kappa < 1e-8)\n {\n return M_PI * (2*rk_double(state)-1);\n }\n else\n {\n r = 1 + sqrt(1 + 4*kappa*kappa);\n rho = (r - sqrt(2*r))/(2*kappa);\n s = (1 + rho*rho)/(2*rho);\n\n while (1)\n {\n U = 2*rk_double(state) - 1;\n V = 2*rk_double(state) - 1;\n Z = cos(M_PI*U);\n W = (1 + s*Z)/(s + Z);\n Y = kappa * (s - W);\n if ((Y*(2-Y) - V >= 0) || (log(Y/V)+1 - Y >= 0))\n {\n break;\n }\n }\n\n if (U < 0)\n {\n result = acos(W);\n }\n else\n {\n result = -acos(W);\n }\n result += mu + M_PI;\n mod = fmod(result, 2*M_PI);\n if (mod && (mod < 0))\n {\n mod += 2*M_PI;\n }\n return mod - M_PI;\n }\n}\n\ndouble rk_pareto(rk_state *state, double a)\n{\n return exp(rk_standard_exponential(state)/a) - 1;\n}\n\ndouble rk_weibull(rk_state *state, double a)\n{\n return pow(rk_standard_exponential(state), 1./a);\n}\n\ndouble rk_power(rk_state *state, double a)\n{\n return pow(1 - exp(-rk_standard_exponential(state)), 1./a);\n}\n\ndouble rk_laplace(rk_state *state, double loc, double scale)\n{\n double U;\n \n U = rk_double(state);\n if (U < 0.5)\n {\n U = loc + scale * log(U + U);\n } else \n {\n U = loc - scale * log(2.0 - U - U);\n }\n return U;\n}\n\ndouble rk_gumbel(rk_state *state, double loc, double scale)\n{\n double U;\n \n U = 1.0 - rk_double(state);\n return loc - scale * log(-log(U));\n}\n\ndouble rk_logistic(rk_state *state, double loc, double scale)\n{\n double U;\n \n U = rk_double(state);\n return loc + scale * log(U/(1.0 - U));\n}\n\ndouble rk_lognormal(rk_state *state, double mean, double sigma)\n{\n return exp(rk_normal(state, mean, sigma));\n}\n\ndouble rk_rayleigh(rk_state *state, double mode)\n{\n return mode*sqrt(-2.0 * log(1.0 - rk_double(state)));\n}\n\ndouble rk_wald(rk_state *state, double mean, double scale)\n{\n double U, X, Y;\n double mu_2l;\n \n mu_2l = mean / (2*scale);\n Y = rk_gauss(state);\n Y = mean*Y*Y;\n X = mean + mu_2l*(Y - sqrt(4*scale*Y + Y*Y));\n U = rk_double(state);\n if (U <= mean/(mean+X))\n {\n return X;\n } else\n {\n return mean*mean/X;\n }\n}\n\nlong rk_zipf(rk_state *state, double a)\n{\n double T, U, V;\n long X;\n double b;\n \n b = pow(2.0, a-1.0);\n do\n {\n U = rk_double(state);\n V = rk_double(state);\n X = (long)floor(pow(U, -1.0/(a-1.0)));\n T = pow(1.0 + 1.0/X, a-1.0); \n } while ((V *X*(T-1.0)/(b-1.0)) > (T/b));\n return X;\n}\n\nlong rk_geometric_search(rk_state *state, double p)\n{\n double U;\n long X;\n double sum, prod, q;\n \n X = 1;\n sum = prod = p;\n q = 1.0 - p;\n U = rk_double(state);\n while (U > sum)\n {\n prod *= q;\n sum += prod;\n X++;\n }\n return X;\n}\n\nlong rk_geometric_inversion(rk_state *state, double p)\n{\n return (long)ceil(log(1.0-rk_double(state))/log(1.0-p));\n}\n\nlong rk_geometric(rk_state *state, double p)\n{\n if (p >= 0.333333333333333333333333)\n {\n return rk_geometric_search(state, p);\n } else\n {\n return rk_geometric_inversion(state, p);\n }\n}\n\nlong rk_hypergeometric_hyp(rk_state *state, long good, long bad, long sample)\n{\n long d1, K, Z;\n double d2, U, Y;\n \n d1 = bad + good - sample;\n d2 = (double)min(bad, good);\n \n Y = d2;\n K = sample;\n while (Y > 0.0)\n {\n U = rk_double(state);\n Y -= (long)floor(U + Y/(d1 + K));\n K--;\n if (K == 0) break;\n }\n Z = (long)(d2 - Y);\n if (bad > good) Z = sample - Z;\n return Z;\n}\n\n/* D1 = 2*sqrt(2/e) */\n/* D2 = 3 - 2*sqrt(3/e) */\n#define D1 1.7155277699214135\n#define D2 0.8989161620588988\nlong rk_hypergeometric_hrua(rk_state *state, long good, long bad, long sample)\n{\n long mingoodbad, maxgoodbad, popsize, m, d9;\n double d4, d5, d6, d7, d8, d10, d11;\n long Z;\n double T, W, X, Y;\n \n mingoodbad = min(good, bad);\n popsize = good + bad;\n maxgoodbad = max(good, bad);\n m = min(sample, popsize - sample);\n d4 = ((double)mingoodbad) / popsize;\n d5 = 1.0 - d4;\n d6 = m*d4 + 0.5;\n d7 = sqrt((popsize - m) * sample * d4 *d5 / (popsize-1) + 0.5);\n d8 = D1*d7 + D2;\n d9 = (long)floor((double)((m+1)*(mingoodbad+1))/(popsize+2));\n d10 = (lgam(d9+1) + lgam(mingoodbad-d9+1) + lgam(m-d9+1) + \n lgam(maxgoodbad-m+d9+1));\n d11 = min(min(m, mingoodbad)+1.0, floor(d6+16*d7));\n /* 16 for 16-decimal-digit precision in D1 and D2 */\n \n while (1)\n {\n X = rk_double(state);\n Y = rk_double(state);\n W = d6 + d8*(Y- 0.5)/X;\n \n /* fast rejection: */\n if ((W < 0.0) || (W >= d11)) continue;\n \n Z = (long)floor(W);\n T = d10 - (lgam(Z+1) + lgam(mingoodbad-Z+1) + lgam(m-Z+1) +\n lgam(maxgoodbad-m+Z+1));\n \n /* fast acceptance: */\n if ((X*(4.0-X)-3.0) <= T) break;\n \n /* fast rejection: */\n if (X*(X-T) >= 1) continue;\n\n if (2.0*log(X) <= T) break; /* acceptance */\n }\n \n /* this is a correction to HRUA* by Ivan Frohne in rv.py */\n if (bad > good) Z = m - Z;\n \n /* another fix from rv.py to allow sample to exceed popsize/2 */\n if (m < sample) Z = bad - Z;\n \n return Z;\n}\n#undef D1\n#undef D2\n\nlong rk_hypergeometric(rk_state *state, long good, long bad, long sample)\n{\n if (sample > 10)\n {\n return rk_hypergeometric_hrua(state, good, bad, sample);\n } else\n {\n return rk_hypergeometric_hyp(state, good, bad, sample);\n }\n}\n\ndouble rk_triangular(rk_state *state, double left, double mode, double right)\n{\n double base, leftbase, ratio, leftprod, rightprod;\n double U;\n \n base = right - left;\n leftbase = mode - left;\n ratio = leftbase / base;\n leftprod = leftbase*base;\n rightprod = (right - mode)*base;\n \n U = rk_double(state);\n if (U <= ratio)\n {\n return left + sqrt(U*leftprod);\n } else \n {\n return right - sqrt((1.0 - U) * rightprod); \n }\n}", "source_code_before": "/* Copyright 2005 Robert Kern (robert.kern@gmail.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n * \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n#include \n#include \"distributions.h\"\n#include \"mconf.h\"\n#include \n\n#ifndef min\n#define min(x,y) ((xy)?x:y)\n#endif\n\ndouble rk_normal(rk_state *state, double loc, double scale)\n{\n return loc + scale*rk_gauss(state);\n}\n\ndouble rk_standard_exponential(rk_state *state)\n{\n /* We use -log(1-U) since U is [0, 1) */\n return -log(1.0 - rk_double(state));\n}\n\ndouble rk_exponential(rk_state *state, double scale)\n{\n return scale * rk_standard_exponential(state);\n}\n\ndouble rk_uniform(rk_state *state, double loc, double scale)\n{\n return loc + scale*rk_double(state);\n}\n\n#define LOG4 1.3862943611198906\n#define ONELOG92 2.5040773967762742\n\ndouble rk_standard_gamma(rk_state *state, double shape)\n{\n double b, c, lam;\n double U, V, X, Y, Z, R;\n\n if (shape == 1.0)\n {\n return rk_standard_exponential(state);\n }\n else if (shape < 1.0)\n {\n while (1)\n {\n U = rk_double(state);\n V = rk_standard_exponential(state);\n if (U <= 1.0 - shape)\n {\n X = pow(U, 1./shape);\n if (X <= V)\n {\n return X;\n }\n }\n else\n {\n Y = -log((1-U)/shape);\n X = pow(1.0 - shape + shape*Y, 1./shape);\n if (X <= (V + Y))\n {\n return X;\n }\n }\n }\n }\n else\n {\n b = shape - LOG4;\n lam = sqrt(2.0*shape - 1.0);\n c = shape + lam;\n \n while (1)\n {\n U = rk_double(state);\n V = rk_double(state);\n Y = log(V/(1.0-V))/lam;\n X = shape*exp(Y); \n Z = U*V*V;\n R = b + c*Y - X;\n if ((R >= 4.5*Z - ONELOG92) || (R >= log(Z)))\n {\n break;\n }\n }\n return X;\n }\n}\n\n#undef LOG4\n#undef ONELOG92\n\ndouble rk_gamma(rk_state *state, double shape, double scale)\n{\n return scale * rk_standard_gamma(state, shape);\n}\n\ndouble rk_beta(rk_state *state, double a, double b)\n{\n double Ga, Gb;\n\n if ((a <= 1.0) && (b <= 1.0))\n {\n double U, V, X, Y;\n /* Use Jonk's algorithm */\n\n while (1)\n {\n U = rk_double(state);\n V = rk_double(state);\n X = pow(U, 1.0/a);\n Y = pow(V, 1.0/b);\n\n if ((X + Y) <= 1.0)\n {\n return X;\n }\n }\n }\n else\n {\n Ga = rk_standard_gamma(state, a);\n Gb = rk_standard_gamma(state, b);\n return Ga/(Ga + Gb);\n }\n}\n\ndouble rk_chisquare(rk_state *state, double df)\n{\n return 2.0*rk_standard_gamma(state, df/2.0);\n}\n\ndouble rk_noncentral_chisquare(rk_state *state, double df, double nonc)\n{\n double Chi2, N;\n\n Chi2 = rk_chisquare(state, df-1);\n N = rk_gauss(state) + sqrt(nonc);\n return Chi2 + N*N;\n}\n\ndouble rk_f(rk_state *state, double dfnum, double dfden)\n{\n return rk_chisquare(state, dfnum) / rk_chisquare(state, dfden);\n}\n\ndouble rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc)\n{\n return ((rk_noncentral_chisquare(state, dfnum, nonc)*dfden) /\n (rk_chisquare(state, dfden)*dfnum));\n}\n\nlong rk_binomial_btpe(rk_state *state, long n, double p)\n{\n double r,q,fm,p1,xm,xl,xr,c,laml,lamr,p2,p3,p4;\n double a,u,v,s,F,rho,t,A,nrq,x1,x2,f1,f2,z,z2,w,w2,x;\n long m,y,k,i;\n\n if (!(state->has_binomial) || \n (state->nsave != n) ||\n (state->psave != p))\n {\n /* initialize */\n state->nsave = n;\n state->psave = p;\n state->has_binomial = 1;\n state->r = r = min(p, 1.0-p);\n state->q = q = 1.0 - r;\n state->fm = fm = n*r+r;\n state->m = m = (long)floor(state->fm);\n state->p1 = p1 = floor(2.195*sqrt(n*r*q)-4.6*q) + 0.5;\n state->xm = xm = m + 0.5;\n state->xl = xl = xm - p1;\n state->xr = xr = xm + p1;\n state->c = c = 0.134 + 20.5/(15.3 + m);\n a = (fm - xl)/(fm-xl*r);\n state->laml = laml = a*(1.0 + a/2.0);\n a = (xr - fm)/(xr*q);\n state->lamr = lamr = a*(1.0 + a/2.0);\n state->p2 = p2 = p1*(1.0 + 2.0*c);\n state->p3 = p3 = p2 + c/laml;\n state->p4 = p4 = p3 + c/lamr;\n }\n else\n {\n r = state->r;\n q = state->q;\n fm = state->fm;\n m = state->m;\n p1 = state->p1;\n xm = state->xm;\n xl = state->xl;\n xr = state->xr;\n c = state->c;\n laml = state->laml;\n lamr = state->lamr;\n p2 = state->p2;\n p3 = state->p3;\n p4 = state->p4;\n }\n\n /* sigh ... */\n Step10:\n nrq = n*r*q;\n u = rk_double(state)*p4;\n v = rk_double(state);\n if (u > p1) goto Step20;\n y = (long)floor(xm - p1*v + u);\n goto Step60;\n\n Step20:\n if (u > p2) goto Step30;\n x = xl + (u - p1)/c;\n v = v*c + 1.0 - fabs(m - x + 0.5)/p1;\n if (v > 1.0) goto Step10;\n y = (long)floor(x);\n goto Step50;\n\n Step30:\n if (u > p3) goto Step40;\n y = (long)floor(xl + log(v)/laml);\n if (y < 0) goto Step10;\n v = v*(u-p2)*laml;\n goto Step50;\n\n Step40:\n y = (int)floor(xr - log(v)/lamr);\n if (y > n) goto Step10;\n v = v*(u-p3)*lamr;\n\n Step50:\n k = fabs(y - m);\n if ((k > 20) && (k < ((nrq)/2.0 - 1))) goto Step52;\n\n s = r/q;\n a = s*(n+1);\n F = 1.0;\n if (m < y)\n {\n for (i=m; i<=y; i++)\n {\n F *= (a/i - s);\n }\n }\n else if (m > y)\n {\n for (i=y; i<=m; i++)\n {\n F /= (a/i - s);\n }\n }\n else\n {\n if (v > F) goto Step10;\n goto Step60;\n }\n\n Step52:\n rho = (k/(nrq))*((k*(k/3.0 + 0.625) + 0.16666666666666666)/nrq + 0.5);\n t = -k*k/(2*nrq);\n A = log(v);\n if (A < (t - rho)) goto Step60;\n if (A > (t + rho)) goto Step10;\n\n x1 = y+1;\n f1 = m+1;\n z = n+1-m;\n w = n-y+1;\n x2 = x1*x1;\n f2 = f1*f1;\n z2 = z*z;\n w2 = w*w;\n if (A > (xm*log(f1/x1)\n + (n-m+0.5)*log(z/w)\n + (y-m)*log(w*r/(x1*q))\n + (13680.-(462.-(132.-(99.-140./f2)/f2)/f2)/f2)/f1/166320.\n + (13680.-(462.-(132.-(99.-140./z2)/z2)/z2)/z2)/z/166320.\n + (13680.-(462.-(132.-(99.-140./x2)/x2)/x2)/x2)/x1/166320.\n + (13680.-(462.-(132.-(99.-140./w2)/w2)/w2)/w2)/w/166320.))\n {\n goto Step10;\n }\n\n Step60:\n if (p > 0.5)\n {\n y = n - y;\n }\n\n return y;\n}\n\nlong rk_binomial_waiting(rk_state *state, long n, double p)\n{\n double q, E, Sum;\n long X;\n\n q = -log(1.0 - p);\n\n X = 0;\n Sum = 0.0;\n\n while (Sum <= q)\n {\n if (X == n)\n {\n X += 1;\n break;\n }\n E = rk_standard_exponential(state);\n Sum += E / (n - X);\n X++;\n }\n return X-1;\n}\n\nlong rk_binomial(rk_state *state, long n, double p)\n{\n double q;\n\n if (p <= 0.5)\n {\n if (p*n <= 30.0)\n {\n return rk_binomial_waiting(state, n, p);\n }\n else\n {\n return rk_binomial_btpe(state, n, p);\n }\n }\n else\n {\n q = 1.0-p;\n if (q*n <= 30.0)\n {\n return n - rk_binomial_waiting(state, n, q);\n }\n else\n {\n return n - rk_binomial_btpe(state, n, q);\n }\n }\n\n}\n\nlong rk_negative_binomial(rk_state *state, long n, double p)\n{\n double Y;\n\n Y = rk_gamma(state, n, (1-p)/p);\n return rk_poisson(state, Y);\n}\n\nlong rk_poisson_mult(rk_state *state, double lam)\n{\n long X;\n double prod, U, enlam;\n\n enlam = exp(-lam);\n X = 0;\n prod = 1.0;\n while (1)\n {\n U = rk_double(state);\n prod *= U;\n if (prod > enlam)\n {\n X += 1;\n }\n else\n {\n return X;\n }\n }\n}\n\n#define LS2PI 0.91893853320467267\n#define TWELFTH 0.083333333333333333333333\nlong rk_poisson_ptrs(rk_state *state, double lam)\n{\n long k;\n double U, V, slam, loglam, a, b, invalpha, vr, us;\n\n slam = sqrt(lam);\n loglam = log(lam);\n b = 0.931 + 2.53*slam;\n a = -0.059 + 0.02483*b;\n invalpha = 1.1239 + 1.1328/(b-3.4);\n vr = 0.9277 - 3.6224/(b-2);\n\n while (1)\n {\n U = rk_double(state) - 0.5;\n V = rk_double(state);\n us = 0.5 - fabs(U);\n k = (long)floor((2*a/us + b)*U + lam + 0.43);\n if ((us >= 0.07) && (V <= vr))\n {\n return k;\n }\n if ((k < 0) ||\n ((us < 0.013) && (V > us)))\n {\n continue;\n }\n if ((log(V) + log(invalpha) - log(a/(us*us)+b)) <=\n (-lam + k*loglam - lgam(k+1)))\n {\n return k;\n }\n\n \n }\n\n}\n\nlong rk_poisson(rk_state *state, double lam)\n{\n if (lam >= 10)\n {\n return rk_poisson_ptrs(state, lam);\n }\n else\n {\n return rk_poisson_mult(state, lam);\n }\n}\n\ndouble rk_standard_cauchy(rk_state *state)\n{\n return rk_gauss(state) / rk_gauss(state);\n}\n\ndouble rk_standard_t(rk_state *state, double df)\n{\n double N, G, X;\n\n N = rk_gauss(state);\n G = rk_standard_gamma(state, df/2);\n X = sqrt(df/2)*N/sqrt(G);\n return X;\n}\n\ndouble rk_vonmises(rk_state *state, double mu, double kappa)\n{\n double r, rho, s;\n double U, V, W, Y, Z;\n double result, mod;\n\n if (kappa < 1e-8)\n {\n return M_PI * (2*rk_double(state)-1);\n }\n else\n {\n r = 1 + sqrt(1 + 4*kappa*kappa);\n rho = (r - sqrt(2*r))/(2*kappa);\n s = (1 + rho*rho)/(2*rho);\n\n while (1)\n {\n U = 2*rk_double(state) - 1;\n V = 2*rk_double(state) - 1;\n Z = cos(M_PI*U);\n W = (1 + s*Z)/(s + Z);\n Y = kappa * (s - W);\n if ((Y*(2-Y) - V >= 0) || (log(Y/V)+1 - Y >= 0))\n {\n break;\n }\n }\n\n if (U < 0)\n {\n result = acos(W);\n }\n else\n {\n result = -acos(W);\n }\n result += mu + M_PI;\n mod = fmod(result, 2*M_PI);\n if (mod && (mod < 0))\n {\n mod += 2*M_PI;\n }\n return mod - M_PI;\n }\n}\n\ndouble rk_pareto(rk_state *state, double a)\n{\n return exp(rk_standard_exponential(state)/a) - 1;\n}\n\ndouble rk_weibull(rk_state *state, double a)\n{\n return pow(rk_standard_exponential(state), 1./a);\n}\n\ndouble rk_power(rk_state *state, double a)\n{\n return pow(1 - exp(-rk_standard_exponential(state)), 1./a);\n}\n", "methods": [ { "name": "rk_normal", "long_name": "rk_normal( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "loc", "scale" ], "start_line": 54, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_standard_exponential", "long_name": "rk_standard_exponential( rk_state * state)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "state" ], "start_line": 59, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "rk_exponential", "long_name": "rk_exponential( rk_state * state , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "state", "scale" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_uniform", "long_name": "rk_uniform( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "loc", "scale" ], "start_line": 70, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_standard_gamma", "long_name": "rk_standard_gamma( rk_state * state , double shape)", "filename": "distributions.c", "nloc": 54, "complexity": 10, "token_count": 271, "parameters": [ "state", "shape" ], "start_line": 78, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "rk_gamma", "long_name": "rk_gamma( rk_state * state , double shape , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "shape", "scale" ], "start_line": 138, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_beta", "long_name": "rk_beta( rk_state * state , double a , double b)", "filename": "distributions.c", "nloc": 25, "complexity": 5, "token_count": 131, "parameters": [ "state", "a", "b" ], "start_line": 143, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "rk_chisquare", "long_name": "rk_chisquare( rk_state * state , double df)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "state", "df" ], "start_line": 173, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_noncentral_chisquare", "long_name": "rk_noncentral_chisquare( rk_state * state , double df , double nonc)", "filename": "distributions.c", "nloc": 7, "complexity": 1, "token_count": 49, "parameters": [ "state", "df", "nonc" ], "start_line": 178, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "rk_f", "long_name": "rk_f( rk_state * state , double dfnum , double dfden)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "state", "dfnum", "dfden" ], "start_line": 187, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_noncentral_f", "long_name": "rk_noncentral_f( rk_state * state , double dfnum , double dfden , double nonc)", "filename": "distributions.c", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "state", "dfnum", "dfden", "nonc" ], "start_line": 192, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "rk_binomial_btpe", "long_name": "rk_binomial_btpe( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 126, "complexity": 21, "token_count": 1119, "parameters": [ "state", "n", "p" ], "start_line": 198, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "rk_binomial_waiting", "long_name": "rk_binomial_waiting( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 20, "complexity": 3, "token_count": 89, "parameters": [ "state", "n", "p" ], "start_line": 338, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rk_binomial", "long_name": "rk_binomial( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 27, "complexity": 4, "token_count": 104, "parameters": [ "state", "n", "p" ], "start_line": 362, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "rk_negative_binomial", "long_name": "rk_negative_binomial( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "state", "n", "p" ], "start_line": 392, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "rk_poisson_mult", "long_name": "rk_poisson_mult( rk_state * state , double lam)", "filename": "distributions.c", "nloc": 21, "complexity": 3, "token_count": 73, "parameters": [ "state", "lam" ], "start_line": 400, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "rk_poisson_ptrs", "long_name": "rk_poisson_ptrs( rk_state * state , double lam)", "filename": "distributions.c", "nloc": 32, "complexity": 8, "token_count": 236, "parameters": [ "state", "lam" ], "start_line": 425, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "rk_poisson", "long_name": "rk_poisson( rk_state * state , double lam)", "filename": "distributions.c", "nloc": 11, "complexity": 2, "token_count": 38, "parameters": [ "state", "lam" ], "start_line": 463, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "rk_standard_cauchy", "long_name": "rk_standard_cauchy( rk_state * state)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "state" ], "start_line": 475, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_standard_t", "long_name": "rk_standard_t( rk_state * state , double df)", "filename": "distributions.c", "nloc": 8, "complexity": 1, "token_count": 55, "parameters": [ "state", "df" ], "start_line": 480, "end_line": 488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "rk_vonmises", "long_name": "rk_vonmises( rk_state * state , double mu , double kappa)", "filename": "distributions.c", "nloc": 43, "complexity": 8, "token_count": 278, "parameters": [ "state", "mu", "kappa" ], "start_line": 490, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "rk_pareto", "long_name": "rk_pareto( rk_state * state , double a)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "a" ], "start_line": 537, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_weibull", "long_name": "rk_weibull( rk_state * state , double a)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "a" ], "start_line": 542, "end_line": 545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_power", "long_name": "rk_power( rk_state * state , double a)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "state", "a" ], "start_line": 547, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_laplace", "long_name": "rk_laplace( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 13, "complexity": 2, "token_count": 66, "parameters": [ "state", "loc", "scale" ], "start_line": 552, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "rk_gumbel", "long_name": "rk_gumbel( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "state", "loc", "scale" ], "start_line": 567, "end_line": 573, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "rk_logistic", "long_name": "rk_logistic( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "state", "loc", "scale" ], "start_line": 575, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "rk_lognormal", "long_name": "rk_lognormal( rk_state * state , double mean , double sigma)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "state", "mean", "sigma" ], "start_line": 583, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_rayleigh", "long_name": "rk_rayleigh( rk_state * state , double mode)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "state", "mode" ], "start_line": 588, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_wald", "long_name": "rk_wald( rk_state * state , double mean , double scale)", "filename": "distributions.c", "nloc": 17, "complexity": 2, "token_count": 106, "parameters": [ "state", "mean", "scale" ], "start_line": 593, "end_line": 610, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "rk_zipf", "long_name": "rk_zipf( rk_state * state , double a)", "filename": "distributions.c", "nloc": 15, "complexity": 2, "token_count": 119, "parameters": [ "state", "a" ], "start_line": 612, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "rk_geometric_search", "long_name": "rk_geometric_search( rk_state * state , double p)", "filename": "distributions.c", "nloc": 17, "complexity": 2, "token_count": 70, "parameters": [ "state", "p" ], "start_line": 629, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "rk_geometric_inversion", "long_name": "rk_geometric_inversion( rk_state * state , double p)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "state", "p" ], "start_line": 648, "end_line": 651, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_geometric", "long_name": "rk_geometric( rk_state * state , double p)", "filename": "distributions.c", "nloc": 10, "complexity": 2, "token_count": 38, "parameters": [ "state", "p" ], "start_line": 653, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "rk_hypergeometric_hyp", "long_name": "rk_hypergeometric_hyp( rk_state * state , long good , long bad , long sample)", "filename": "distributions.c", "nloc": 19, "complexity": 4, "token_count": 129, "parameters": [ "state", "good", "bad", "sample" ], "start_line": 664, "end_line": 684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "rk_hypergeometric_hrua", "long_name": "rk_hypergeometric_hrua( rk_state * state , long good , long bad , long sample)", "filename": "distributions.c", "nloc": 36, "complexity": 9, "token_count": 416, "parameters": [ "state", "good", "bad", "sample" ], "start_line": 690, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "rk_hypergeometric", "long_name": "rk_hypergeometric( rk_state * state , long good , long bad , long sample)", "filename": "distributions.c", "nloc": 10, "complexity": 2, "token_count": 52, "parameters": [ "state", "good", "bad", "sample" ], "start_line": 745, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "rk_triangular", "long_name": "rk_triangular( rk_state * state , double left , double mode , double right)", "filename": "distributions.c", "nloc": 18, "complexity": 2, "token_count": 107, "parameters": [ "state", "left", "mode", "right" ], "start_line": 756, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "methods_before": [ { "name": "rk_normal", "long_name": "rk_normal( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "loc", "scale" ], "start_line": 33, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_standard_exponential", "long_name": "rk_standard_exponential( rk_state * state)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "state" ], "start_line": 38, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "rk_exponential", "long_name": "rk_exponential( rk_state * state , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "state", "scale" ], "start_line": 44, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_uniform", "long_name": "rk_uniform( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "loc", "scale" ], "start_line": 49, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_standard_gamma", "long_name": "rk_standard_gamma( rk_state * state , double shape)", "filename": "distributions.c", "nloc": 54, "complexity": 10, "token_count": 271, "parameters": [ "state", "shape" ], "start_line": 57, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "rk_gamma", "long_name": "rk_gamma( rk_state * state , double shape , double scale)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "shape", "scale" ], "start_line": 117, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_beta", "long_name": "rk_beta( rk_state * state , double a , double b)", "filename": "distributions.c", "nloc": 25, "complexity": 5, "token_count": 131, "parameters": [ "state", "a", "b" ], "start_line": 122, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "rk_chisquare", "long_name": "rk_chisquare( rk_state * state , double df)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "state", "df" ], "start_line": 152, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_noncentral_chisquare", "long_name": "rk_noncentral_chisquare( rk_state * state , double df , double nonc)", "filename": "distributions.c", "nloc": 7, "complexity": 1, "token_count": 49, "parameters": [ "state", "df", "nonc" ], "start_line": 157, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "rk_f", "long_name": "rk_f( rk_state * state , double dfnum , double dfden)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "state", "dfnum", "dfden" ], "start_line": 166, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_noncentral_f", "long_name": "rk_noncentral_f( rk_state * state , double dfnum , double dfden , double nonc)", "filename": "distributions.c", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "state", "dfnum", "dfden", "nonc" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "rk_binomial_btpe", "long_name": "rk_binomial_btpe( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 126, "complexity": 21, "token_count": 1119, "parameters": [ "state", "n", "p" ], "start_line": 177, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 139, "top_nesting_level": 0 }, { "name": "rk_binomial_waiting", "long_name": "rk_binomial_waiting( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 20, "complexity": 3, "token_count": 89, "parameters": [ "state", "n", "p" ], "start_line": 317, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rk_binomial", "long_name": "rk_binomial( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 27, "complexity": 4, "token_count": 104, "parameters": [ "state", "n", "p" ], "start_line": 341, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "rk_negative_binomial", "long_name": "rk_negative_binomial( rk_state * state , long n , double p)", "filename": "distributions.c", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "state", "n", "p" ], "start_line": 371, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "rk_poisson_mult", "long_name": "rk_poisson_mult( rk_state * state , double lam)", "filename": "distributions.c", "nloc": 21, "complexity": 3, "token_count": 73, "parameters": [ "state", "lam" ], "start_line": 379, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "rk_poisson_ptrs", "long_name": "rk_poisson_ptrs( rk_state * state , double lam)", "filename": "distributions.c", "nloc": 32, "complexity": 8, "token_count": 236, "parameters": [ "state", "lam" ], "start_line": 404, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "rk_poisson", "long_name": "rk_poisson( rk_state * state , double lam)", "filename": "distributions.c", "nloc": 11, "complexity": 2, "token_count": 38, "parameters": [ "state", "lam" ], "start_line": 442, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "rk_standard_cauchy", "long_name": "rk_standard_cauchy( rk_state * state)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "state" ], "start_line": 454, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_standard_t", "long_name": "rk_standard_t( rk_state * state , double df)", "filename": "distributions.c", "nloc": 8, "complexity": 1, "token_count": 55, "parameters": [ "state", "df" ], "start_line": 459, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "rk_vonmises", "long_name": "rk_vonmises( rk_state * state , double mu , double kappa)", "filename": "distributions.c", "nloc": 43, "complexity": 8, "token_count": 278, "parameters": [ "state", "mu", "kappa" ], "start_line": 469, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "rk_pareto", "long_name": "rk_pareto( rk_state * state , double a)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "a" ], "start_line": 516, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_weibull", "long_name": "rk_weibull( rk_state * state , double a)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "state", "a" ], "start_line": 521, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_power", "long_name": "rk_power( rk_state * state , double a)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "state", "a" ], "start_line": 526, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "rk_laplace", "long_name": "rk_laplace( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 13, "complexity": 2, "token_count": 66, "parameters": [ "state", "loc", "scale" ], "start_line": 552, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "rk_geometric", "long_name": "rk_geometric( rk_state * state , double p)", "filename": "distributions.c", "nloc": 10, "complexity": 2, "token_count": 38, "parameters": [ "state", "p" ], "start_line": 653, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "rk_zipf", "long_name": "rk_zipf( rk_state * state , double a)", "filename": "distributions.c", "nloc": 15, "complexity": 2, "token_count": 119, "parameters": [ "state", "a" ], "start_line": 612, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "rk_triangular", "long_name": "rk_triangular( rk_state * state , double left , double mode , double right)", "filename": "distributions.c", "nloc": 18, "complexity": 2, "token_count": 107, "parameters": [ "state", "left", "mode", "right" ], "start_line": 756, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "rk_rayleigh", "long_name": "rk_rayleigh( rk_state * state , double mode)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "state", "mode" ], "start_line": 588, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_gumbel", "long_name": "rk_gumbel( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "state", "loc", "scale" ], "start_line": 567, "end_line": 573, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "rk_hypergeometric_hrua", "long_name": "rk_hypergeometric_hrua( rk_state * state , long good , long bad , long sample)", "filename": "distributions.c", "nloc": 36, "complexity": 9, "token_count": 416, "parameters": [ "state", "good", "bad", "sample" ], "start_line": 690, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "rk_geometric_search", "long_name": "rk_geometric_search( rk_state * state , double p)", "filename": "distributions.c", "nloc": 17, "complexity": 2, "token_count": 70, "parameters": [ "state", "p" ], "start_line": 629, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "rk_wald", "long_name": "rk_wald( rk_state * state , double mean , double scale)", "filename": "distributions.c", "nloc": 17, "complexity": 2, "token_count": 106, "parameters": [ "state", "mean", "scale" ], "start_line": 593, "end_line": 610, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "rk_logistic", "long_name": "rk_logistic( rk_state * state , double loc , double scale)", "filename": "distributions.c", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "state", "loc", "scale" ], "start_line": 575, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "rk_geometric_inversion", "long_name": "rk_geometric_inversion( rk_state * state , double p)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "state", "p" ], "start_line": 648, "end_line": 651, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_lognormal", "long_name": "rk_lognormal( rk_state * state , double mean , double sigma)", "filename": "distributions.c", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "state", "mean", "sigma" ], "start_line": 583, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "rk_hypergeometric_hyp", "long_name": "rk_hypergeometric_hyp( rk_state * state , long good , long bad , long sample)", "filename": "distributions.c", "nloc": 19, "complexity": 4, "token_count": 129, "parameters": [ "state", "good", "bad", "sample" ], "start_line": 664, "end_line": 684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "rk_hypergeometric", "long_name": "rk_hypergeometric( rk_state * state , long good , long bad , long sample)", "filename": "distributions.c", "nloc": 10, "complexity": 2, "token_count": 52, "parameters": [ "state", "good", "bad", "sample" ], "start_line": 745, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "nloc": 612, "complexity": 111, "token_count": 4110, "diff_parsed": { "added": [ "/* The implementations of rk_hypergeometric_hyp(), rk_hypergeometric_hrua(),", " * and rk_triangular() were adapted from Ivan Frohne's rv.py which has this", " * license:", " *", " * Copyright 1998 by Ivan Frohne; Wasilla, Alaska, U.S.A.", " * All Rights Reserved", " *", " * Permission to use, copy, modify and distribute this software and its", " * documentation for any purpose, free of charge, is granted subject to the", " * following conditions:", " * The above copyright notice and this permission notice shall be included in", " * all copies or substantial portions of the software.", " *", " * THE SOFTWARE AND DOCUMENTATION IS PROVIDED WITHOUT WARRANTY OF ANY KIND,", " * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO MERCHANTABILITY, FITNESS", " * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR", " * OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM OR DAMAGES IN A CONTRACT", " * ACTION, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE", " * SOFTWARE OR ITS DOCUMENTATION.", " */", "", "", "double rk_laplace(rk_state *state, double loc, double scale)", "{", " double U;", "", " U = rk_double(state);", " if (U < 0.5)", " {", " U = loc + scale * log(U + U);", " } else", " {", " U = loc - scale * log(2.0 - U - U);", " }", " return U;", "}", "", "double rk_gumbel(rk_state *state, double loc, double scale)", "{", " double U;", "", " U = 1.0 - rk_double(state);", " return loc - scale * log(-log(U));", "}", "", "double rk_logistic(rk_state *state, double loc, double scale)", "{", " double U;", "", " U = rk_double(state);", " return loc + scale * log(U/(1.0 - U));", "}", "", "double rk_lognormal(rk_state *state, double mean, double sigma)", "{", " return exp(rk_normal(state, mean, sigma));", "}", "", "double rk_rayleigh(rk_state *state, double mode)", "{", " return mode*sqrt(-2.0 * log(1.0 - rk_double(state)));", "}", "", "double rk_wald(rk_state *state, double mean, double scale)", "{", " double U, X, Y;", " double mu_2l;", "", " mu_2l = mean / (2*scale);", " Y = rk_gauss(state);", " Y = mean*Y*Y;", " X = mean + mu_2l*(Y - sqrt(4*scale*Y + Y*Y));", " U = rk_double(state);", " if (U <= mean/(mean+X))", " {", " return X;", " } else", " {", " return mean*mean/X;", " }", "}", "", "long rk_zipf(rk_state *state, double a)", "{", " double T, U, V;", " long X;", " double b;", "", " b = pow(2.0, a-1.0);", " do", " {", " U = rk_double(state);", " V = rk_double(state);", " X = (long)floor(pow(U, -1.0/(a-1.0)));", " T = pow(1.0 + 1.0/X, a-1.0);", " } while ((V *X*(T-1.0)/(b-1.0)) > (T/b));", " return X;", "}", "", "long rk_geometric_search(rk_state *state, double p)", "{", " double U;", " long X;", " double sum, prod, q;", "", " X = 1;", " sum = prod = p;", " q = 1.0 - p;", " U = rk_double(state);", " while (U > sum)", " {", " prod *= q;", " sum += prod;", " X++;", " }", " return X;", "}", "", "long rk_geometric_inversion(rk_state *state, double p)", "{", " return (long)ceil(log(1.0-rk_double(state))/log(1.0-p));", "}", "", "long rk_geometric(rk_state *state, double p)", "{", " if (p >= 0.333333333333333333333333)", " {", " return rk_geometric_search(state, p);", " } else", " {", " return rk_geometric_inversion(state, p);", " }", "}", "", "long rk_hypergeometric_hyp(rk_state *state, long good, long bad, long sample)", "{", " long d1, K, Z;", " double d2, U, Y;", "", " d1 = bad + good - sample;", " d2 = (double)min(bad, good);", "", " Y = d2;", " K = sample;", " while (Y > 0.0)", " {", " U = rk_double(state);", " Y -= (long)floor(U + Y/(d1 + K));", " K--;", " if (K == 0) break;", " }", " Z = (long)(d2 - Y);", " if (bad > good) Z = sample - Z;", " return Z;", "}", "", "/* D1 = 2*sqrt(2/e) */", "/* D2 = 3 - 2*sqrt(3/e) */", "#define D1 1.7155277699214135", "#define D2 0.8989161620588988", "long rk_hypergeometric_hrua(rk_state *state, long good, long bad, long sample)", "{", " long mingoodbad, maxgoodbad, popsize, m, d9;", " double d4, d5, d6, d7, d8, d10, d11;", " long Z;", " double T, W, X, Y;", "", " mingoodbad = min(good, bad);", " popsize = good + bad;", " maxgoodbad = max(good, bad);", " m = min(sample, popsize - sample);", " d4 = ((double)mingoodbad) / popsize;", " d5 = 1.0 - d4;", " d6 = m*d4 + 0.5;", " d7 = sqrt((popsize - m) * sample * d4 *d5 / (popsize-1) + 0.5);", " d8 = D1*d7 + D2;", " d9 = (long)floor((double)((m+1)*(mingoodbad+1))/(popsize+2));", " d10 = (lgam(d9+1) + lgam(mingoodbad-d9+1) + lgam(m-d9+1) +", " lgam(maxgoodbad-m+d9+1));", " d11 = min(min(m, mingoodbad)+1.0, floor(d6+16*d7));", " /* 16 for 16-decimal-digit precision in D1 and D2 */", "", " while (1)", " {", " X = rk_double(state);", " Y = rk_double(state);", " W = d6 + d8*(Y- 0.5)/X;", "", " /* fast rejection: */", " if ((W < 0.0) || (W >= d11)) continue;", "", " Z = (long)floor(W);", " T = d10 - (lgam(Z+1) + lgam(mingoodbad-Z+1) + lgam(m-Z+1) +", " lgam(maxgoodbad-m+Z+1));", "", " /* fast acceptance: */", " if ((X*(4.0-X)-3.0) <= T) break;", "", " /* fast rejection: */", " if (X*(X-T) >= 1) continue;", "", " if (2.0*log(X) <= T) break; /* acceptance */", " }", "", " /* this is a correction to HRUA* by Ivan Frohne in rv.py */", " if (bad > good) Z = m - Z;", "", " /* another fix from rv.py to allow sample to exceed popsize/2 */", " if (m < sample) Z = bad - Z;", "", " return Z;", "}", "#undef D1", "#undef D2", "", "long rk_hypergeometric(rk_state *state, long good, long bad, long sample)", "{", " if (sample > 10)", " {", " return rk_hypergeometric_hrua(state, good, bad, sample);", " } else", " {", " return rk_hypergeometric_hyp(state, good, bad, sample);", " }", "}", "", "double rk_triangular(rk_state *state, double left, double mode, double right)", "{", " double base, leftbase, ratio, leftprod, rightprod;", " double U;", "", " base = right - left;", " leftbase = mode - left;", " ratio = leftbase / base;", " leftprod = leftbase*base;", " rightprod = (right - mode)*base;", "", " U = rk_double(state);", " if (U <= ratio)", " {", " return left + sqrt(U*leftprod);", " } else", " {", " return right - sqrt((1.0 - U) * rightprod);", " }", "}" ], "deleted": [] } }, { "old_path": "scipy/corelib/mtrand/distributions.h", "new_path": "scipy/corelib/mtrand/distributions.h", "filename": "distributions.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -136,6 +136,40 @@ extern double rk_weibull(rk_state *state, double a);\n /* Power distribution via inversion (Devroye p. 262) */\n extern double rk_power(rk_state *state, double a);\n \n+/* Laplace distribution */\n+extern double rk_laplace(rk_state *state, double loc, double scale);\n+\n+/* Gumbel distribution */\n+extern double rk_gumbel(rk_state *state, double loc, double scale);\n+\n+/* Logistic distribution */\n+extern double rk_logistic(rk_state *state, double loc, double scale);\n+\n+/* Log-normal distribution */\n+extern double rk_lognormal(rk_state *state, double mean, double sigma);\n+\n+/* Rayleigh distribution */\n+extern double rk_rayleigh(rk_state *state, double mode);\n+\n+/* Wald distribution */\n+extern double rk_wald(rk_state *state, double mean, double scale);\n+\n+/* Zipf distribution */\n+extern long rk_zipf(rk_state *state, double a);\n+\n+/* Geometric distribution */\n+extern long rk_geometric(rk_state *state, double p);\n+extern long rk_geometric_search(rk_state *state, double p);\n+extern long rk_geometric_inversion(rk_state *state, double p);\n+\n+/* Hypergeometric distribution */\n+extern long rk_hypergeometric(rk_state *state, long good, long bad, long sample);\n+extern long rk_hypergeometric_hyp(rk_state *state, long good, long bad, long sample);\n+extern long rk_hypergeometric_hrua(rk_state *state, long good, long bad, long sample);\n+\n+/* Triangular distribution */\n+extern double rk_triangular(rk_state *state, double left, double mode, double right);\n+\n #ifdef __cplusplus\n }\n #endif\n", "added_lines": 34, "deleted_lines": 0, "source_code": "/* Copyright 2005 Robert Kern (robert.kern@gmail.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n * \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n#ifndef _RK_DISTR_\n#define _RK_DISTR_\n\n#include \"randomkit.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* References:\n * \n * Devroye, Luc. _Non-Uniform Random Variate Generation_.\n * Springer-Verlag, New York, 1986.\n * http://cgm.cs.mcgill.ca/~luc/rnbookindex.html\n * \n * Kachitvichyanukul, V. and Schmeiser, B. W. Binomial Random Variate\n * Generation. Communications of the ACM, 31, 2 (February, 1988) 216.\n *\n * Hoermann, W. The Transformed Rejection Method for Generating Poisson Random\n * Variables, Insurance: Mathematics and Economics, (to appear)\n * http://citeseer.csail.mit.edu/151115.html\n */\n\n/* Normal distribution with mean=loc and standard deviation=scale. */\nextern double rk_normal(rk_state *state, double loc, double scale);\n\n/* Standard exponential distribution (mean=1) computed by inversion of the \n * CDF. */\nextern double rk_standard_exponential(rk_state *state);\n\n/* Exponential distribution with mean=scale. */\nextern double rk_exponential(rk_state *state, double scale);\n\n/* Uniform distribution on interval [loc, loc+scale). */\nextern double rk_uniform(rk_state *state, double loc, double scale);\n\n/* Standard gamma distribution with shape parameter. \n * When shape < 1, the algorithm given by (Devroye p. 304) is used.\n * When shape == 1, a Exponential variate is generated.\n * When shape > 1, Cheng's GB rejection algorithm from Devroye p. 413 with the\n * corrections given in the Errata is used.\n */\nextern double rk_standard_gamma(rk_state *state, double shape);\n\n/* Gamma distribution with shape and scale. */\nextern double rk_gamma(rk_state *state, double shape, double scale);\n\n/* Beta distribution computed by combining two gamma variates (Devroye p. 432).\n */\nextern double rk_beta(rk_state *state, double a, double b);\n\n/* Chi^2 distribution computed by transforming a gamma variate (it being a\n * special case Gamma(df/2, 2)). */\nextern double rk_chisquare(rk_state *state, double df);\n\n/* Noncentral Chi^2 distribution computed by modifying a Chi^2 variate. */\nextern double rk_noncentral_chisquare(rk_state *state, double df, double nonc);\n\n/* F distribution computed by taking the ratio of two Chi^2 variates. */\nextern double rk_f(rk_state *state, double dfnum, double dfden);\n\n/* Noncentral F distribution computed by taking the ratio of a noncentral Chi^2\n * and a Chi^2 variate. */\nextern double rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc);\n\n/* Binomial distribution with n Bernoulli trials with success probability p.\n * When n*p <= 30, the \"Second waiting time method\" given by (Devroye p. 525) is\n * used. Otherwise, the BTPE algorithm of (Kachitvichyanukul and Schmeiser 1988)\n * is used. */\nextern long rk_binomial(rk_state *state, long n, double p);\n\n/* Binomial distribution using BTPE. */\nextern long rk_binomial_btpe(rk_state *state, long n, double p);\n\n/* Binomial distribution using the waiting time algorithm. */\nextern long rk_binomial_waiting(rk_state *state, long n, double p);\n\n/* Negative binomial distribution computed by generating a Gamma(n, (1-p)/p)\n * variate Y and returning a Poisson(Y) variate (Devroye p. 543). */\nextern long rk_negative_binomial(rk_state *state, long n, double p);\n\n/* Poisson distribution with mean=lam.\n * When lam < 10, a basic algorithm using repeated multiplications of uniform\n * variates is used (Devroye p. 504).\n * When lam >= 10, algorithm PTRS from (Hoermann 1992) is used.\n */\nextern long rk_poisson(rk_state *state, double lam);\n\n/* Poisson distribution computed by repeated multiplication of uniform variates.\n */\nextern long rk_poisson_mult(rk_state *state, double lam);\n\n/* Poisson distribution computer by the PTRS algorithm. */\nextern long rk_poisson_ptrs(rk_state *state, double lam);\n\n/* Standard Cauchy distribution computed by dividing standard gaussians \n * (Devroye p. 451). */\nextern double rk_standard_cauchy(rk_state *state);\n\n/* Standard t-distribution with df degrees of freedom (Devroye p. 445 as\n * corrected in the Errata). */\nextern double rk_standard_t(rk_state *state, double df);\n\n/* von Mises circular distribution with center mu and shape kappa on [-pi,pi]\n * (Devroye p. 476 as corrected in the Errata). */\nextern double rk_vonmises(rk_state *state, double mu, double kappa);\n\n/* Pareto distribution via inversion (Devroye p. 262) */\nextern double rk_pareto(rk_state *state, double a);\n\n/* Weibull distribution via inversion (Devroye p. 262) */\nextern double rk_weibull(rk_state *state, double a);\n\n/* Power distribution via inversion (Devroye p. 262) */\nextern double rk_power(rk_state *state, double a);\n\n/* Laplace distribution */\nextern double rk_laplace(rk_state *state, double loc, double scale);\n\n/* Gumbel distribution */\nextern double rk_gumbel(rk_state *state, double loc, double scale);\n\n/* Logistic distribution */\nextern double rk_logistic(rk_state *state, double loc, double scale);\n\n/* Log-normal distribution */\nextern double rk_lognormal(rk_state *state, double mean, double sigma);\n\n/* Rayleigh distribution */\nextern double rk_rayleigh(rk_state *state, double mode);\n\n/* Wald distribution */\nextern double rk_wald(rk_state *state, double mean, double scale);\n\n/* Zipf distribution */\nextern long rk_zipf(rk_state *state, double a);\n\n/* Geometric distribution */\nextern long rk_geometric(rk_state *state, double p);\nextern long rk_geometric_search(rk_state *state, double p);\nextern long rk_geometric_inversion(rk_state *state, double p);\n\n/* Hypergeometric distribution */\nextern long rk_hypergeometric(rk_state *state, long good, long bad, long sample);\nextern long rk_hypergeometric_hyp(rk_state *state, long good, long bad, long sample);\nextern long rk_hypergeometric_hrua(rk_state *state, long good, long bad, long sample);\n\n/* Triangular distribution */\nextern double rk_triangular(rk_state *state, double left, double mode, double right);\n\n#ifdef __cplusplus\n}\n#endif\n\n\n#endif /* _RK_DISTR_ */\n", "source_code_before": "/* Copyright 2005 Robert Kern (robert.kern@gmail.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n * \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n#ifndef _RK_DISTR_\n#define _RK_DISTR_\n\n#include \"randomkit.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* References:\n * \n * Devroye, Luc. _Non-Uniform Random Variate Generation_.\n * Springer-Verlag, New York, 1986.\n * http://cgm.cs.mcgill.ca/~luc/rnbookindex.html\n * \n * Kachitvichyanukul, V. and Schmeiser, B. W. Binomial Random Variate\n * Generation. Communications of the ACM, 31, 2 (February, 1988) 216.\n *\n * Hoermann, W. The Transformed Rejection Method for Generating Poisson Random\n * Variables, Insurance: Mathematics and Economics, (to appear)\n * http://citeseer.csail.mit.edu/151115.html\n */\n\n/* Normal distribution with mean=loc and standard deviation=scale. */\nextern double rk_normal(rk_state *state, double loc, double scale);\n\n/* Standard exponential distribution (mean=1) computed by inversion of the \n * CDF. */\nextern double rk_standard_exponential(rk_state *state);\n\n/* Exponential distribution with mean=scale. */\nextern double rk_exponential(rk_state *state, double scale);\n\n/* Uniform distribution on interval [loc, loc+scale). */\nextern double rk_uniform(rk_state *state, double loc, double scale);\n\n/* Standard gamma distribution with shape parameter. \n * When shape < 1, the algorithm given by (Devroye p. 304) is used.\n * When shape == 1, a Exponential variate is generated.\n * When shape > 1, Cheng's GB rejection algorithm from Devroye p. 413 with the\n * corrections given in the Errata is used.\n */\nextern double rk_standard_gamma(rk_state *state, double shape);\n\n/* Gamma distribution with shape and scale. */\nextern double rk_gamma(rk_state *state, double shape, double scale);\n\n/* Beta distribution computed by combining two gamma variates (Devroye p. 432).\n */\nextern double rk_beta(rk_state *state, double a, double b);\n\n/* Chi^2 distribution computed by transforming a gamma variate (it being a\n * special case Gamma(df/2, 2)). */\nextern double rk_chisquare(rk_state *state, double df);\n\n/* Noncentral Chi^2 distribution computed by modifying a Chi^2 variate. */\nextern double rk_noncentral_chisquare(rk_state *state, double df, double nonc);\n\n/* F distribution computed by taking the ratio of two Chi^2 variates. */\nextern double rk_f(rk_state *state, double dfnum, double dfden);\n\n/* Noncentral F distribution computed by taking the ratio of a noncentral Chi^2\n * and a Chi^2 variate. */\nextern double rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc);\n\n/* Binomial distribution with n Bernoulli trials with success probability p.\n * When n*p <= 30, the \"Second waiting time method\" given by (Devroye p. 525) is\n * used. Otherwise, the BTPE algorithm of (Kachitvichyanukul and Schmeiser 1988)\n * is used. */\nextern long rk_binomial(rk_state *state, long n, double p);\n\n/* Binomial distribution using BTPE. */\nextern long rk_binomial_btpe(rk_state *state, long n, double p);\n\n/* Binomial distribution using the waiting time algorithm. */\nextern long rk_binomial_waiting(rk_state *state, long n, double p);\n\n/* Negative binomial distribution computed by generating a Gamma(n, (1-p)/p)\n * variate Y and returning a Poisson(Y) variate (Devroye p. 543). */\nextern long rk_negative_binomial(rk_state *state, long n, double p);\n\n/* Poisson distribution with mean=lam.\n * When lam < 10, a basic algorithm using repeated multiplications of uniform\n * variates is used (Devroye p. 504).\n * When lam >= 10, algorithm PTRS from (Hoermann 1992) is used.\n */\nextern long rk_poisson(rk_state *state, double lam);\n\n/* Poisson distribution computed by repeated multiplication of uniform variates.\n */\nextern long rk_poisson_mult(rk_state *state, double lam);\n\n/* Poisson distribution computer by the PTRS algorithm. */\nextern long rk_poisson_ptrs(rk_state *state, double lam);\n\n/* Standard Cauchy distribution computed by dividing standard gaussians \n * (Devroye p. 451). */\nextern double rk_standard_cauchy(rk_state *state);\n\n/* Standard t-distribution with df degrees of freedom (Devroye p. 445 as\n * corrected in the Errata). */\nextern double rk_standard_t(rk_state *state, double df);\n\n/* von Mises circular distribution with center mu and shape kappa on [-pi,pi]\n * (Devroye p. 476 as corrected in the Errata). */\nextern double rk_vonmises(rk_state *state, double mu, double kappa);\n\n/* Pareto distribution via inversion (Devroye p. 262) */\nextern double rk_pareto(rk_state *state, double a);\n\n/* Weibull distribution via inversion (Devroye p. 262) */\nextern double rk_weibull(rk_state *state, double a);\n\n/* Power distribution via inversion (Devroye p. 262) */\nextern double rk_power(rk_state *state, double a);\n\n#ifdef __cplusplus\n}\n#endif\n\n\n#endif /* _RK_DISTR_ */\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 41, "complexity": 0, "token_count": 534, "diff_parsed": { "added": [ "/* Laplace distribution */", "extern double rk_laplace(rk_state *state, double loc, double scale);", "", "/* Gumbel distribution */", "extern double rk_gumbel(rk_state *state, double loc, double scale);", "", "/* Logistic distribution */", "extern double rk_logistic(rk_state *state, double loc, double scale);", "", "/* Log-normal distribution */", "extern double rk_lognormal(rk_state *state, double mean, double sigma);", "", "/* Rayleigh distribution */", "extern double rk_rayleigh(rk_state *state, double mode);", "", "/* Wald distribution */", "extern double rk_wald(rk_state *state, double mean, double scale);", "", "/* Zipf distribution */", "extern long rk_zipf(rk_state *state, double a);", "", "/* Geometric distribution */", "extern long rk_geometric(rk_state *state, double p);", "extern long rk_geometric_search(rk_state *state, double p);", "extern long rk_geometric_inversion(rk_state *state, double p);", "", "/* Hypergeometric distribution */", "extern long rk_hypergeometric(rk_state *state, long good, long bad, long sample);", "extern long rk_hypergeometric_hyp(rk_state *state, long good, long bad, long sample);", "extern long rk_hypergeometric_hrua(rk_state *state, long good, long bad, long sample);", "", "/* Triangular distribution */", "extern double rk_triangular(rk_state *state, double left, double mode, double right);", "" ], "deleted": [] } }, { "old_path": "scipy/corelib/mtrand/mtrand.c", "new_path": "scipy/corelib/mtrand/mtrand.c", "filename": "mtrand.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-/* Generated by Pyrex 0.9.3.1 on Wed Sep 28 22:52:52 2005 */\n+/* Generated by Pyrex 0.9.3.1 on Thu Oct 6 21:56:32 2005 */\n \n #include \"Python.h\"\n #include \"structmember.h\"\n@@ -85,25 +85,44 @@ static PyObject *__pyx_k30;\n static PyObject *__pyx_k31;\n static PyObject *__pyx_k32;\n static PyObject *__pyx_k33;\n-static PyObject *__pyx_k34;\n-static PyObject *__pyx_k35;\n-static double __pyx_k36;\n-static PyObject *__pyx_k37;\n-static PyObject *__pyx_k38;\n+static double __pyx_k34;\n+static double __pyx_k35;\n+static PyObject *__pyx_k36;\n+static double __pyx_k37;\n+static double __pyx_k38;\n static PyObject *__pyx_k39;\n+static double __pyx_k40;\n+static double __pyx_k41;\n+static PyObject *__pyx_k42;\n+static double __pyx_k43;\n+static double __pyx_k44;\n+static PyObject *__pyx_k45;\n+static PyObject *__pyx_k46;\n+static PyObject *__pyx_k47;\n+static PyObject *__pyx_k48;\n+static PyObject *__pyx_k49;\n+static PyObject *__pyx_k50;\n+static double __pyx_k51;\n+static PyObject *__pyx_k52;\n+static PyObject *__pyx_k53;\n+static PyObject *__pyx_k54;\n+static PyObject *__pyx_k55;\n+static PyObject *__pyx_k56;\n+static PyObject *__pyx_k57;\n static PyObject *(__pyx_f_6mtrand_cont0_array(rk_state (*),double ((*)(rk_state (*))),PyObject *)); /*proto*/\n static PyObject *(__pyx_f_6mtrand_cont1_array(rk_state (*),double ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\n static PyObject *(__pyx_f_6mtrand_cont2_array(rk_state (*),double ((*)(rk_state (*),double ,double )),PyObject *,double ,double )); /*proto*/\n static PyObject *(__pyx_f_6mtrand_cont3_array(rk_state (*),double ((*)(rk_state (*),double ,double ,double )),PyObject *,double ,double ,double )); /*proto*/\n static PyObject *(__pyx_f_6mtrand_disc0_array(rk_state (*),long ((*)(rk_state (*))),PyObject *)); /*proto*/\n static PyObject *(__pyx_f_6mtrand_discnp_array(rk_state (*),long ((*)(rk_state (*),long ,double )),PyObject *,long ,double )); /*proto*/\n+static PyObject *(__pyx_f_6mtrand_discnmN_array(rk_state (*),long ((*)(rk_state (*),long ,long ,long )),PyObject *,long ,long ,long )); /*proto*/\n static PyObject *(__pyx_f_6mtrand_discd_array(rk_state (*),long ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\n static double (__pyx_f_6mtrand_kahan_sum(double (*),long )); /*proto*/\n \n /* Implementation of mtrand */\n \n \n-static PyObject *__pyx_n_scipy;\n+static PyObject *__pyx_n__sp;\n static PyObject *__pyx_n__rand;\n static PyObject *__pyx_n_get_state;\n static PyObject *__pyx_n_set_state;\n@@ -131,13 +150,24 @@ static PyObject *__pyx_n_vonmises;\n static PyObject *__pyx_n_pareto;\n static PyObject *__pyx_n_weibull;\n static PyObject *__pyx_n_power;\n+static PyObject *__pyx_n_laplace;\n+static PyObject *__pyx_n_gumbel;\n+static PyObject *__pyx_n_logistic;\n+static PyObject *__pyx_n_lognormal;\n+static PyObject *__pyx_n_rayleigh;\n+static PyObject *__pyx_n_wald;\n+static PyObject *__pyx_n_triangular;\n static PyObject *__pyx_n_binomial;\n static PyObject *__pyx_n_negative_binomial;\n static PyObject *__pyx_n_poisson;\n+static PyObject *__pyx_n_zipf;\n+static PyObject *__pyx_n_geometric;\n+static PyObject *__pyx_n_hypergeometric;\n static PyObject *__pyx_n_multivariate_normal;\n static PyObject *__pyx_n_multinomial;\n static PyObject *__pyx_n_shuffle;\n static PyObject *__pyx_n_permutation;\n+static PyObject *__pyx_n_scipy;\n \n static PyObject *__pyx_n_empty;\n static PyObject *__pyx_n_Float64;\n@@ -155,12 +185,12 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":111 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":123 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":112 */\n- __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":124 */\n+ __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -168,19 +198,19 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":114 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":126 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -188,22 +218,22 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":115 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":127 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":116 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":117 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":129 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":118 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":130 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n __pyx_L3:;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":119 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -237,12 +267,12 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":127 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":139 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */\n- __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":140 */\n+ __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -250,19 +280,19 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":130 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":142 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -270,22 +300,22 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":143 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":132 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":133 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":134 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":146 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n __pyx_L3:;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":135 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -319,12 +349,12 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":156 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */\n- __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":157 */\n+ __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -332,19 +362,19 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":159 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -352,22 +382,22 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":148 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":160 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":149 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":161 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":150 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":151 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":163 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b);\n __pyx_L3:;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":152 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":164 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -401,12 +431,12 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":174 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":163 */\n- __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":175 */\n+ __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -414,19 +444,19 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":165 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":177 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -434,22 +464,22 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":166 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":178 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":167 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":168 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":180 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":169 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":181 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c);\n __pyx_L3:;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":170 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -485,12 +515,12 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*_\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":178 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":190 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */\n- __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":191 */\n+ __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -498,19 +528,19 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*_\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":181 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":193 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -518,22 +548,22 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*_\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":194 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":183 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":184 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":196 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":185 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":197 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n __pyx_L3:;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":186 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -567,12 +597,12 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":194 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":206 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */\n- __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":207 */\n+ __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -580,19 +610,19 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":197 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":209 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -600,22 +630,22 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":210 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":199 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":200 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":212 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":201 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":213 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p);\n __pyx_L3:;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":202 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -636,6 +666,88 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*\n return __pyx_r;\n }\n \n+static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,long ,long )),PyObject *__pyx_v_size,long __pyx_v_n,long __pyx_v_m,long __pyx_v_N) {\n+ long (*__pyx_v_array_data);\n+ PyArrayObject *__pyx_v_array;\n+ long __pyx_v_length;\n+ long __pyx_v_i;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ Py_INCREF(__pyx_v_size);\n+ __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":223 */\n+ __pyx_1 = __pyx_v_size == Py_None;\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":224 */\n+ __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+ goto __pyx_L2;\n+ }\n+ /*else*/ {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":226 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n+ Py_INCREF(__pyx_v_size);\n+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n+ PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n+ __pyx_4 = 0;\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_INCREF(((PyObject *)__pyx_4));\n+ Py_DECREF(((PyObject *)__pyx_v_array));\n+ __pyx_v_array = ((PyObject *)__pyx_4);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":227 */\n+ __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */\n+ __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */\n+ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":230 */\n+ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N);\n+ __pyx_L3:;\n+ }\n+ __pyx_L4:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":231 */\n+ Py_INCREF(((PyObject *)__pyx_v_array));\n+ __pyx_r = ((PyObject *)__pyx_v_array);\n+ goto __pyx_L0;\n+ }\n+ __pyx_L2:;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.discnmN_array\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_array);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n static PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n@@ -649,12 +761,12 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*_\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":210 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":239 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */\n- __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":240 */\n+ __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -662,19 +774,19 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*_\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":213 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":242 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -682,22 +794,22 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*_\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":243 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":215 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":244 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":216 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":245 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":217 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":246 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n __pyx_L3:;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":218 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":247 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -726,31 +838,31 @@ static double __pyx_f_6mtrand_kahan_sum(double (*__pyx_v_darr),long __pyx_v_n) {\n long __pyx_v_i;\n double __pyx_r;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":223 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */\n __pyx_v_sum = (__pyx_v_darr[0]);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":224 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":253 */\n __pyx_v_c = 0.0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":225 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":254 */\n for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":226 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":255 */\n __pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":227 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":256 */\n __pyx_v_t = (__pyx_v_sum + __pyx_v_y);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":257 */\n __pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */\n __pyx_v_sum = __pyx_v_t;\n __pyx_L2:;\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":230 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */\n __pyx_r = __pyx_v_sum;\n goto __pyx_L0;\n \n@@ -777,15 +889,15 @@ static int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObje\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":253 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":282 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state (*))PyMem_Malloc((sizeof(rk_state ))));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":255 */\n- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":284 */\n+ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n@@ -809,11 +921,11 @@ static void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {\n int __pyx_1;\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":287 */\n __pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":288 */\n PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n@@ -848,41 +960,41 @@ static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyOb\n Py_INCREF(__pyx_v_seed);\n __pyx_v_obj = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_obj);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":273 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":302 */\n __pyx_1 = __pyx_v_seed == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":274 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":303 */\n __pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_seed);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n __pyx_1 = __pyx_4 == __pyx_2;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":276 */\n- __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":305 */\n+ __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}\n rk_seed(__pyx_5,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":278 */\n- __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */\n+ __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_obj));\n __pyx_v_obj = __pyx_3;\n __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":279 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */\n init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long (*))__pyx_v_obj->data),(__pyx_v_obj->dimensions[0]));\n }\n __pyx_L2:;\n@@ -919,20 +1031,20 @@ static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n __pyx_v_state = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":288 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":317 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n+ __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_1 = 0;\n __pyx_4 = 0;\n- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_1));\n@@ -940,12 +1052,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self,\n __pyx_v_state = ((PyObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":289 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":318 */\n memcpy(((void (*))__pyx_v_state->data),((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long ))));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":290 */\n- __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":319 */\n+ __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n Py_INCREF(__pyx_n_MT19937);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_MT19937);\n Py_INCREF(((PyObject *)__pyx_v_state));\n@@ -973,11 +1085,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self,\n \n static PyObject *__pyx_n_ValueError;\n \n-static PyObject *__pyx_k42p;\n-static PyObject *__pyx_k43p;\n+static PyObject *__pyx_k60p;\n+static PyObject *__pyx_k61p;\n \n-static char (__pyx_k42[]) = \"algorithm must be 'MT19937'\";\n-static char (__pyx_k43[]) = \"state must be 624 longs\";\n+static char (__pyx_k60[]) = \"algorithm must be 'MT19937'\";\n+static char (__pyx_k61[]) = \"state must be 624 longs\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_set_state[] = \"Set the state from a tuple.\\n \\n state = (\\'MT19937\\', int key[624], int pos)\\n \\n set_state(state)\\n \";\n@@ -1000,76 +1112,76 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,\n __pyx_v_algorithm_name = Py_None; Py_INCREF(__pyx_v_algorithm_name);\n __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":301 */\n- __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":330 */\n+ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_algorithm_name);\n __pyx_v_algorithm_name = __pyx_2;\n __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":302 */\n- if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":331 */\n+ if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}\n __pyx_3 = __pyx_3 != 0;\n if (__pyx_3) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":303 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n- Py_INCREF(__pyx_k42p);\n- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k42p);\n- __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":332 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k60p);\n+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k60p);\n+ __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":304 */\n- __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n- __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":333 */\n+ __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n+ __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n Py_DECREF(__pyx_v_key);\n __pyx_v_key = __pyx_2;\n __pyx_2 = 0;\n- __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n- __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n+ __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n+ __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_v_pos = __pyx_3;\n- if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n+ if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":305 */\n- __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":334 */\n+ __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_obj));\n __pyx_v_obj = __pyx_4;\n __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":306 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":335 */\n __pyx_3 = ((__pyx_v_obj->dimensions[0]) != 624);\n if (__pyx_3) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n- Py_INCREF(__pyx_k43p);\n- PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k43p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k61p);\n+ PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k61p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":337 */\n memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,((void (*))__pyx_v_obj->data),(624 * (sizeof(long ))));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":309 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":338 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos;\n \n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n@@ -1099,10 +1211,10 @@ static PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_se\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":313 */\n- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":342 */\n+ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_r = __pyx_3;\n@@ -1134,12 +1246,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_se\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":316 */\n- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":345 */\n+ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}\n Py_INCREF(__pyx_v_state);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n@@ -1173,19 +1285,19 @@ static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":319 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stats); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":348 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stats); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n- __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n+ __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_5);\n@@ -1223,8 +1335,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_s\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":327 */\n- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */\n+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n@@ -1253,8 +1365,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":334 */\n- __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */\n+ __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n@@ -1271,9 +1383,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self,\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k44p;\n+static PyObject *__pyx_k62p;\n \n-static char (__pyx_k44[]) = \"low >= high\";\n+static char (__pyx_k62[]) = \"low >= high\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_randint[] = \"Return random integers x such that low <= x < high.\\n\\n randint(low, high=None, size=None) -> random values\\n\\n If high is None, then 0 <= x < low.\\n \";\n@@ -1304,58 +1416,58 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":349 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":378 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":350 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":379 */\n __pyx_v_lo = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":351 */\n- __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":380 */\n+ __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n goto __pyx_L2;\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":353 */\n- __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":382 */\n+ __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}\n __pyx_v_lo = __pyx_2;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":354 */\n- __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":383 */\n+ __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":385 */\n __pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":357 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":386 */\n __pyx_1 = (__pyx_v_diff < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":358 */\n- __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n- Py_INCREF(__pyx_k44p);\n- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k44p);\n- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */\n+ __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k62p);\n+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k62p);\n+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __Pyx_Raise(__pyx_5, 0, 0);\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":360 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":389 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":361 */\n- __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":390 */\n+ __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;}\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n@@ -1363,19 +1475,19 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */\n- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":392 */\n+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n@@ -1383,22 +1495,22 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":364 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":393 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":365 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":394 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":366 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":395 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":367 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":396 */\n (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state));\n __pyx_L5:;\n }\n __pyx_L6:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":368 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n@@ -1435,22 +1547,22 @@ static PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyO\n Py_INCREF(__pyx_v_self);\n __pyx_v_bytestring = Py_None; Py_INCREF(__pyx_v_bytestring);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":376 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":405 */\n __pyx_v_bytes = PyMem_Malloc(__pyx_v_length);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":377 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":406 */\n rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":378 */\n- __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":407 */\n+ __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n Py_DECREF(__pyx_v_bytestring);\n __pyx_v_bytestring = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":379 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":408 */\n PyMem_Free(__pyx_v_bytes);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":380 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":409 */\n Py_INCREF(__pyx_v_bytestring);\n __pyx_r = __pyx_v_bytestring;\n goto __pyx_L0;\n@@ -1483,8 +1595,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */\n- __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":416 */\n+ __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n@@ -1525,25 +1637,25 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb\n }\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":396 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":425 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n- if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n+ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n+ if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */\n- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":426 */\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n@@ -1553,12 +1665,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":399 */\n- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n- __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n- if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n- __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":428 */\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n+ __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n+ if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n+ __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n@@ -1604,25 +1716,25 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO\n }\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":407 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":436 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n- if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n+ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n+ if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":408 */\n- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}\n- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":437 */\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n@@ -1632,12 +1744,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":410 */\n- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":439 */\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_args);\n- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n@@ -1682,17 +1794,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":419 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":448 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":420 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":449 */\n Py_INCREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n __pyx_v_high = __pyx_v_low;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":421 */\n- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":450 */\n+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}\n Py_DECREF(__pyx_v_low);\n __pyx_v_low = __pyx_2;\n __pyx_2 = 0;\n@@ -1700,19 +1812,19 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":422 */\n- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n- __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n- __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":451 */\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n+ __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n+ __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n Py_INCREF(__pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_size);\n __pyx_4 = 0;\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_4;\n@@ -1747,8 +1859,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":430 */\n- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */\n+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n@@ -1765,9 +1877,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k46p;\n+static PyObject *__pyx_k64p;\n \n-static char (__pyx_k46[]) = \"scale <= 0\";\n+static char (__pyx_k64[]) = \"scale <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_normal[] = \"Normal distribution (mean=loc, stdev=scale).\\n\\n normal(loc=0.0, scale=1.0, size=None) -> random values\\n \";\n@@ -1788,27 +1900,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":437 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":438 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n- Py_INCREF(__pyx_k46p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k46p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":467 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k64p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":439 */\n- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":468 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -1827,11 +1939,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k47p;\n-static PyObject *__pyx_k48p;\n+static PyObject *__pyx_k65p;\n+static PyObject *__pyx_k66p;\n \n-static char (__pyx_k47[]) = \"a <= 0\";\n-static char (__pyx_k48[]) = \"b <= 0\";\n+static char (__pyx_k65[]) = \"a <= 0\";\n+static char (__pyx_k66[]) = \"b <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_beta[] = \"Beta distribution over [0, 1].\\n\\n beta(a, b, size=None) -> random values\\n \";\n@@ -1850,43 +1962,43 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":446 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":447 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n- Py_INCREF(__pyx_k47p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k47p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":476 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k65p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k65p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_b <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":449 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n- Py_INCREF(__pyx_k48p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":478 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k66p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":450 */\n- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":479 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -1905,9 +2017,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k49p;\n+static PyObject *__pyx_k67p;\n \n-static char (__pyx_k49[]) = \"scale <= 0\";\n+static char (__pyx_k67[]) = \"scale <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_exponential[] = \"Exponential distribution.\\n\\n exponential(scale=1.0, size=None) -> random values\\n \";\n@@ -1926,27 +2038,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_sel\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":457 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":458 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n- Py_INCREF(__pyx_k49p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k49p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":487 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k67p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */\n- __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":488 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -1977,8 +2089,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */\n- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":495 */\n+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n@@ -1995,9 +2107,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k50p;\n+static PyObject *__pyx_k68p;\n \n-static char (__pyx_k50[]) = \"shape <= 0\";\n+static char (__pyx_k68[]) = \"shape <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = \"Standard Gamma distribution.\\n\\n standard_gamma(shape, size=None) -> random values\\n \";\n@@ -2015,27 +2127,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":473 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":502 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":474 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n- Py_INCREF(__pyx_k50p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k50p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":503 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k68p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */\n- __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":504 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2054,11 +2166,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k51p;\n-static PyObject *__pyx_k52p;\n+static PyObject *__pyx_k69p;\n+static PyObject *__pyx_k70p;\n \n-static char (__pyx_k51[]) = \"shape <= 0\";\n-static char (__pyx_k52[]) = \"scale <= 0\";\n+static char (__pyx_k69[]) = \"shape <= 0\";\n+static char (__pyx_k70[]) = \"scale <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_gamma[] = \"Gamma distribution.\\n\\n gamma(shape, scale=1.0, size=None) -> random values\\n \";\n@@ -2078,43 +2190,43 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":482 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":511 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":483 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n- Py_INCREF(__pyx_k51p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k51p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":512 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k69p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":485 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n- Py_INCREF(__pyx_k52p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k52p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":514 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k70p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */\n- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":515 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2133,11 +2245,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k53p;\n-static PyObject *__pyx_k54p;\n+static PyObject *__pyx_k71p;\n+static PyObject *__pyx_k72p;\n \n-static char (__pyx_k53[]) = \"dfnum <= 0\";\n-static char (__pyx_k54[]) = \"dfden <= 0\";\n+static char (__pyx_k71[]) = \"dfnum <= 0\";\n+static char (__pyx_k72[]) = \"dfden <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_f[] = \"F distribution.\\n\\n f(dfnum, dfden, size=None) -> random values\\n \";\n@@ -2156,43 +2268,43 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":493 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */\n __pyx_1 = (__pyx_v_dfnum <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":494 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n- Py_INCREF(__pyx_k53p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k53p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":523 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k71p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":496 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n- Py_INCREF(__pyx_k54p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k54p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":525 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k72p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":497 */\n- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":526 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2211,13 +2323,13 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k55p;\n-static PyObject *__pyx_k56p;\n-static PyObject *__pyx_k57p;\n+static PyObject *__pyx_k73p;\n+static PyObject *__pyx_k74p;\n+static PyObject *__pyx_k75p;\n \n-static char (__pyx_k55[]) = \"dfnum <= 1\";\n-static char (__pyx_k56[]) = \"dfden <= 0\";\n-static char (__pyx_k57[]) = \"nonc < 0\";\n+static char (__pyx_k73[]) = \"dfnum <= 1\";\n+static char (__pyx_k74[]) = \"dfden <= 0\";\n+static char (__pyx_k75[]) = \"nonc < 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = \"Noncentral F distribution.\\n\\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\\n \";\n@@ -2237,59 +2349,59 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":504 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":533 */\n __pyx_1 = (__pyx_v_dfnum <= 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":505 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n- Py_INCREF(__pyx_k55p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k55p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":534 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k73p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k73p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":507 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n- Py_INCREF(__pyx_k56p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k56p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":536 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k74p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k74p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":509 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n- Py_INCREF(__pyx_k57p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k57p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":538 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k75p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k75p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":510 */\n- __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */\n+ __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2308,9 +2420,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k58p;\n+static PyObject *__pyx_k76p;\n \n-static char (__pyx_k58[]) = \"df <= 0\";\n+static char (__pyx_k76[]) = \"df <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_chisquare[] = \"Chi^2 distribution.\\n\\n chisquare(df, size=None) -> random values\\n \";\n@@ -2328,27 +2440,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":518 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":519 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n- Py_INCREF(__pyx_k58p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k58p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":548 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k76p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":520 */\n- __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":549 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2367,11 +2479,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self,\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k59p;\n-static PyObject *__pyx_k60p;\n+static PyObject *__pyx_k77p;\n+static PyObject *__pyx_k78p;\n \n-static char (__pyx_k59[]) = \"df <= 1\";\n-static char (__pyx_k60[]) = \"nonc < 0\";\n+static char (__pyx_k77[]) = \"df <= 1\";\n+static char (__pyx_k78[]) = \"nonc < 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = \"Noncentral Chi^2 distribution.\\n\\n noncentral_chisquare(df, nonc, size=None) -> random values\\n \";\n@@ -2390,43 +2502,43 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":527 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */\n __pyx_1 = (__pyx_v_df <= 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n- Py_INCREF(__pyx_k59p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k59p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":557 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k77p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k77p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":530 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n- Py_INCREF(__pyx_k60p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k60p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":559 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k78p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k78p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":531 */\n- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":560 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2457,8 +2569,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */\n- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":568 */\n+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n@@ -2475,9 +2587,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k61p;\n+static PyObject *__pyx_k79p;\n \n-static char (__pyx_k61[]) = \"df <= 0\";\n+static char (__pyx_k79[]) = \"df <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_standard_t[] = \"Standard Student\\'s t distribution with df degrees of freedom.\\n\\n standard_t(df, size=None)\\n \";\n@@ -2495,27 +2607,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":546 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n- Py_INCREF(__pyx_k61p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k61p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":576 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k79p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k79p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":548 */\n- __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":577 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2534,9 +2646,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k62p;\n+static PyObject *__pyx_k80p;\n \n-static char (__pyx_k62[]) = \"kappa < 0\";\n+static char (__pyx_k80[]) = \"kappa < 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_vonmises[] = \"von Mises circular distribution with mode mu and dispersion parameter\\n kappa on [-pi, pi].\\n\\n vonmises(mu, kappa, size=None)\\n \";\n@@ -2555,27 +2667,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":585 */\n __pyx_1 = (__pyx_v_kappa < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":557 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n- Py_INCREF(__pyx_k62p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k62p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":586 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k80p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k80p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":558 */\n- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":587 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2594,9 +2706,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k63p;\n+static PyObject *__pyx_k81p;\n \n-static char (__pyx_k63[]) = \"a <= 0\";\n+static char (__pyx_k81[]) = \"a <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_pareto[] = \"Pareto distribution.\\n\\n pareto(a, size=None)\\n \";\n@@ -2614,27 +2726,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, Py\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":565 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":566 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n- Py_INCREF(__pyx_k63p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k63p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":595 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k81p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k81p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":567 */\n- __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":596 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2653,9 +2765,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, Py\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k64p;\n+static PyObject *__pyx_k82p;\n \n-static char (__pyx_k64[]) = \"a <= 0\";\n+static char (__pyx_k82[]) = \"a <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_weibull[] = \"Weibull distribution.\\n\\n weibull(a, size=None)\\n \";\n@@ -2673,27 +2785,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":574 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":603 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n- Py_INCREF(__pyx_k64p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":604 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k82p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k82p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":576 */\n- __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":605 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2712,9 +2824,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, P\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k65p;\n+static PyObject *__pyx_k83p;\n \n-static char (__pyx_k65[]) = \"a <= 0\";\n+static char (__pyx_k83[]) = \"a <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_power[] = \"Power distribution.\\n\\n power(a, size=None)\\n \";\n@@ -2732,27 +2844,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyO\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":583 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":584 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n- Py_INCREF(__pyx_k65p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k65p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":613 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k83p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k83p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":585 */\n- __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":614 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2771,84 +2883,50 @@ static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyO\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k66p;\n-static PyObject *__pyx_k67p;\n-static PyObject *__pyx_k68p;\n+static PyObject *__pyx_k84p;\n \n-static char (__pyx_k66[]) = \"n <= 0\";\n-static char (__pyx_k67[]) = \"p < 0\";\n-static char (__pyx_k68[]) = \"p > 1\";\n+static char (__pyx_k84[]) = \"scale <= 0.0\";\n \n-static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n-static char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";\n-static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n- long __pyx_v_n;\n- double __pyx_v_p;\n+static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_laplace[] = \"Laplace distribution.\\n \\n laplace(loc=0.0, scale=1.0, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_loc;\n+ double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n- static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n- __pyx_v_size = __pyx_k34;\n- if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n+ static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n+ __pyx_v_loc = __pyx_k34;\n+ __pyx_v_scale = __pyx_k35;\n+ __pyx_v_size = __pyx_k36;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":593 */\n- __pyx_1 = (__pyx_v_n <= 0);\n- if (__pyx_1) {\n-\n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n- Py_INCREF(__pyx_k66p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n- Py_DECREF(__pyx_2); __pyx_2 = 0;\n- Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __Pyx_Raise(__pyx_4, 0, 0);\n- Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n- goto __pyx_L2;\n- }\n- __pyx_1 = (__pyx_v_p < 0);\n- if (__pyx_1) {\n-\n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":596 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n- Py_INCREF(__pyx_k67p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n- Py_DECREF(__pyx_2); __pyx_2 = 0;\n- Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __Pyx_Raise(__pyx_4, 0, 0);\n- Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n- goto __pyx_L2;\n- }\n- __pyx_1 = (__pyx_v_p > 1);\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */\n+ __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":598 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n- Py_INCREF(__pyx_k68p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":622 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k84p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k84p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":599 */\n- __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":623 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2859,7 +2937,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n- __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");\n+ __Pyx_AddTraceback(\"mtrand.RandomState.laplace\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n@@ -2867,18 +2945,438 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k69p;\n-static PyObject *__pyx_k70p;\n-static PyObject *__pyx_k71p;\n+static PyObject *__pyx_k85p;\n \n-static char (__pyx_k69[]) = \"n <= 0\";\n-static char (__pyx_k70[]) = \"p < 0\";\n-static char (__pyx_k71[]) = \"p > 1\";\n+static char (__pyx_k85[]) = \"scale <= 0.0\";\n \n-static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n-static char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";\n-static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n- long __pyx_v_n;\n+static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_gumbel[] = \"Gumbel distribution.\\n \\n gumbel(loc=0.0, scale=1.0, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_loc;\n+ double __pyx_v_scale;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n+ __pyx_v_loc = __pyx_k37;\n+ __pyx_v_scale = __pyx_k38;\n+ __pyx_v_size = __pyx_k39;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":630 */\n+ __pyx_1 = (__pyx_v_scale <= 0.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":631 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k85p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k85p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":632 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.gumbel\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k86p;\n+\n+static char (__pyx_k86[]) = \"scale <= 0.0\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_logistic[] = \"Logistic distribution.\\n \\n logistic(loc=0.0, scale=1.0, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_loc;\n+ double __pyx_v_scale;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n+ __pyx_v_loc = __pyx_k40;\n+ __pyx_v_scale = __pyx_k41;\n+ __pyx_v_size = __pyx_k42;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":639 */\n+ __pyx_1 = (__pyx_v_scale <= 0.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":640 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k86p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k86p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":641 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.logistic\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k87p;\n+\n+static char (__pyx_k87[]) = \"sigma <= 0.0\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_lognormal[] = \"Log-normal distribution.\\n \\n Note that the mean parameter is not the mean of this distribution, but \\n the underlying normal distribution.\\n \\n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\\n \\n lognormal(mean=0.0, sigma=1.0, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_mean;\n+ double __pyx_v_sigma;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"mean\",\"sigma\",\"size\",0};\n+ __pyx_v_mean = __pyx_k43;\n+ __pyx_v_sigma = __pyx_k44;\n+ __pyx_v_size = __pyx_k45;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_sigma, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":653 */\n+ __pyx_1 = (__pyx_v_sigma <= 0.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":654 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k87p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k87p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":655 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_mean,__pyx_v_sigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.lognormal\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k88p;\n+\n+static char (__pyx_k88[]) = \"mode <= 0.0\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_rayleigh[] = \"Rayleigh distribution.\\n \\n rayleigh(mode, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_mode;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"mode\",\"size\",0};\n+ __pyx_v_size = __pyx_k46;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_mode, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":662 */\n+ __pyx_1 = (__pyx_v_mode <= 0.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":663 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k88p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k88p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":664 */\n+ __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_mode); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.rayleigh\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k89p;\n+static PyObject *__pyx_k90p;\n+\n+static char (__pyx_k89[]) = \"mean <= 0.0\";\n+static char (__pyx_k90[]) = \"scale <= 0.0\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_wald[] = \"Wald (inverse Gaussian) distribution.\\n \\n wald(mean, scale, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_mean;\n+ double __pyx_v_scale;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"mean\",\"scale\",\"size\",0};\n+ __pyx_v_size = __pyx_k47;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_scale, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":671 */\n+ __pyx_1 = (__pyx_v_mean <= 0.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":672 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k89p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k89p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_scale <= 0.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":674 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k90p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k90p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":675 */\n+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_mean,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.wald\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k91p;\n+static PyObject *__pyx_k92p;\n+static PyObject *__pyx_k93p;\n+\n+static char (__pyx_k91[]) = \"left > mode\";\n+static char (__pyx_k92[]) = \"mode > right\";\n+static char (__pyx_k93[]) = \"left == right\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_triangular[] = \"Triangular distribution starting at left, peaking at mode, and \\n ending at right (left <= mode <= right).\\n \\n triangular(left, mode, right, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_left;\n+ double __pyx_v_mode;\n+ double __pyx_v_right;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"left\",\"mode\",\"right\",\"size\",0};\n+ __pyx_v_size = __pyx_k48;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_left, &__pyx_v_mode, &__pyx_v_right, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":683 */\n+ __pyx_1 = (__pyx_v_left > __pyx_v_mode);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":684 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k91p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k91p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_mode > __pyx_v_right);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":686 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k92p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k92p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_left == __pyx_v_right);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":688 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k93p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k93p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":689 */\n+ __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_left,__pyx_v_mode,__pyx_v_right); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.triangular\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k94p;\n+static PyObject *__pyx_k95p;\n+static PyObject *__pyx_k96p;\n+\n+static char (__pyx_k94[]) = \"n <= 0\";\n+static char (__pyx_k95[]) = \"p < 0\";\n+static char (__pyx_k96[]) = \"p > 1\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n@@ -2887,64 +3385,160 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n- __pyx_v_size = __pyx_k35;\n+ __pyx_v_size = __pyx_k49;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":606 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":607 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n- Py_INCREF(__pyx_k69p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":699 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k94p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k94p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_p < 0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":701 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k95p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k95p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_p > 1);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k96p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k96p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */\n+ __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k97p;\n+static PyObject *__pyx_k98p;\n+static PyObject *__pyx_k99p;\n+\n+static char (__pyx_k97[]) = \"n <= 0\";\n+static char (__pyx_k98[]) = \"p < 0\";\n+static char (__pyx_k99[]) = \"p > 1\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ long __pyx_v_n;\n+ double __pyx_v_p;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n+ __pyx_v_size = __pyx_k50;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */\n+ __pyx_1 = (__pyx_v_n <= 0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":712 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k97p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k97p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":609 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n- Py_INCREF(__pyx_k70p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":714 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k98p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k98p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":611 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n- Py_INCREF(__pyx_k71p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k99p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k99p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */\n- __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */\n+ __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -2963,9 +3557,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx\n return __pyx_r;\n }\n \n-static PyObject *__pyx_k72p;\n+static PyObject *__pyx_k100p;\n \n-static char (__pyx_k72[]) = \"lam <= 0\";\n+static char (__pyx_k100[]) = \"lam <= 0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_poisson[] = \"Poisson distribution.\\n\\n poisson(lam=1.0, size=None) -> random values\\n \";\n@@ -2978,33 +3572,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, P\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"lam\",\"size\",0};\n- __pyx_v_lam = __pyx_k36;\n- __pyx_v_size = __pyx_k37;\n+ __pyx_v_lam = __pyx_k51;\n+ __pyx_v_size = __pyx_k52;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_lam, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":620 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":725 */\n __pyx_1 = (__pyx_v_lam <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n- Py_INCREF(__pyx_k72p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);\n- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":726 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k100p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k100p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":622 */\n- __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":727 */\n+ __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n@@ -3023,6 +3617,257 @@ static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, P\n return __pyx_r;\n }\n \n+static PyObject *__pyx_k101p;\n+\n+static char (__pyx_k101[]) = \"a <= 1.0\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_zipf[] = \"Zipf distribution.\\n \\n zipf(a, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_a;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"a\",\"size\",0};\n+ __pyx_v_size = __pyx_k53;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":734 */\n+ __pyx_1 = (__pyx_v_a <= 1.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":735 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k101p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k101p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":736 */\n+ __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.zipf\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k102p;\n+static PyObject *__pyx_k103p;\n+\n+static char (__pyx_k102[]) = \"p < 0.0\";\n+static char (__pyx_k103[]) = \"p > 1.0\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_geometric[] = \"Geometric distribution with p being the probability of \\\"success\\\" on\\n an individual trial.\\n \\n geometric(p, size=None)\\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ double __pyx_v_p;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"p\",\"size\",0};\n+ __pyx_v_size = __pyx_k54;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":744 */\n+ __pyx_1 = (__pyx_v_p < 0.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":745 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k102p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k102p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_p > 1.0);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":747 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k103p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k103p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":748 */\n+ __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.geometric\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n+static PyObject *__pyx_k104p;\n+static PyObject *__pyx_k105p;\n+static PyObject *__pyx_k106p;\n+static PyObject *__pyx_k107p;\n+\n+static char (__pyx_k104[]) = \"ngood < 1\";\n+static char (__pyx_k105[]) = \"nbad < 1\";\n+static char (__pyx_k106[]) = \"ngood + nbad < nsample\";\n+static char (__pyx_k107[]) = \"nsample < 1\";\n+\n+static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n+static char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = \"Hypergeometric distribution.\\n \\n Consider an urn with ngood \\\"good\\\" balls and nbad \\\"bad\\\" balls. If one \\n were to draw nsample balls from the urn without replacement, then \\n the hypergeometric distribution describes the distribution of \\\"good\\\" \\n balls in the sample.\\n \\n hypergeometric(ngood, nbad, nsample, size=None) \\n \";\n+static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n+ long __pyx_v_ngood;\n+ long __pyx_v_nbad;\n+ long __pyx_v_nsample;\n+ PyObject *__pyx_v_size = 0;\n+ PyObject *__pyx_r;\n+ int __pyx_1;\n+ PyObject *__pyx_2 = 0;\n+ PyObject *__pyx_3 = 0;\n+ PyObject *__pyx_4 = 0;\n+ static char *__pyx_argnames[] = {\"ngood\",\"nbad\",\"nsample\",\"size\",0};\n+ __pyx_v_size = __pyx_k55;\n+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lll|O\", __pyx_argnames, &__pyx_v_ngood, &__pyx_v_nbad, &__pyx_v_nsample, &__pyx_v_size)) return 0;\n+ Py_INCREF(__pyx_v_self);\n+ Py_INCREF(__pyx_v_size);\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":760 */\n+ __pyx_1 = (__pyx_v_ngood < 1);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":761 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k104p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k104p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_nbad < 1);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":763 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k105p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k105p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = ((__pyx_v_ngood + __pyx_v_nbad) < __pyx_v_nsample);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k106p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k106p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_1 = (__pyx_v_nsample < 1);\n+ if (__pyx_1) {\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":767 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k107p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k107p);\n+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __Pyx_Raise(__pyx_4, 0, 0);\n+ Py_DECREF(__pyx_4); __pyx_4 = 0;\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n+ goto __pyx_L2;\n+ }\n+ __pyx_L2:;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */\n+ __pyx_2 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ngood,__pyx_v_nbad,__pyx_v_nsample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n+ __pyx_r = __pyx_2;\n+ __pyx_2 = 0;\n+ goto __pyx_L0;\n+\n+ __pyx_r = Py_None; Py_INCREF(__pyx_r);\n+ goto __pyx_L0;\n+ __pyx_L1:;\n+ Py_XDECREF(__pyx_2);\n+ Py_XDECREF(__pyx_3);\n+ Py_XDECREF(__pyx_4);\n+ __Pyx_AddTraceback(\"mtrand.RandomState.hypergeometric\");\n+ __pyx_r = 0;\n+ __pyx_L0:;\n+ Py_DECREF(__pyx_v_self);\n+ Py_DECREF(__pyx_v_size);\n+ return __pyx_r;\n+}\n+\n static PyObject *__pyx_n_array;\n static PyObject *__pyx_n_shape;\n static PyObject *__pyx_n_ArgumentError;\n@@ -3034,18 +3879,17 @@ static PyObject *__pyx_n_reduce;\n static PyObject *__pyx_n_linalg;\n static PyObject *__pyx_n_singular_value_decomposition;\n static PyObject *__pyx_n_matrixmultiply;\n-static PyObject *__pyx_n_Numeric;\n static PyObject *__pyx_n_sqrt;\n static PyObject *__pyx_n_add;\n static PyObject *__pyx_n_tuple;\n \n-static PyObject *__pyx_k73p;\n-static PyObject *__pyx_k74p;\n-static PyObject *__pyx_k75p;\n+static PyObject *__pyx_k108p;\n+static PyObject *__pyx_k109p;\n+static PyObject *__pyx_k110p;\n \n-static char (__pyx_k73[]) = \"mean must be 1 dimensional\";\n-static char (__pyx_k74[]) = \"cov must be 2 dimensional and square\";\n-static char (__pyx_k75[]) = \"mean and cov must have same length\";\n+static char (__pyx_k108[]) = \"mean must be 1 dimensional\";\n+static char (__pyx_k109[]) = \"cov must be 2 dimensional and square\";\n+static char (__pyx_k110[]) = \"mean and cov must have same length\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = \"Return an array containing multivariate normally distributed random numbers\\n with specified mean and covariance.\\n\\n multivariate_normal(mean, cov) -> random values\\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\\n\\n mean must be a 1 dimensional array. cov must be a square two dimensional\\n array with the same number of rows and columns as mean has elements.\\n\\n The first form returns a single 1-D array containing a multivariate\\n normal.\\n\\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\\n normal.\\n \";\n@@ -3066,7 +3910,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"cov\",\"size\",0};\n- __pyx_v_size = __pyx_k38;\n+ __pyx_v_size = __pyx_k56;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"OO|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_cov, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_mean);\n@@ -3079,40 +3923,40 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);\n __pyx_v_v = Py_None; Py_INCREF(__pyx_v_v);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":643 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":790 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_mean);\n- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_mean);\n __pyx_v_mean = __pyx_3;\n __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":644 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":791 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cov);\n- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_cov);\n __pyx_v_cov = __pyx_2;\n __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":645 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":792 */\n __pyx_4 = __pyx_v_size == Py_None;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":646 */\n- __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":793 */\n+ __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; goto __pyx_L1;}\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n@@ -3120,140 +3964,140 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":648 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":795 */\n Py_INCREF(__pyx_v_size);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_v_size;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":649 */\n- __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":796 */\n+ __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);\n __pyx_2 = 0;\n- __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n+ __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n- if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n+ __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n+ if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":650 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n- Py_INCREF(__pyx_k73p);\n- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k73p);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":797 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k108p);\n+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k108p);\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_3, 0, 0);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":651 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":798 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n- if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n+ __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n+ if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (!__pyx_4) {\n- __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n- __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n+ __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n- __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n+ if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n }\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":652 */\n- __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n- Py_INCREF(__pyx_k74p);\n- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k74p);\n- __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":799 */\n+ __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k109p);\n+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k109p);\n+ __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n goto __pyx_L4;\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":653 */\n- __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n- __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":800 */\n+ __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n+ __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n- __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n+ __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n+ if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":654 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n- Py_INCREF(__pyx_k75p);\n- PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k75p);\n- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":801 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k110p);\n+ PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k110p);\n+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __Pyx_Raise(__pyx_2, 0, 0);\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n goto __pyx_L5;\n }\n __pyx_L5:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":656 */\n- __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":803 */\n+ __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);\n __pyx_1 = 0;\n- __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n+ __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n+ __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":657 */\n- __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":804 */\n+ __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyList_SET_ITEM(__pyx_1, 0, __pyx_v_shape);\n Py_DECREF(__pyx_v_shape);\n@@ -3263,178 +4107,178 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n __pyx_L6:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":658 */\n- __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n- __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":805 */\n+ __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n+ __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);\n __pyx_5 = 0;\n- __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_final_shape);\n __pyx_v_final_shape = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":659 */\n- __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n- __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":806 */\n+ __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n+ __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n __pyx_1 = 0;\n- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":663 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n- __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":810 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n+ __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);\n __pyx_3 = 0;\n- __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n+ __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_5;\n __pyx_5 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":664 */\n- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":811 */\n+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_final_shape);\n- __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n- __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n+ __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);\n __pyx_1 = 0;\n- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}\n- __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}\n- __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n+ __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);\n PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);\n __pyx_3 = 0;\n __pyx_5 = 0;\n- if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":672 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_linalg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":821 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_linalg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_singular_value_decomposition); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_singular_value_decomposition); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_cov);\n- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_v_u);\n __pyx_v_u = __pyx_3;\n __pyx_3 = 0;\n- __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_v_s);\n __pyx_v_s = __pyx_5;\n __pyx_5 = 0;\n- __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_v_v);\n __pyx_v_v = __pyx_1;\n __pyx_1 = 0;\n- if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n+ if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":673 */\n- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n- __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":822 */\n+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_Numeric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_INCREF(__pyx_v_s);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);\n- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n+ __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n Py_INCREF(__pyx_v_v);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_v);\n __pyx_2 = 0;\n- __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":676 */\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n- __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":825 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_mean);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_x);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_x);\n- __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":826 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":678 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":827 */\n Py_INCREF(__pyx_v_x);\n __pyx_r = __pyx_v_x;\n goto __pyx_L0;\n@@ -3464,9 +4308,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n \n static PyObject *__pyx_n_zeros;\n \n-static PyObject *__pyx_k76p;\n+static PyObject *__pyx_k111p;\n \n-static char (__pyx_k76[]) = \"sum(pvals) > 1.0\";\n+static char (__pyx_k111[]) = \"sum(pvals) > 1.0\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_multinomial[] = \"Multinomial distribution.\\n \\n multinomial(n, pvals, size=None) -> random values\\n\\n pvals is a sequence of probabilities that should sum to 1 (however, the\\n last element is always assumed to account for the remaining probability\\n as long as sum(pvals[:-1]) <= 1).\\n \";\n@@ -3493,7 +4337,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"n\",\"pvals\",\"size\",0};\n- __pyx_v_size = __pyx_k39;\n+ __pyx_v_size = __pyx_k57;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lO|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_pvals, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_pvals);\n@@ -3503,53 +4347,53 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_multin = Py_None; Py_INCREF(__pyx_v_multin);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":696 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":845 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n Py_INCREF(__pyx_v_pvals);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pvals);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n+ __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_v_d = __pyx_4;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":697 */\n- __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":846 */\n+ __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_parr));\n __pyx_v_parr = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":847 */\n __pyx_v_pix = ((double (*))__pyx_v_parr->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":700 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":849 */\n __pyx_5 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > 1.0);\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":701 */\n- __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n- Py_INCREF(__pyx_k76p);\n- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);\n- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":850 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n+ Py_INCREF(__pyx_k111p);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k111p);\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":852 */\n __pyx_5 = __pyx_v_size == Py_None;\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */\n- __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":853 */\n+ __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n@@ -3557,22 +4401,22 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n __pyx_5 = __pyx_3 == __pyx_1;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */\n- __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":855 */\n+ __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n@@ -3584,12 +4428,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":708 */\n- __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":857 */\n+ __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);\n __pyx_1 = 0;\n- __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n+ __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n@@ -3597,90 +4441,90 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":710 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":859 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);\n __pyx_1 = 0;\n- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_multin);\n __pyx_v_multin = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":860 */\n Py_INCREF(((PyObject *)__pyx_v_multin));\n Py_DECREF(((PyObject *)__pyx_v_mnarr));\n __pyx_v_mnarr = ((PyObject *)__pyx_v_multin);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":712 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":861 */\n __pyx_v_mnix = ((long (*))__pyx_v_mnarr->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":713 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":862 */\n __pyx_v_i = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":714 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":863 */\n while (1) {\n __pyx_L4:;\n __pyx_5 = (__pyx_v_i < PyArray_SIZE(__pyx_v_mnarr));\n if (!__pyx_5) break;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":715 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":864 */\n __pyx_v_Sum = 1.0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":865 */\n __pyx_v_dn = __pyx_v_n;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":866 */\n __pyx_4 = (__pyx_v_d - 1);\n for (__pyx_v_j = 0; __pyx_v_j < __pyx_4; ++__pyx_v_j) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":718 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":867 */\n (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":719 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":868 */\n __pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":720 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":869 */\n __pyx_5 = (__pyx_v_dn <= 0);\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":721 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":870 */\n goto __pyx_L7;\n goto __pyx_L8;\n }\n __pyx_L8:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":722 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":871 */\n __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j]));\n __pyx_L6:;\n }\n __pyx_L7:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":723 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":872 */\n __pyx_5 = (__pyx_v_dn > 0);\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":724 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":873 */\n (__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn;\n goto __pyx_L9;\n }\n __pyx_L9:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":726 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":875 */\n __pyx_v_i = (__pyx_v_i + __pyx_v_d);\n }\n __pyx_L5:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":728 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":877 */\n Py_INCREF(__pyx_v_multin);\n __pyx_r = __pyx_v_multin;\n goto __pyx_L0;\n@@ -3721,48 +4565,48 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":739 */\n- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":888 */\n+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n- __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n+ __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n+ __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n+ __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_v_i = __pyx_4;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":740 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":889 */\n while (1) {\n __pyx_L2:;\n __pyx_5 = (__pyx_v_i > 0);\n if (!__pyx_5) break;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":741 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":890 */\n __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":742 */\n- __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":891 */\n+ __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n+ __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n+ __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n+ __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n- if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n+ __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n+ if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n- if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n+ __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n+ if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":743 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":892 */\n __pyx_v_i = (__pyx_v_i - 1);\n }\n __pyx_L3:;\n@@ -3798,31 +4642,31 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel\n Py_INCREF(__pyx_v_x);\n __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":751 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_arange); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":900 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_arange); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x);\n- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_arr);\n __pyx_v_arr = __pyx_3;\n __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":752 */\n- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":901 */\n+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}\n+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}\n Py_INCREF(__pyx_v_arr);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_arr);\n- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":753 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":902 */\n Py_INCREF(__pyx_v_arr);\n __pyx_r = __pyx_v_arr;\n goto __pyx_L0;\n@@ -3847,10 +4691,10 @@ static __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_Float64, \"Float64\"},\n {&__pyx_n_Int, \"Int\"},\n {&__pyx_n_MT19937, \"MT19937\"},\n- {&__pyx_n_Numeric, \"scipy\"},\n {&__pyx_n_ValueError, \"ValueError\"},\n {&__pyx_n___RandomState_ctor, \"__RandomState_ctor\"},\n {&__pyx_n__rand, \"_rand\"},\n+ {&__pyx_n__sp, \"_sp\"},\n {&__pyx_n_add, \"add\"},\n {&__pyx_n_append, \"append\"},\n {&__pyx_n_arange, \"arange\"},\n@@ -3863,12 +4707,18 @@ static __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_exponential, \"exponential\"},\n {&__pyx_n_f, \"f\"},\n {&__pyx_n_gamma, \"gamma\"},\n+ {&__pyx_n_geometric, \"geometric\"},\n {&__pyx_n_get_state, \"get_state\"},\n+ {&__pyx_n_gumbel, \"gumbel\"},\n+ {&__pyx_n_hypergeometric, \"hypergeometric\"},\n {&__pyx_n_int, \"int\"},\n {&__pyx_n_isinstance, \"isinstance\"},\n+ {&__pyx_n_laplace, \"laplace\"},\n {&__pyx_n_len, \"len\"},\n {&__pyx_n_linalg, \"linalg\"},\n {&__pyx_n_list, \"list\"},\n+ {&__pyx_n_logistic, \"logistic\"},\n+ {&__pyx_n_lognormal, \"lognormal\"},\n {&__pyx_n_matrixmultiply, \"matrixmultiply\"},\n {&__pyx_n_multinomial, \"multinomial\"},\n {&__pyx_n_multiply, \"multiply\"},\n@@ -3886,6 +4736,7 @@ static __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_randn, \"randn\"},\n {&__pyx_n_random_integers, \"random_integers\"},\n {&__pyx_n_random_sample, \"random_sample\"},\n+ {&__pyx_n_rayleigh, \"rayleigh\"},\n {&__pyx_n_reduce, \"reduce\"},\n {&__pyx_n_scipy, \"scipy\"},\n {&__pyx_n_seed, \"seed\"},\n@@ -3901,37 +4752,22 @@ static __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_standard_normal, \"standard_normal\"},\n {&__pyx_n_standard_t, \"standard_t\"},\n {&__pyx_n_stats, \"stats\"},\n+ {&__pyx_n_triangular, \"triangular\"},\n {&__pyx_n_tuple, \"tuple\"},\n {&__pyx_n_type, \"type\"},\n {&__pyx_n_uniform, \"uniform\"},\n {&__pyx_n_vonmises, \"vonmises\"},\n+ {&__pyx_n_wald, \"wald\"},\n {&__pyx_n_weibull, \"weibull\"},\n {&__pyx_n_zeros, \"zeros\"},\n+ {&__pyx_n_zipf, \"zipf\"},\n {0, 0}\n };\n \n static __Pyx_StringTabEntry __pyx_string_tab[] = {\n- {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)},\n- {&__pyx_k43p, __pyx_k43, sizeof(__pyx_k43)},\n- {&__pyx_k44p, __pyx_k44, sizeof(__pyx_k44)},\n- {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)},\n- {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)},\n- {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)},\n- {&__pyx_k49p, __pyx_k49, sizeof(__pyx_k49)},\n- {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)},\n- {&__pyx_k51p, __pyx_k51, sizeof(__pyx_k51)},\n- {&__pyx_k52p, __pyx_k52, sizeof(__pyx_k52)},\n- {&__pyx_k53p, __pyx_k53, sizeof(__pyx_k53)},\n- {&__pyx_k54p, __pyx_k54, sizeof(__pyx_k54)},\n- {&__pyx_k55p, __pyx_k55, sizeof(__pyx_k55)},\n- {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)},\n- {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)},\n- {&__pyx_k58p, __pyx_k58, sizeof(__pyx_k58)},\n- {&__pyx_k59p, __pyx_k59, sizeof(__pyx_k59)},\n {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)},\n {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)},\n {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)},\n- {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)},\n {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)},\n {&__pyx_k65p, __pyx_k65, sizeof(__pyx_k65)},\n {&__pyx_k66p, __pyx_k66, sizeof(__pyx_k66)},\n@@ -3945,6 +4781,41 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {\n {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)},\n {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)},\n {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)},\n+ {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)},\n+ {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)},\n+ {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)},\n+ {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)},\n+ {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)},\n+ {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)},\n+ {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)},\n+ {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)},\n+ {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)},\n+ {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)},\n+ {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)},\n+ {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)},\n+ {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)},\n+ {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)},\n+ {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)},\n+ {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)},\n+ {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)},\n+ {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)},\n+ {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)},\n+ {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)},\n+ {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)},\n+ {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)},\n+ {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)},\n+ {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)},\n+ {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)},\n+ {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)},\n+ {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)},\n+ {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)},\n+ {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)},\n+ {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)},\n+ {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)},\n+ {&__pyx_k108p, __pyx_k108, sizeof(__pyx_k108)},\n+ {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)},\n+ {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)},\n+ {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)},\n {0, 0, 0}\n };\n \n@@ -4011,9 +4882,19 @@ static struct PyMethodDef __pyx_methods_6mtrand_RandomState[] = {\n {\"pareto\", (PyCFunction)__pyx_f_6mtrand_11RandomState_pareto, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_pareto},\n {\"weibull\", (PyCFunction)__pyx_f_6mtrand_11RandomState_weibull, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_weibull},\n {\"power\", (PyCFunction)__pyx_f_6mtrand_11RandomState_power, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_power},\n+ {\"laplace\", (PyCFunction)__pyx_f_6mtrand_11RandomState_laplace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_laplace},\n+ {\"gumbel\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gumbel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gumbel},\n+ {\"logistic\", (PyCFunction)__pyx_f_6mtrand_11RandomState_logistic, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_logistic},\n+ {\"lognormal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_lognormal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_lognormal},\n+ {\"rayleigh\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rayleigh, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rayleigh},\n+ {\"wald\", (PyCFunction)__pyx_f_6mtrand_11RandomState_wald, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_wald},\n+ {\"triangular\", (PyCFunction)__pyx_f_6mtrand_11RandomState_triangular, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_triangular},\n {\"binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_binomial},\n {\"negative_binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_negative_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_negative_binomial},\n {\"poisson\", (PyCFunction)__pyx_f_6mtrand_11RandomState_poisson, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_poisson},\n+ {\"zipf\", (PyCFunction)__pyx_f_6mtrand_11RandomState_zipf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_zipf},\n+ {\"geometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_geometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_geometric},\n+ {\"hypergeometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_hypergeometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_hypergeometric},\n {\"multivariate_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multivariate_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multivariate_normal},\n {\"multinomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multinomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multinomial},\n {\"shuffle\", (PyCFunction)__pyx_f_6mtrand_11RandomState_shuffle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_shuffle},\n@@ -4153,381 +5034,499 @@ DL_EXPORT(void) initmtrand(void) {\n if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_ptype_6mtrand_ArrayType = __Pyx_ImportType(\"scipy\", \"ArrayType\", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ArrayType) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L1;}\n- if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}\n- if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}\n+ if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}\n+ if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}\n __pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":101 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":113 */\n import_array();\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":103 */\n- __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;}\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_scipy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":115 */\n+ __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n__sp, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":281 */\n Py_INCREF(Py_None);\n __pyx_k2 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":261 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":290 */\n Py_INCREF(Py_None);\n __pyx_k3 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":322 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":351 */\n Py_INCREF(Py_None);\n __pyx_k4 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":329 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":358 */\n Py_INCREF(Py_None);\n __pyx_k5 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":365 */\n Py_INCREF(Py_None);\n __pyx_k6 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k7 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":382 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":411 */\n __pyx_k8 = 0.0;\n __pyx_k9 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k10 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":412 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */\n Py_INCREF(Py_None);\n __pyx_k11 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k12 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":425 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":454 */\n Py_INCREF(Py_None);\n __pyx_k13 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":432 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":461 */\n __pyx_k14 = 0.0;\n __pyx_k15 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k16 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":470 */\n Py_INCREF(Py_None);\n __pyx_k17 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":452 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":481 */\n __pyx_k18 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k19 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":461 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":490 */\n Py_INCREF(Py_None);\n __pyx_k20 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":468 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":497 */\n Py_INCREF(Py_None);\n __pyx_k21 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":477 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":506 */\n __pyx_k22 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k23 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":488 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":517 */\n Py_INCREF(Py_None);\n __pyx_k24 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":499 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */\n Py_INCREF(Py_None);\n __pyx_k25 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":513 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":542 */\n Py_INCREF(Py_None);\n __pyx_k26 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":551 */\n Py_INCREF(Py_None);\n __pyx_k27 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":534 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":563 */\n Py_INCREF(Py_None);\n __pyx_k28 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":541 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":570 */\n Py_INCREF(Py_None);\n __pyx_k29 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":550 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":579 */\n Py_INCREF(Py_None);\n __pyx_k30 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":560 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":589 */\n Py_INCREF(Py_None);\n __pyx_k31 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":569 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":598 */\n Py_INCREF(Py_None);\n __pyx_k32 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":578 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":607 */\n Py_INCREF(Py_None);\n __pyx_k33 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":588 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":616 */\n+ __pyx_k34 = 0.0;\n+ __pyx_k35 = 1.0;\n Py_INCREF(Py_None);\n- __pyx_k34 = Py_None;\n+ __pyx_k36 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":601 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":625 */\n+ __pyx_k37 = 0.0;\n+ __pyx_k38 = 1.0;\n Py_INCREF(Py_None);\n- __pyx_k35 = Py_None;\n+ __pyx_k39 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":615 */\n- __pyx_k36 = 1.0;\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":634 */\n+ __pyx_k40 = 0.0;\n+ __pyx_k41 = 1.0;\n Py_INCREF(Py_None);\n- __pyx_k37 = Py_None;\n+ __pyx_k42 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":625 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":643 */\n+ __pyx_k43 = 0.0;\n+ __pyx_k44 = 1.0;\n Py_INCREF(Py_None);\n- __pyx_k38 = Py_None;\n+ __pyx_k45 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":680 */\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":657 */\n Py_INCREF(Py_None);\n- __pyx_k39 = Py_None;\n+ __pyx_k46 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":666 */\n+ Py_INCREF(Py_None);\n+ __pyx_k47 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */\n+ Py_INCREF(Py_None);\n+ __pyx_k48 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":693 */\n+ Py_INCREF(Py_None);\n+ __pyx_k49 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":756 */\n- __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}\n- __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */\n+ Py_INCREF(Py_None);\n+ __pyx_k50 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":720 */\n+ __pyx_k51 = 1.0;\n+ Py_INCREF(Py_None);\n+ __pyx_k52 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":729 */\n+ Py_INCREF(Py_None);\n+ __pyx_k53 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":738 */\n+ Py_INCREF(Py_None);\n+ __pyx_k54 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":750 */\n+ Py_INCREF(Py_None);\n+ __pyx_k55 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */\n+ Py_INCREF(Py_None);\n+ __pyx_k56 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":829 */\n+ Py_INCREF(Py_None);\n+ __pyx_k57 = Py_None;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":905 */\n+ __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n+ __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":757 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":906 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":758 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":907 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":759 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":908 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":760 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":909 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":761 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":910 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":762 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":911 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":763 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":912 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":764 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":913 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":914 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":766 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":915 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":767 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":916 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":917 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":769 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":918 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":770 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":919 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":771 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":920 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":921 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":922 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":923 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":924 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":925 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":926 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":927 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":928 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":929 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":930 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":931 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":773 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":932 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_laplace); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":774 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":933 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gumbel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":775 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":934 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logistic); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":776 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":935 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_lognormal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":777 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":936 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rayleigh); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":778 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":937 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_wald); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":779 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":938 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_triangular); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":780 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":940 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":781 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":941 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":782 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":942 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":783 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":943 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zipf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":784 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":944 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_geometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":785 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":945 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_hypergeometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":786 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":947 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":787 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":948 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":788 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":950 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":789 */\n- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}\n- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}\n+ /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":951 */\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}\n+ if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n return;\n __pyx_L1:;\n", "added_lines": 2053, "deleted_lines": 1054, "source_code": "/* Generated by Pyrex 0.9.3.1 on Thu Oct 6 21:56:32 2005 */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n#ifndef PY_LONG_LONG\n #define PY_LONG_LONG LONG_LONG\n#endif\n#include \"string.h\"\n#include \"math.h\"\n#include \"scipy/arrayobject.h\"\n#include \"randomkit.h\"\n#include \"distributions.h\"\n#include \"initarray.h\"\n\n\ntypedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/\ntypedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/\nstatic PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/\nstatic int __Pyx_EndUnpack(PyObject *, int); /*proto*/\nstatic int __Pyx_PrintItem(PyObject *); /*proto*/\nstatic int __Pyx_PrintNewline(void); /*proto*/\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/\nstatic void __Pyx_ReRaise(void); /*proto*/\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/\nstatic PyObject *__Pyx_GetExcValue(void); /*proto*/\nstatic int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/\nstatic int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/\nstatic int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/\nstatic void __Pyx_WriteUnraisable(char *name); /*proto*/\nstatic void __Pyx_AddTraceback(char *funcname); /*proto*/\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/\nstatic int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/\nstatic int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/\nstatic PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/\n\nstatic PyObject *__pyx_m;\nstatic PyObject *__pyx_b;\nstatic int __pyx_lineno;\nstatic char *__pyx_filename;\nstaticforward char **__pyx_f;\n\n/* Declarations from mtrand */\n\nstaticforward PyTypeObject __pyx_type_6mtrand_RandomState;\n\nstruct __pyx_obj_6mtrand_RandomState {\n PyObject_HEAD\n rk_state (*internal_state);\n};\n\nstatic PyTypeObject *__pyx_ptype_6mtrand_ArrayType = 0;\nstatic PyTypeObject *__pyx_ptype_6mtrand_RandomState = 0;\nstatic PyObject *__pyx_k2;\nstatic PyObject *__pyx_k3;\nstatic PyObject *__pyx_k4;\nstatic PyObject *__pyx_k5;\nstatic PyObject *__pyx_k6;\nstatic PyObject *__pyx_k7;\nstatic double __pyx_k8;\nstatic double __pyx_k9;\nstatic PyObject *__pyx_k10;\nstatic PyObject *__pyx_k11;\nstatic PyObject *__pyx_k12;\nstatic PyObject *__pyx_k13;\nstatic double __pyx_k14;\nstatic double __pyx_k15;\nstatic PyObject *__pyx_k16;\nstatic PyObject *__pyx_k17;\nstatic double __pyx_k18;\nstatic PyObject *__pyx_k19;\nstatic PyObject *__pyx_k20;\nstatic PyObject *__pyx_k21;\nstatic double __pyx_k22;\nstatic PyObject *__pyx_k23;\nstatic PyObject *__pyx_k24;\nstatic PyObject *__pyx_k25;\nstatic PyObject *__pyx_k26;\nstatic PyObject *__pyx_k27;\nstatic PyObject *__pyx_k28;\nstatic PyObject *__pyx_k29;\nstatic PyObject *__pyx_k30;\nstatic PyObject *__pyx_k31;\nstatic PyObject *__pyx_k32;\nstatic PyObject *__pyx_k33;\nstatic double __pyx_k34;\nstatic double __pyx_k35;\nstatic PyObject *__pyx_k36;\nstatic double __pyx_k37;\nstatic double __pyx_k38;\nstatic PyObject *__pyx_k39;\nstatic double __pyx_k40;\nstatic double __pyx_k41;\nstatic PyObject *__pyx_k42;\nstatic double __pyx_k43;\nstatic double __pyx_k44;\nstatic PyObject *__pyx_k45;\nstatic PyObject *__pyx_k46;\nstatic PyObject *__pyx_k47;\nstatic PyObject *__pyx_k48;\nstatic PyObject *__pyx_k49;\nstatic PyObject *__pyx_k50;\nstatic double __pyx_k51;\nstatic PyObject *__pyx_k52;\nstatic PyObject *__pyx_k53;\nstatic PyObject *__pyx_k54;\nstatic PyObject *__pyx_k55;\nstatic PyObject *__pyx_k56;\nstatic PyObject *__pyx_k57;\nstatic PyObject *(__pyx_f_6mtrand_cont0_array(rk_state (*),double ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont1_array(rk_state (*),double ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont2_array(rk_state (*),double ((*)(rk_state (*),double ,double )),PyObject *,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont3_array(rk_state (*),double ((*)(rk_state (*),double ,double ,double )),PyObject *,double ,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_disc0_array(rk_state (*),long ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discnp_array(rk_state (*),long ((*)(rk_state (*),long ,double )),PyObject *,long ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discnmN_array(rk_state (*),long ((*)(rk_state (*),long ,long ,long )),PyObject *,long ,long ,long )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discd_array(rk_state (*),long ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic double (__pyx_f_6mtrand_kahan_sum(double (*),long )); /*proto*/\n\n/* Implementation of mtrand */\n\n\nstatic PyObject *__pyx_n__sp;\nstatic PyObject *__pyx_n__rand;\nstatic PyObject *__pyx_n_get_state;\nstatic PyObject *__pyx_n_set_state;\nstatic PyObject *__pyx_n_random_sample;\nstatic PyObject *__pyx_n_randint;\nstatic PyObject *__pyx_n_bytes;\nstatic PyObject *__pyx_n_uniform;\nstatic PyObject *__pyx_n_rand;\nstatic PyObject *__pyx_n_randn;\nstatic PyObject *__pyx_n_random_integers;\nstatic PyObject *__pyx_n_standard_normal;\nstatic PyObject *__pyx_n_normal;\nstatic PyObject *__pyx_n_beta;\nstatic PyObject *__pyx_n_exponential;\nstatic PyObject *__pyx_n_standard_exponential;\nstatic PyObject *__pyx_n_standard_gamma;\nstatic PyObject *__pyx_n_gamma;\nstatic PyObject *__pyx_n_f;\nstatic PyObject *__pyx_n_noncentral_f;\nstatic PyObject *__pyx_n_chisquare;\nstatic PyObject *__pyx_n_noncentral_chisquare;\nstatic PyObject *__pyx_n_standard_cauchy;\nstatic PyObject *__pyx_n_standard_t;\nstatic PyObject *__pyx_n_vonmises;\nstatic PyObject *__pyx_n_pareto;\nstatic PyObject *__pyx_n_weibull;\nstatic PyObject *__pyx_n_power;\nstatic PyObject *__pyx_n_laplace;\nstatic PyObject *__pyx_n_gumbel;\nstatic PyObject *__pyx_n_logistic;\nstatic PyObject *__pyx_n_lognormal;\nstatic PyObject *__pyx_n_rayleigh;\nstatic PyObject *__pyx_n_wald;\nstatic PyObject *__pyx_n_triangular;\nstatic PyObject *__pyx_n_binomial;\nstatic PyObject *__pyx_n_negative_binomial;\nstatic PyObject *__pyx_n_poisson;\nstatic PyObject *__pyx_n_zipf;\nstatic PyObject *__pyx_n_geometric;\nstatic PyObject *__pyx_n_hypergeometric;\nstatic PyObject *__pyx_n_multivariate_normal;\nstatic PyObject *__pyx_n_multinomial;\nstatic PyObject *__pyx_n_shuffle;\nstatic PyObject *__pyx_n_permutation;\nstatic PyObject *__pyx_n_scipy;\n\nstatic PyObject *__pyx_n_empty;\nstatic PyObject *__pyx_n_Float64;\n\nstatic PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":123 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":124 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":126 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":127 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":129 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":130 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":139 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":140 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":142 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":143 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":146 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont1_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":156 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":157 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":159 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":160 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":161 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":163 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":164 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont2_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b,double __pyx_v_c) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":174 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":175 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":177 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":178 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":180 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":181 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont3_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_Int;\n\nstatic PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":190 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":191 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":193 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":194 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":196 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":197 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.disc0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,double )),PyObject *__pyx_v_size,long __pyx_v_n,double __pyx_v_p) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":206 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":207 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":209 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":210 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":212 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":213 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discnp_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,long ,long )),PyObject *__pyx_v_size,long __pyx_v_n,long __pyx_v_m,long __pyx_v_N) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":223 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":224 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":226 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":227 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":230 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":231 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discnmN_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":239 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":240 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":242 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":243 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":244 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":245 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":246 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":247 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discd_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic double __pyx_f_6mtrand_kahan_sum(double (*__pyx_v_darr),long __pyx_v_n) {\n double __pyx_v_c;\n double __pyx_v_y;\n double __pyx_v_t;\n double __pyx_v_sum;\n long __pyx_v_i;\n double __pyx_r;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */\n __pyx_v_sum = (__pyx_v_darr[0]);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":253 */\n __pyx_v_c = 0.0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":254 */\n for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":255 */\n __pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":256 */\n __pyx_v_t = (__pyx_v_sum + __pyx_v_y);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":257 */\n __pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */\n __pyx_v_sum = __pyx_v_t;\n __pyx_L2:;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */\n __pyx_r = __pyx_v_sum;\n goto __pyx_L0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __pyx_L1:;\n __Pyx_WriteUnraisable(\"mtrand.kahan_sum\");\n __pyx_L0:;\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_seed;\n\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n int __pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k2;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return -1;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":282 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state (*))PyMem_Malloc((sizeof(rk_state ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":284 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__init__\");\n __pyx_r = -1;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self); /*proto*/\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {\n int __pyx_1;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":287 */\n __pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":288 */\n PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n goto __pyx_L0;\n __pyx_L1:;\n __Pyx_AddTraceback(\"mtrand.RandomState.__dealloc__\");\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n}\n\nstatic PyObject *__pyx_n_type;\nstatic PyObject *__pyx_n_int;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_seed[] = \"Seed the generator.\\n\\n seed(seed=None)\\n\\n seed can be an integer, an array (or other sequence) of integers of any\\n length, or None. If seed is None, then RandomState will try to read data\\n from /dev/urandom (or the Windows analogue) if available or seed from\\n the clock otherwise.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n rk_error __pyx_v_errcode;\n PyArrayObject *__pyx_v_obj;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n unsigned long __pyx_5;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k3;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n __pyx_v_obj = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_obj);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":302 */\n __pyx_1 = __pyx_v_seed == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":303 */\n __pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_seed);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n __pyx_1 = __pyx_4 == __pyx_2;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":305 */\n __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}\n rk_seed(__pyx_5,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */\n __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_obj));\n __pyx_v_obj = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */\n init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long (*))__pyx_v_obj->data),(__pyx_v_obj->dimensions[0]));\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.seed\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_obj);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_MT19937;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_get_state[] = \"Return a tuple representing the internal state of the generator.\\n\\n get_state() -> (\\'MT19937\\', int key[624], int pos)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyArrayObject *__pyx_v_state;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n __pyx_v_state = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":317 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_1 = 0;\n __pyx_4 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_1));\n Py_DECREF(((PyObject *)__pyx_v_state));\n __pyx_v_state = ((PyObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":318 */\n memcpy(((void (*))__pyx_v_state->data),((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":319 */\n __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n Py_INCREF(__pyx_n_MT19937);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_MT19937);\n Py_INCREF(((PyObject *)__pyx_v_state));\n PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_state));\n PyTuple_SET_ITEM(__pyx_2, 2, __pyx_4);\n __pyx_4 = 0;\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.get_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_state);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_ValueError;\n\nstatic PyObject *__pyx_k60p;\nstatic PyObject *__pyx_k61p;\n\nstatic char (__pyx_k60[]) = \"algorithm must be 'MT19937'\";\nstatic char (__pyx_k61[]) = \"state must be 624 longs\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_set_state[] = \"Set the state from a tuple.\\n \\n state = (\\'MT19937\\', int key[624], int pos)\\n \\n set_state(state)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyArrayObject *__pyx_v_obj;\n int __pyx_v_pos;\n PyObject *__pyx_v_algorithm_name;\n PyObject *__pyx_v_key;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n int __pyx_3;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n __pyx_v_obj = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_obj);\n __pyx_v_algorithm_name = Py_None; Py_INCREF(__pyx_v_algorithm_name);\n __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":330 */\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_algorithm_name);\n __pyx_v_algorithm_name = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":331 */\n if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}\n __pyx_3 = __pyx_3 != 0;\n if (__pyx_3) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":332 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n Py_INCREF(__pyx_k60p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k60p);\n __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":333 */\n __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n Py_DECREF(__pyx_v_key);\n __pyx_v_key = __pyx_2;\n __pyx_2 = 0;\n __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_v_pos = __pyx_3;\n if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":334 */\n __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_obj));\n __pyx_v_obj = __pyx_4;\n __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":335 */\n __pyx_3 = ((__pyx_v_obj->dimensions[0]) != 624);\n if (__pyx_3) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n Py_INCREF(__pyx_k61p);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k61p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":337 */\n memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,((void (*))__pyx_v_obj->data),(624 * (sizeof(long ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":338 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.set_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_obj);\n Py_DECREF(__pyx_v_algorithm_name);\n Py_DECREF(__pyx_v_key);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":342 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__getstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":345 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}\n Py_INCREF(__pyx_v_state);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__setstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_stats;\nstatic PyObject *__pyx_n___RandomState_ctor;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":348 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stats); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_5);\n __pyx_1 = 0;\n __pyx_2 = 0;\n __pyx_5 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.__reduce__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_sample[] = \"Return random floats in the half-open interval [0.0, 1.0).\\n\\n random_sample(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k4;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_sample\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_tomaxint[] = \"Returns random integers x such that 0 <= x <= sys.maxint.\\n\\n tomaxint(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k5;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */\n __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.tomaxint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k62p;\n\nstatic char (__pyx_k62[]) = \"low >= high\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randint[] = \"Return random integers x such that low <= x < high.\\n\\n randint(low, high=None, size=None) -> random values\\n\\n If high is None, then 0 <= x < low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_lo;\n long __pyx_v_hi;\n long __pyx_v_diff;\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n long __pyx_2;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k6;\n __pyx_v_size = __pyx_k7;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":378 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":379 */\n __pyx_v_lo = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":380 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":382 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}\n __pyx_v_lo = __pyx_2;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":383 */\n __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":385 */\n __pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":386 */\n __pyx_1 = (__pyx_v_diff < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n Py_INCREF(__pyx_k62p);\n PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k62p);\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __Pyx_Raise(__pyx_5, 0, 0);\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":389 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":390 */\n __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;}\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n goto __pyx_L4;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":392 */\n __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":393 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":394 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":395 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":396 */\n (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state));\n __pyx_L5:;\n }\n __pyx_L6:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L4:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.randint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_bytes[] = \"Return random bytes.\\n\\n bytes(length) -> str\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n unsigned int __pyx_v_length;\n void (*__pyx_v_bytes);\n PyObject *__pyx_v_bytestring;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"length\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"i\", __pyx_argnames, &__pyx_v_length)) return 0;\n Py_INCREF(__pyx_v_self);\n __pyx_v_bytestring = Py_None; Py_INCREF(__pyx_v_bytestring);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":405 */\n __pyx_v_bytes = PyMem_Malloc(__pyx_v_length);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":406 */\n rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":407 */\n __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n Py_DECREF(__pyx_v_bytestring);\n __pyx_v_bytestring = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":408 */\n PyMem_Free(__pyx_v_bytes);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":409 */\n Py_INCREF(__pyx_v_bytestring);\n __pyx_r = __pyx_v_bytestring;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.bytes\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_bytestring);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_uniform[] = \"Uniform distribution over [low, high).\\n\\n uniform(low=0.0, high=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_low;\n double __pyx_v_high;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_low = __pyx_k8;\n __pyx_v_high = __pyx_k9;\n __pyx_v_size = __pyx_k10;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":416 */\n __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.uniform\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_len;\nstatic PyObject *__pyx_n_size;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_rand[] = \"Return an array of the given dimensions which is initialized to \\n random numbers from a uniform distribution in the range [0,1).\\n\\n randn(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":425 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":426 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":428 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_r = __pyx_5;\n __pyx_5 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.rand\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randn[] = \"Returns zero-mean, unit-variance Gaussian random numbers in an \\n array of shape (d0, d1, ..., dn).\\n\\n randn(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":436 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":437 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":439 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_args);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.randn\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_integers[] = \"Return random integers x such that low <= x <= high.\\n\\n random_integers(low, high=None, size=None) -> random values.\\n\\n If high is None, then 1 <= x <= low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k11;\n __pyx_v_size = __pyx_k12;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":448 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":449 */\n Py_INCREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n __pyx_v_high = __pyx_v_low;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":450 */\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}\n Py_DECREF(__pyx_v_low);\n __pyx_v_low = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":451 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n Py_INCREF(__pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_size);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_4;\n __pyx_4 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_integers\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_normal[] = \"Standard Normal distribution (mean=0, stdev=1).\\n\\n standard_normal(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k13;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k64p;\n\nstatic char (__pyx_k64[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_normal[] = \"Normal distribution (mean=loc, stdev=scale).\\n\\n normal(loc=0.0, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k14;\n __pyx_v_scale = __pyx_k15;\n __pyx_v_size = __pyx_k16;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":467 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n Py_INCREF(__pyx_k64p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":468 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k65p;\nstatic PyObject *__pyx_k66p;\n\nstatic char (__pyx_k65[]) = \"a <= 0\";\nstatic char (__pyx_k66[]) = \"b <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_beta[] = \"Beta distribution over [0, 1].\\n\\n beta(a, b, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n double __pyx_v_b;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"b\",\"size\",0};\n __pyx_v_size = __pyx_k17;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":476 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n Py_INCREF(__pyx_k65p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k65p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_b <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":478 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n Py_INCREF(__pyx_k66p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":479 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.beta\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k67p;\n\nstatic char (__pyx_k67[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_exponential[] = \"Exponential distribution.\\n\\n exponential(scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k18;\n __pyx_v_size = __pyx_k19;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":487 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n Py_INCREF(__pyx_k67p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":488 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_exponential[] = \"Standard exponential distribution (scale=1).\\n\\n standard_exponential(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k20;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":495 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k68p;\n\nstatic char (__pyx_k68[]) = \"shape <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = \"Standard Gamma distribution.\\n\\n standard_gamma(shape, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"size\",0};\n __pyx_v_size = __pyx_k21;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":502 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":503 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n Py_INCREF(__pyx_k68p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":504 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k69p;\nstatic PyObject *__pyx_k70p;\n\nstatic char (__pyx_k69[]) = \"shape <= 0\";\nstatic char (__pyx_k70[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_gamma[] = \"Gamma distribution.\\n\\n gamma(shape, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k22;\n __pyx_v_size = __pyx_k23;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|dO\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":511 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":512 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n Py_INCREF(__pyx_k69p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":514 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n Py_INCREF(__pyx_k70p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":515 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k71p;\nstatic PyObject *__pyx_k72p;\n\nstatic char (__pyx_k71[]) = \"dfnum <= 0\";\nstatic char (__pyx_k72[]) = \"dfden <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_f[] = \"F distribution.\\n\\n f(dfnum, dfden, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"size\",0};\n __pyx_v_size = __pyx_k24;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */\n __pyx_1 = (__pyx_v_dfnum <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":523 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n Py_INCREF(__pyx_k71p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":525 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n Py_INCREF(__pyx_k72p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":526 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k73p;\nstatic PyObject *__pyx_k74p;\nstatic PyObject *__pyx_k75p;\n\nstatic char (__pyx_k73[]) = \"dfnum <= 1\";\nstatic char (__pyx_k74[]) = \"dfden <= 0\";\nstatic char (__pyx_k75[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = \"Noncentral F distribution.\\n\\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k25;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":533 */\n __pyx_1 = (__pyx_v_dfnum <= 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":534 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n Py_INCREF(__pyx_k73p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k73p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":536 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n Py_INCREF(__pyx_k74p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k74p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":538 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n Py_INCREF(__pyx_k75p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k75p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k76p;\n\nstatic char (__pyx_k76[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_chisquare[] = \"Chi^2 distribution.\\n\\n chisquare(df, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k26;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":548 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n Py_INCREF(__pyx_k76p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":549 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k77p;\nstatic PyObject *__pyx_k78p;\n\nstatic char (__pyx_k77[]) = \"df <= 1\";\nstatic char (__pyx_k78[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = \"Noncentral Chi^2 distribution.\\n\\n noncentral_chisquare(df, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k27;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */\n __pyx_1 = (__pyx_v_df <= 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":557 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n Py_INCREF(__pyx_k77p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k77p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":559 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n Py_INCREF(__pyx_k78p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k78p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":560 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_cauchy[] = \"Standard Cauchy with mode=0.\\n\\n standard_cauchy(size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k28;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":568 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_cauchy\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k79p;\n\nstatic char (__pyx_k79[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_t[] = \"Standard Student\\'s t distribution with df degrees of freedom.\\n\\n standard_t(df, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k29;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":576 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n Py_INCREF(__pyx_k79p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k79p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":577 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_t\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k80p;\n\nstatic char (__pyx_k80[]) = \"kappa < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_vonmises[] = \"von Mises circular distribution with mode mu and dispersion parameter\\n kappa on [-pi, pi].\\n\\n vonmises(mu, kappa, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mu;\n double __pyx_v_kappa;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mu\",\"kappa\",\"size\",0};\n __pyx_v_size = __pyx_k30;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mu, &__pyx_v_kappa, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":585 */\n __pyx_1 = (__pyx_v_kappa < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":586 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n Py_INCREF(__pyx_k80p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k80p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":587 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.vonmises\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k81p;\n\nstatic char (__pyx_k81[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_pareto[] = \"Pareto distribution.\\n\\n pareto(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k31;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":595 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n Py_INCREF(__pyx_k81p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k81p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":596 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.pareto\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k82p;\n\nstatic char (__pyx_k82[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_weibull[] = \"Weibull distribution.\\n\\n weibull(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k32;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":603 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":604 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n Py_INCREF(__pyx_k82p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k82p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":605 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.weibull\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k83p;\n\nstatic char (__pyx_k83[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_power[] = \"Power distribution.\\n\\n power(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k33;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":613 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n Py_INCREF(__pyx_k83p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k83p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":614 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.power\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k84p;\n\nstatic char (__pyx_k84[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_laplace[] = \"Laplace distribution.\\n \\n laplace(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k34;\n __pyx_v_scale = __pyx_k35;\n __pyx_v_size = __pyx_k36;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":622 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n Py_INCREF(__pyx_k84p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k84p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":623 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.laplace\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k85p;\n\nstatic char (__pyx_k85[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_gumbel[] = \"Gumbel distribution.\\n \\n gumbel(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k37;\n __pyx_v_scale = __pyx_k38;\n __pyx_v_size = __pyx_k39;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":630 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":631 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n Py_INCREF(__pyx_k85p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k85p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":632 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.gumbel\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k86p;\n\nstatic char (__pyx_k86[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_logistic[] = \"Logistic distribution.\\n \\n logistic(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k40;\n __pyx_v_scale = __pyx_k41;\n __pyx_v_size = __pyx_k42;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":639 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":640 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n Py_INCREF(__pyx_k86p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k86p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":641 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.logistic\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k87p;\n\nstatic char (__pyx_k87[]) = \"sigma <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_lognormal[] = \"Log-normal distribution.\\n \\n Note that the mean parameter is not the mean of this distribution, but \\n the underlying normal distribution.\\n \\n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\\n \\n lognormal(mean=0.0, sigma=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mean;\n double __pyx_v_sigma;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"sigma\",\"size\",0};\n __pyx_v_mean = __pyx_k43;\n __pyx_v_sigma = __pyx_k44;\n __pyx_v_size = __pyx_k45;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_sigma, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":653 */\n __pyx_1 = (__pyx_v_sigma <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":654 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n Py_INCREF(__pyx_k87p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k87p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":655 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_mean,__pyx_v_sigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.lognormal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k88p;\n\nstatic char (__pyx_k88[]) = \"mode <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_rayleigh[] = \"Rayleigh distribution.\\n \\n rayleigh(mode, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mode;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mode\",\"size\",0};\n __pyx_v_size = __pyx_k46;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_mode, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":662 */\n __pyx_1 = (__pyx_v_mode <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":663 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n Py_INCREF(__pyx_k88p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k88p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":664 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_mode); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.rayleigh\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k89p;\nstatic PyObject *__pyx_k90p;\n\nstatic char (__pyx_k89[]) = \"mean <= 0.0\";\nstatic char (__pyx_k90[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_wald[] = \"Wald (inverse Gaussian) distribution.\\n \\n wald(mean, scale, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mean;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"scale\",\"size\",0};\n __pyx_v_size = __pyx_k47;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":671 */\n __pyx_1 = (__pyx_v_mean <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":672 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_INCREF(__pyx_k89p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k89p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":674 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n Py_INCREF(__pyx_k90p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k90p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":675 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_mean,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.wald\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k91p;\nstatic PyObject *__pyx_k92p;\nstatic PyObject *__pyx_k93p;\n\nstatic char (__pyx_k91[]) = \"left > mode\";\nstatic char (__pyx_k92[]) = \"mode > right\";\nstatic char (__pyx_k93[]) = \"left == right\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_triangular[] = \"Triangular distribution starting at left, peaking at mode, and \\n ending at right (left <= mode <= right).\\n \\n triangular(left, mode, right, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_left;\n double __pyx_v_mode;\n double __pyx_v_right;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"left\",\"mode\",\"right\",\"size\",0};\n __pyx_v_size = __pyx_k48;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_left, &__pyx_v_mode, &__pyx_v_right, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":683 */\n __pyx_1 = (__pyx_v_left > __pyx_v_mode);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":684 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n Py_INCREF(__pyx_k91p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k91p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_mode > __pyx_v_right);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":686 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n Py_INCREF(__pyx_k92p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k92p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_left == __pyx_v_right);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":688 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n Py_INCREF(__pyx_k93p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k93p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":689 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_left,__pyx_v_mode,__pyx_v_right); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.triangular\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k94p;\nstatic PyObject *__pyx_k95p;\nstatic PyObject *__pyx_k96p;\n\nstatic char (__pyx_k94[]) = \"n <= 0\";\nstatic char (__pyx_k95[]) = \"p < 0\";\nstatic char (__pyx_k96[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k49;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":699 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n Py_INCREF(__pyx_k94p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k94p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":701 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n Py_INCREF(__pyx_k95p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k95p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n Py_INCREF(__pyx_k96p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k96p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k97p;\nstatic PyObject *__pyx_k98p;\nstatic PyObject *__pyx_k99p;\n\nstatic char (__pyx_k97[]) = \"n <= 0\";\nstatic char (__pyx_k98[]) = \"p < 0\";\nstatic char (__pyx_k99[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k50;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":712 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n Py_INCREF(__pyx_k97p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k97p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":714 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n Py_INCREF(__pyx_k98p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k98p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n Py_INCREF(__pyx_k99p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k99p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.negative_binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k100p;\n\nstatic char (__pyx_k100[]) = \"lam <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_poisson[] = \"Poisson distribution.\\n\\n poisson(lam=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_lam;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"lam\",\"size\",0};\n __pyx_v_lam = __pyx_k51;\n __pyx_v_size = __pyx_k52;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_lam, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":725 */\n __pyx_1 = (__pyx_v_lam <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":726 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n Py_INCREF(__pyx_k100p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k100p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":727 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.poisson\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k101p;\n\nstatic char (__pyx_k101[]) = \"a <= 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_zipf[] = \"Zipf distribution.\\n \\n zipf(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k53;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":734 */\n __pyx_1 = (__pyx_v_a <= 1.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":735 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n Py_INCREF(__pyx_k101p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k101p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":736 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.zipf\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k102p;\nstatic PyObject *__pyx_k103p;\n\nstatic char (__pyx_k102[]) = \"p < 0.0\";\nstatic char (__pyx_k103[]) = \"p > 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_geometric[] = \"Geometric distribution with p being the probability of \\\"success\\\" on\\n an individual trial.\\n \\n geometric(p, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"p\",\"size\",0};\n __pyx_v_size = __pyx_k54;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":744 */\n __pyx_1 = (__pyx_v_p < 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":745 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n Py_INCREF(__pyx_k102p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k102p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":747 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n Py_INCREF(__pyx_k103p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k103p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":748 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.geometric\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k104p;\nstatic PyObject *__pyx_k105p;\nstatic PyObject *__pyx_k106p;\nstatic PyObject *__pyx_k107p;\n\nstatic char (__pyx_k104[]) = \"ngood < 1\";\nstatic char (__pyx_k105[]) = \"nbad < 1\";\nstatic char (__pyx_k106[]) = \"ngood + nbad < nsample\";\nstatic char (__pyx_k107[]) = \"nsample < 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = \"Hypergeometric distribution.\\n \\n Consider an urn with ngood \\\"good\\\" balls and nbad \\\"bad\\\" balls. If one \\n were to draw nsample balls from the urn without replacement, then \\n the hypergeometric distribution describes the distribution of \\\"good\\\" \\n balls in the sample.\\n \\n hypergeometric(ngood, nbad, nsample, size=None) \\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_ngood;\n long __pyx_v_nbad;\n long __pyx_v_nsample;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"ngood\",\"nbad\",\"nsample\",\"size\",0};\n __pyx_v_size = __pyx_k55;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lll|O\", __pyx_argnames, &__pyx_v_ngood, &__pyx_v_nbad, &__pyx_v_nsample, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":760 */\n __pyx_1 = (__pyx_v_ngood < 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":761 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n Py_INCREF(__pyx_k104p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k104p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nbad < 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":763 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n Py_INCREF(__pyx_k105p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k105p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = ((__pyx_v_ngood + __pyx_v_nbad) < __pyx_v_nsample);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n Py_INCREF(__pyx_k106p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k106p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nsample < 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":767 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n Py_INCREF(__pyx_k107p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k107p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */\n __pyx_2 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ngood,__pyx_v_nbad,__pyx_v_nsample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.hypergeometric\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_array;\nstatic PyObject *__pyx_n_shape;\nstatic PyObject *__pyx_n_ArgumentError;\nstatic PyObject *__pyx_n_isinstance;\nstatic PyObject *__pyx_n_list;\nstatic PyObject *__pyx_n_append;\nstatic PyObject *__pyx_n_multiply;\nstatic PyObject *__pyx_n_reduce;\nstatic PyObject *__pyx_n_linalg;\nstatic PyObject *__pyx_n_singular_value_decomposition;\nstatic PyObject *__pyx_n_matrixmultiply;\nstatic PyObject *__pyx_n_sqrt;\nstatic PyObject *__pyx_n_add;\nstatic PyObject *__pyx_n_tuple;\n\nstatic PyObject *__pyx_k108p;\nstatic PyObject *__pyx_k109p;\nstatic PyObject *__pyx_k110p;\n\nstatic char (__pyx_k108[]) = \"mean must be 1 dimensional\";\nstatic char (__pyx_k109[]) = \"cov must be 2 dimensional and square\";\nstatic char (__pyx_k110[]) = \"mean and cov must have same length\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = \"Return an array containing multivariate normally distributed random numbers\\n with specified mean and covariance.\\n\\n multivariate_normal(mean, cov) -> random values\\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\\n\\n mean must be a 1 dimensional array. cov must be a square two dimensional\\n array with the same number of rows and columns as mean has elements.\\n\\n The first form returns a single 1-D array containing a multivariate\\n normal.\\n\\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\\n normal.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_mean = 0;\n PyObject *__pyx_v_cov = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_final_shape;\n PyObject *__pyx_v_x;\n PyObject *__pyx_v_u;\n PyObject *__pyx_v_s;\n PyObject *__pyx_v_v;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"cov\",\"size\",0};\n __pyx_v_size = __pyx_k56;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"OO|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_cov, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_mean);\n Py_INCREF(__pyx_v_cov);\n Py_INCREF(__pyx_v_size);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_final_shape = Py_None; Py_INCREF(__pyx_v_final_shape);\n __pyx_v_x = Py_None; Py_INCREF(__pyx_v_x);\n __pyx_v_u = Py_None; Py_INCREF(__pyx_v_u);\n __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);\n __pyx_v_v = Py_None; Py_INCREF(__pyx_v_v);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":790 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_mean);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_mean);\n __pyx_v_mean = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":791 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cov);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_cov);\n __pyx_v_cov = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":792 */\n __pyx_4 = __pyx_v_size == Py_None;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":793 */\n __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; goto __pyx_L1;}\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":795 */\n Py_INCREF(__pyx_v_size);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_v_size;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":796 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":797 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n Py_INCREF(__pyx_k108p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k108p);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_3, 0, 0);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":798 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (!__pyx_4) {\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n }\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":799 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n Py_INCREF(__pyx_k109p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k109p);\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}\n goto __pyx_L4;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":800 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":801 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n Py_INCREF(__pyx_k110p);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k110p);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __Pyx_Raise(__pyx_2, 0, 0);\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}\n goto __pyx_L5;\n }\n __pyx_L5:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":803 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":804 */\n __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyList_SET_ITEM(__pyx_1, 0, __pyx_v_shape);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L6;\n }\n __pyx_L6:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":805 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);\n __pyx_5 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_final_shape);\n __pyx_v_final_shape = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":806 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":810 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);\n __pyx_3 = 0;\n __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_5;\n __pyx_5 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":811 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_final_shape);\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);\n PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);\n __pyx_3 = 0;\n __pyx_5 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":821 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_linalg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_singular_value_decomposition); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_cov);\n __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_v_u);\n __pyx_v_u = __pyx_3;\n __pyx_3 = 0;\n __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_v_s);\n __pyx_v_s = __pyx_5;\n __pyx_5 = 0;\n __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_v_v);\n __pyx_v_v = __pyx_1;\n __pyx_1 = 0;\n if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":822 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_INCREF(__pyx_v_s);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n Py_INCREF(__pyx_v_v);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_v);\n __pyx_2 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":825 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_mean);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_x);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_x);\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":826 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":827 */\n Py_INCREF(__pyx_v_x);\n __pyx_r = __pyx_v_x;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.multivariate_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_final_shape);\n Py_DECREF(__pyx_v_x);\n Py_DECREF(__pyx_v_u);\n Py_DECREF(__pyx_v_s);\n Py_DECREF(__pyx_v_v);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_mean);\n Py_DECREF(__pyx_v_cov);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_zeros;\n\nstatic PyObject *__pyx_k111p;\n\nstatic char (__pyx_k111[]) = \"sum(pvals) > 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multinomial[] = \"Multinomial distribution.\\n \\n multinomial(n, pvals, size=None) -> random values\\n\\n pvals is a sequence of probabilities that should sum to 1 (however, the\\n last element is always assumed to account for the remaining probability\\n as long as sum(pvals[:-1]) <= 1).\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n PyObject *__pyx_v_pvals = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_d;\n PyArrayObject *__pyx_v_parr;\n PyArrayObject *__pyx_v_mnarr;\n double (*__pyx_v_pix);\n long (*__pyx_v_mnix);\n long __pyx_v_i;\n long __pyx_v_j;\n long __pyx_v_dn;\n double __pyx_v_Sum;\n double __pyx_v_prob;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_multin;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"n\",\"pvals\",\"size\",0};\n __pyx_v_size = __pyx_k57;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lO|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_pvals, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_pvals);\n Py_INCREF(__pyx_v_size);\n __pyx_v_parr = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_parr);\n __pyx_v_mnarr = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_mnarr);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_multin = Py_None; Py_INCREF(__pyx_v_multin);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":845 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n Py_INCREF(__pyx_v_pvals);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pvals);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_v_d = __pyx_4;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":846 */\n __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_parr));\n __pyx_v_parr = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":847 */\n __pyx_v_pix = ((double (*))__pyx_v_parr->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":849 */\n __pyx_5 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > 1.0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":850 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n Py_INCREF(__pyx_k111p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k111p);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":852 */\n __pyx_5 = __pyx_v_size == Py_None;\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":853 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}\n __pyx_5 = __pyx_3 == __pyx_1;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":855 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":857 */\n __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":859 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_multin);\n __pyx_v_multin = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":860 */\n Py_INCREF(((PyObject *)__pyx_v_multin));\n Py_DECREF(((PyObject *)__pyx_v_mnarr));\n __pyx_v_mnarr = ((PyObject *)__pyx_v_multin);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":861 */\n __pyx_v_mnix = ((long (*))__pyx_v_mnarr->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":862 */\n __pyx_v_i = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":863 */\n while (1) {\n __pyx_L4:;\n __pyx_5 = (__pyx_v_i < PyArray_SIZE(__pyx_v_mnarr));\n if (!__pyx_5) break;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":864 */\n __pyx_v_Sum = 1.0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":865 */\n __pyx_v_dn = __pyx_v_n;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":866 */\n __pyx_4 = (__pyx_v_d - 1);\n for (__pyx_v_j = 0; __pyx_v_j < __pyx_4; ++__pyx_v_j) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":867 */\n (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":868 */\n __pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":869 */\n __pyx_5 = (__pyx_v_dn <= 0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":870 */\n goto __pyx_L7;\n goto __pyx_L8;\n }\n __pyx_L8:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":871 */\n __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j]));\n __pyx_L6:;\n }\n __pyx_L7:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":872 */\n __pyx_5 = (__pyx_v_dn > 0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":873 */\n (__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn;\n goto __pyx_L9;\n }\n __pyx_L9:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":875 */\n __pyx_v_i = (__pyx_v_i + __pyx_v_d);\n }\n __pyx_L5:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":877 */\n Py_INCREF(__pyx_v_multin);\n __pyx_r = __pyx_v_multin;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.multinomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_parr);\n Py_DECREF(__pyx_v_mnarr);\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_multin);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_pvals);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_shuffle[] = \"Modify a sequence in-place by shuffling its contents.\\n \\n shuffle(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n long __pyx_v_i;\n long __pyx_v_j;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":888 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_v_i = __pyx_4;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":889 */\n while (1) {\n __pyx_L2:;\n __pyx_5 = (__pyx_v_i > 0);\n if (!__pyx_5) break;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":890 */\n __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":891 */\n __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":892 */\n __pyx_v_i = (__pyx_v_i - 1);\n }\n __pyx_L3:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.shuffle\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_arange;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_permutation[] = \"Given an integer, return a shuffled sequence of integers >= 0 and \\n < x.\\n\\n permutation(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n PyObject *__pyx_v_arr;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":900 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_arange); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_arr);\n __pyx_v_arr = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":901 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}\n Py_INCREF(__pyx_v_arr);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_arr);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":902 */\n Py_INCREF(__pyx_v_arr);\n __pyx_r = __pyx_v_arr;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.permutation\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_arr);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_ArgumentError, \"ArgumentError\"},\n {&__pyx_n_Float64, \"Float64\"},\n {&__pyx_n_Int, \"Int\"},\n {&__pyx_n_MT19937, \"MT19937\"},\n {&__pyx_n_ValueError, \"ValueError\"},\n {&__pyx_n___RandomState_ctor, \"__RandomState_ctor\"},\n {&__pyx_n__rand, \"_rand\"},\n {&__pyx_n__sp, \"_sp\"},\n {&__pyx_n_add, \"add\"},\n {&__pyx_n_append, \"append\"},\n {&__pyx_n_arange, \"arange\"},\n {&__pyx_n_array, \"array\"},\n {&__pyx_n_beta, \"beta\"},\n {&__pyx_n_binomial, \"binomial\"},\n {&__pyx_n_bytes, \"bytes\"},\n {&__pyx_n_chisquare, \"chisquare\"},\n {&__pyx_n_empty, \"empty\"},\n {&__pyx_n_exponential, \"exponential\"},\n {&__pyx_n_f, \"f\"},\n {&__pyx_n_gamma, \"gamma\"},\n {&__pyx_n_geometric, \"geometric\"},\n {&__pyx_n_get_state, \"get_state\"},\n {&__pyx_n_gumbel, \"gumbel\"},\n {&__pyx_n_hypergeometric, \"hypergeometric\"},\n {&__pyx_n_int, \"int\"},\n {&__pyx_n_isinstance, \"isinstance\"},\n {&__pyx_n_laplace, \"laplace\"},\n {&__pyx_n_len, \"len\"},\n {&__pyx_n_linalg, \"linalg\"},\n {&__pyx_n_list, \"list\"},\n {&__pyx_n_logistic, \"logistic\"},\n {&__pyx_n_lognormal, \"lognormal\"},\n {&__pyx_n_matrixmultiply, \"matrixmultiply\"},\n {&__pyx_n_multinomial, \"multinomial\"},\n {&__pyx_n_multiply, \"multiply\"},\n {&__pyx_n_multivariate_normal, \"multivariate_normal\"},\n {&__pyx_n_negative_binomial, \"negative_binomial\"},\n {&__pyx_n_noncentral_chisquare, \"noncentral_chisquare\"},\n {&__pyx_n_noncentral_f, \"noncentral_f\"},\n {&__pyx_n_normal, \"normal\"},\n {&__pyx_n_pareto, \"pareto\"},\n {&__pyx_n_permutation, \"permutation\"},\n {&__pyx_n_poisson, \"poisson\"},\n {&__pyx_n_power, \"power\"},\n {&__pyx_n_rand, \"rand\"},\n {&__pyx_n_randint, \"randint\"},\n {&__pyx_n_randn, \"randn\"},\n {&__pyx_n_random_integers, \"random_integers\"},\n {&__pyx_n_random_sample, \"random_sample\"},\n {&__pyx_n_rayleigh, \"rayleigh\"},\n {&__pyx_n_reduce, \"reduce\"},\n {&__pyx_n_scipy, \"scipy\"},\n {&__pyx_n_seed, \"seed\"},\n {&__pyx_n_set_state, \"set_state\"},\n {&__pyx_n_shape, \"shape\"},\n {&__pyx_n_shuffle, \"shuffle\"},\n {&__pyx_n_singular_value_decomposition, \"singular_value_decomposition\"},\n {&__pyx_n_size, \"size\"},\n {&__pyx_n_sqrt, \"sqrt\"},\n {&__pyx_n_standard_cauchy, \"standard_cauchy\"},\n {&__pyx_n_standard_exponential, \"standard_exponential\"},\n {&__pyx_n_standard_gamma, \"standard_gamma\"},\n {&__pyx_n_standard_normal, \"standard_normal\"},\n {&__pyx_n_standard_t, \"standard_t\"},\n {&__pyx_n_stats, \"stats\"},\n {&__pyx_n_triangular, \"triangular\"},\n {&__pyx_n_tuple, \"tuple\"},\n {&__pyx_n_type, \"type\"},\n {&__pyx_n_uniform, \"uniform\"},\n {&__pyx_n_vonmises, \"vonmises\"},\n {&__pyx_n_wald, \"wald\"},\n {&__pyx_n_weibull, \"weibull\"},\n {&__pyx_n_zeros, \"zeros\"},\n {&__pyx_n_zipf, \"zipf\"},\n {0, 0}\n};\n\nstatic __Pyx_StringTabEntry __pyx_string_tab[] = {\n {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)},\n {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)},\n {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)},\n {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)},\n {&__pyx_k65p, __pyx_k65, sizeof(__pyx_k65)},\n {&__pyx_k66p, __pyx_k66, sizeof(__pyx_k66)},\n {&__pyx_k67p, __pyx_k67, sizeof(__pyx_k67)},\n {&__pyx_k68p, __pyx_k68, sizeof(__pyx_k68)},\n {&__pyx_k69p, __pyx_k69, sizeof(__pyx_k69)},\n {&__pyx_k70p, __pyx_k70, sizeof(__pyx_k70)},\n {&__pyx_k71p, __pyx_k71, sizeof(__pyx_k71)},\n {&__pyx_k72p, __pyx_k72, sizeof(__pyx_k72)},\n {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)},\n {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)},\n {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)},\n {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)},\n {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)},\n {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)},\n {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)},\n {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)},\n {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)},\n {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)},\n {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)},\n {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)},\n {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)},\n {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)},\n {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)},\n {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)},\n {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)},\n {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)},\n {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)},\n {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)},\n {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)},\n {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)},\n {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)},\n {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)},\n {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)},\n {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)},\n {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)},\n {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)},\n {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)},\n {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)},\n {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)},\n {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)},\n {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)},\n {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)},\n {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)},\n {&__pyx_k108p, __pyx_k108, sizeof(__pyx_k108)},\n {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)},\n {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)},\n {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)},\n {0, 0, 0}\n};\n\nstatic PyObject *__pyx_tp_new_6mtrand_RandomState(PyTypeObject *t, PyObject *a, PyObject *k) {\n PyObject *o = (*t->tp_alloc)(t, 0);\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return o;\n}\n\nstatic void __pyx_tp_dealloc_6mtrand_RandomState(PyObject *o) {\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n {\n PyObject *etype, *eval, *etb;\n PyErr_Fetch(&etype, &eval, &etb);\n ++o->ob_refcnt;\n __pyx_f_6mtrand_11RandomState___dealloc__(o);\n if (PyErr_Occurred()) PyErr_WriteUnraisable(o);\n --o->ob_refcnt;\n PyErr_Restore(etype, eval, etb);\n }\n (*o->ob_type->tp_free)(o);\n}\n\nstatic int __pyx_tp_traverse_6mtrand_RandomState(PyObject *o, visitproc v, void *a) {\n int e;\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return 0;\n}\n\nstatic int __pyx_tp_clear_6mtrand_RandomState(PyObject *o) {\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return 0;\n}\n\nstatic struct PyMethodDef __pyx_methods_6mtrand_RandomState[] = {\n {\"seed\", (PyCFunction)__pyx_f_6mtrand_11RandomState_seed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_seed},\n {\"get_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_get_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_get_state},\n {\"set_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_set_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_set_state},\n {\"__getstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___getstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__setstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___setstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__reduce__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___reduce__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"random_sample\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_sample},\n {\"tomaxint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_tomaxint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_tomaxint},\n {\"randint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randint},\n {\"bytes\", (PyCFunction)__pyx_f_6mtrand_11RandomState_bytes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_bytes},\n {\"uniform\", (PyCFunction)__pyx_f_6mtrand_11RandomState_uniform, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_uniform},\n {\"rand\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rand, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rand},\n {\"randn\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randn, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randn},\n {\"random_integers\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_integers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_integers},\n {\"standard_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_normal},\n {\"normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_normal},\n {\"beta\", (PyCFunction)__pyx_f_6mtrand_11RandomState_beta, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_beta},\n {\"exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_exponential},\n {\"standard_exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_exponential},\n {\"standard_gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_gamma},\n {\"gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gamma},\n {\"f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_f},\n {\"noncentral_f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_f},\n {\"chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_chisquare},\n {\"noncentral_chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_chisquare},\n {\"standard_cauchy\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_cauchy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_cauchy},\n {\"standard_t\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_t, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_t},\n {\"vonmises\", (PyCFunction)__pyx_f_6mtrand_11RandomState_vonmises, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_vonmises},\n {\"pareto\", (PyCFunction)__pyx_f_6mtrand_11RandomState_pareto, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_pareto},\n {\"weibull\", (PyCFunction)__pyx_f_6mtrand_11RandomState_weibull, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_weibull},\n {\"power\", (PyCFunction)__pyx_f_6mtrand_11RandomState_power, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_power},\n {\"laplace\", (PyCFunction)__pyx_f_6mtrand_11RandomState_laplace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_laplace},\n {\"gumbel\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gumbel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gumbel},\n {\"logistic\", (PyCFunction)__pyx_f_6mtrand_11RandomState_logistic, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_logistic},\n {\"lognormal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_lognormal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_lognormal},\n {\"rayleigh\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rayleigh, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rayleigh},\n {\"wald\", (PyCFunction)__pyx_f_6mtrand_11RandomState_wald, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_wald},\n {\"triangular\", (PyCFunction)__pyx_f_6mtrand_11RandomState_triangular, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_triangular},\n {\"binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_binomial},\n {\"negative_binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_negative_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_negative_binomial},\n {\"poisson\", (PyCFunction)__pyx_f_6mtrand_11RandomState_poisson, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_poisson},\n {\"zipf\", (PyCFunction)__pyx_f_6mtrand_11RandomState_zipf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_zipf},\n {\"geometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_geometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_geometric},\n {\"hypergeometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_hypergeometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_hypergeometric},\n {\"multivariate_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multivariate_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multivariate_normal},\n {\"multinomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multinomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multinomial},\n {\"shuffle\", (PyCFunction)__pyx_f_6mtrand_11RandomState_shuffle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_shuffle},\n {\"permutation\", (PyCFunction)__pyx_f_6mtrand_11RandomState_permutation, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_permutation},\n {0, 0, 0, 0}\n};\n\nstatic PyNumberMethods __pyx_tp_as_number_RandomState = {\n 0, /*nb_add*/\n 0, /*nb_subtract*/\n 0, /*nb_multiply*/\n 0, /*nb_divide*/\n 0, /*nb_remainder*/\n 0, /*nb_divmod*/\n 0, /*nb_power*/\n 0, /*nb_negative*/\n 0, /*nb_positive*/\n 0, /*nb_absolute*/\n 0, /*nb_nonzero*/\n 0, /*nb_invert*/\n 0, /*nb_lshift*/\n 0, /*nb_rshift*/\n 0, /*nb_and*/\n 0, /*nb_xor*/\n 0, /*nb_or*/\n 0, /*nb_coerce*/\n 0, /*nb_int*/\n 0, /*nb_long*/\n 0, /*nb_float*/\n 0, /*nb_oct*/\n 0, /*nb_hex*/\n 0, /*nb_inplace_add*/\n 0, /*nb_inplace_subtract*/\n 0, /*nb_inplace_multiply*/\n 0, /*nb_inplace_divide*/\n 0, /*nb_inplace_remainder*/\n 0, /*nb_inplace_power*/\n 0, /*nb_inplace_lshift*/\n 0, /*nb_inplace_rshift*/\n 0, /*nb_inplace_and*/\n 0, /*nb_inplace_xor*/\n 0, /*nb_inplace_or*/\n 0, /*nb_floor_divide*/\n 0, /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n};\n\nstatic PySequenceMethods __pyx_tp_as_sequence_RandomState = {\n 0, /*sq_length*/\n 0, /*sq_concat*/\n 0, /*sq_repeat*/\n 0, /*sq_item*/\n 0, /*sq_slice*/\n 0, /*sq_ass_item*/\n 0, /*sq_ass_slice*/\n 0, /*sq_contains*/\n 0, /*sq_inplace_concat*/\n 0, /*sq_inplace_repeat*/\n};\n\nstatic PyMappingMethods __pyx_tp_as_mapping_RandomState = {\n 0, /*mp_length*/\n 0, /*mp_subscript*/\n 0, /*mp_ass_subscript*/\n};\n\nstatic PyBufferProcs __pyx_tp_as_buffer_RandomState = {\n 0, /*bf_getreadbuffer*/\n 0, /*bf_getwritebuffer*/\n 0, /*bf_getsegcount*/\n 0, /*bf_getcharbuffer*/\n};\n\nstatichere PyTypeObject __pyx_type_6mtrand_RandomState = {\n PyObject_HEAD_INIT(0)\n 0, /*ob_size*/\n \"mtrand.RandomState\", /*tp_name*/\n sizeof(struct __pyx_obj_6mtrand_RandomState), /*tp_basicsize*/\n 0, /*tp_itemsize*/\n __pyx_tp_dealloc_6mtrand_RandomState, /*tp_dealloc*/\n 0, /*tp_print*/\n 0, /*tp_getattr*/\n 0, /*tp_setattr*/\n 0, /*tp_compare*/\n 0, /*tp_repr*/\n &__pyx_tp_as_number_RandomState, /*tp_as_number*/\n &__pyx_tp_as_sequence_RandomState, /*tp_as_sequence*/\n &__pyx_tp_as_mapping_RandomState, /*tp_as_mapping*/\n 0, /*tp_hash*/\n 0, /*tp_call*/\n 0, /*tp_str*/\n 0, /*tp_getattro*/\n 0, /*tp_setattro*/\n &__pyx_tp_as_buffer_RandomState, /*tp_as_buffer*/\n Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/\n \"Container for the Mersenne Twister PRNG.\\n\\n Constructor\\n -----------\\n RandomState(seed=None): initializes the PRNG with the given seed. See the\\n seed() method for details.\\n\\n Distribution Methods\\n -----------------\\n RandomState exposes a number of methods for generating random numbers drawn\\n from a variety of probability distributions. In addition to the\\n distribution-specific arguments, each method takes a keyword argument\\n size=None. If size is None, then a single value is generated and returned.\\n If size is an integer, then a 1-D scipy array filled with generated values\\n is returned. If size is a tuple, then a scipy array with that shape is\\n filled and returned.\\n \", /*tp_doc*/\n __pyx_tp_traverse_6mtrand_RandomState, /*tp_traverse*/\n __pyx_tp_clear_6mtrand_RandomState, /*tp_clear*/\n 0, /*tp_richcompare*/\n 0, /*tp_weaklistoffset*/\n 0, /*tp_iter*/\n 0, /*tp_iternext*/\n __pyx_methods_6mtrand_RandomState, /*tp_methods*/\n 0, /*tp_members*/\n 0, /*tp_getset*/\n 0, /*tp_base*/\n 0, /*tp_dict*/\n 0, /*tp_descr_get*/\n 0, /*tp_descr_set*/\n 0, /*tp_dictoffset*/\n __pyx_f_6mtrand_11RandomState___init__, /*tp_init*/\n 0, /*tp_alloc*/\n __pyx_tp_new_6mtrand_RandomState, /*tp_new*/\n 0, /*tp_free*/\n 0, /*tp_is_gc*/\n 0, /*tp_bases*/\n 0, /*tp_mro*/\n 0, /*tp_cache*/\n 0, /*tp_subclasses*/\n 0, /*tp_weaklist*/\n};\n\nstatic struct PyMethodDef __pyx_methods[] = {\n {0, 0, 0, 0}\n};\n\nDL_EXPORT(void) initmtrand(void); /*proto*/\nDL_EXPORT(void) initmtrand(void) {\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n __pyx_m = Py_InitModule4(\"mtrand\", __pyx_methods, 0, 0, PYTHON_API_VERSION);\n if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_b = PyImport_AddModule(\"__builtin__\");\n if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (PyObject_SetAttrString(__pyx_m, \"__builtins__\", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_ptype_6mtrand_ArrayType = __Pyx_ImportType(\"scipy\", \"ArrayType\", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ArrayType) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L1;}\n if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}\n if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}\n __pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":113 */\n import_array();\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":115 */\n __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}\n if (PyObject_SetAttr(__pyx_m, __pyx_n__sp, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":281 */\n Py_INCREF(Py_None);\n __pyx_k2 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":290 */\n Py_INCREF(Py_None);\n __pyx_k3 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":351 */\n Py_INCREF(Py_None);\n __pyx_k4 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":358 */\n Py_INCREF(Py_None);\n __pyx_k5 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":365 */\n Py_INCREF(Py_None);\n __pyx_k6 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k7 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":411 */\n __pyx_k8 = 0.0;\n __pyx_k9 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k10 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */\n Py_INCREF(Py_None);\n __pyx_k11 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k12 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":454 */\n Py_INCREF(Py_None);\n __pyx_k13 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":461 */\n __pyx_k14 = 0.0;\n __pyx_k15 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k16 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":470 */\n Py_INCREF(Py_None);\n __pyx_k17 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":481 */\n __pyx_k18 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k19 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":490 */\n Py_INCREF(Py_None);\n __pyx_k20 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":497 */\n Py_INCREF(Py_None);\n __pyx_k21 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":506 */\n __pyx_k22 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k23 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":517 */\n Py_INCREF(Py_None);\n __pyx_k24 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */\n Py_INCREF(Py_None);\n __pyx_k25 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":542 */\n Py_INCREF(Py_None);\n __pyx_k26 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":551 */\n Py_INCREF(Py_None);\n __pyx_k27 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":563 */\n Py_INCREF(Py_None);\n __pyx_k28 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":570 */\n Py_INCREF(Py_None);\n __pyx_k29 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":579 */\n Py_INCREF(Py_None);\n __pyx_k30 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":589 */\n Py_INCREF(Py_None);\n __pyx_k31 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":598 */\n Py_INCREF(Py_None);\n __pyx_k32 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":607 */\n Py_INCREF(Py_None);\n __pyx_k33 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":616 */\n __pyx_k34 = 0.0;\n __pyx_k35 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k36 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":625 */\n __pyx_k37 = 0.0;\n __pyx_k38 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k39 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":634 */\n __pyx_k40 = 0.0;\n __pyx_k41 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k42 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":643 */\n __pyx_k43 = 0.0;\n __pyx_k44 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k45 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":657 */\n Py_INCREF(Py_None);\n __pyx_k46 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":666 */\n Py_INCREF(Py_None);\n __pyx_k47 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */\n Py_INCREF(Py_None);\n __pyx_k48 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":693 */\n Py_INCREF(Py_None);\n __pyx_k49 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */\n Py_INCREF(Py_None);\n __pyx_k50 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":720 */\n __pyx_k51 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k52 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":729 */\n Py_INCREF(Py_None);\n __pyx_k53 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":738 */\n Py_INCREF(Py_None);\n __pyx_k54 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":750 */\n Py_INCREF(Py_None);\n __pyx_k55 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */\n Py_INCREF(Py_None);\n __pyx_k56 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":829 */\n Py_INCREF(Py_None);\n __pyx_k57 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":905 */\n __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":906 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":907 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":908 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":909 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":910 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":911 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":912 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":913 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":914 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":915 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":916 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":917 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":918 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":919 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":920 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":921 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":922 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":923 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":924 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":925 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":926 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":927 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":928 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":929 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":930 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":931 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":932 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_laplace); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":933 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gumbel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":934 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logistic); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":935 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_lognormal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":936 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rayleigh); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":937 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_wald); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":938 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_triangular); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":940 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":941 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":942 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":943 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zipf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":944 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_geometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":945 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_hypergeometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":947 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":948 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":950 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":951 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n return;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n __Pyx_AddTraceback(\"mtrand\");\n}\n\nstatic char *__pyx_filenames[] = {\n \"mtrand.pyx\",\n \"scipy.pxi\",\n};\nstatichere char **__pyx_f = __pyx_filenames;\n\n/* Runtime support code */\n\nstatic int __Pyx_GetStarArgs(\n PyObject **args, \n PyObject **kwds,\n char *kwd_list[], \n int nargs,\n PyObject **args2, \n PyObject **kwds2)\n{\n PyObject *x = 0, *args1 = 0, *kwds1 = 0;\n \n if (args2)\n *args2 = 0;\n if (kwds2)\n *kwds2 = 0;\n \n if (args2) {\n args1 = PyTuple_GetSlice(*args, 0, nargs);\n if (!args1)\n goto bad;\n *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args));\n if (!*args2)\n goto bad;\n }\n else {\n args1 = *args;\n Py_INCREF(args1);\n }\n \n if (kwds2) {\n if (*kwds) {\n char **p;\n kwds1 = PyDict_New();\n if (!kwds)\n goto bad;\n *kwds2 = PyDict_Copy(*kwds);\n if (!*kwds2)\n goto bad;\n for (p = kwd_list; *p; p++) {\n x = PyDict_GetItemString(*kwds, *p);\n if (x) {\n if (PyDict_SetItemString(kwds1, *p, x) < 0)\n goto bad;\n if (PyDict_DelItemString(*kwds2, *p) < 0)\n goto bad;\n }\n }\n }\n else {\n *kwds2 = PyDict_New();\n if (!*kwds2)\n goto bad;\n }\n }\n else {\n kwds1 = *kwds;\n Py_XINCREF(kwds1);\n }\n \n *args = args1;\n *kwds = kwds1;\n return 0;\nbad:\n Py_XDECREF(args1);\n Py_XDECREF(kwds1);\n if (*args2)\n Py_XDECREF(*args2);\n if (*kwds2)\n Py_XDECREF(*kwds2);\n return -1;\n}\n\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {\n PyObject *__import__ = 0;\n PyObject *empty_list = 0;\n PyObject *module = 0;\n PyObject *global_dict = 0;\n PyObject *empty_dict = 0;\n PyObject *list;\n __import__ = PyObject_GetAttrString(__pyx_b, \"__import__\");\n if (!__import__)\n goto bad;\n if (from_list)\n list = from_list;\n else {\n empty_list = PyList_New(0);\n if (!empty_list)\n goto bad;\n list = empty_list;\n }\n global_dict = PyModule_GetDict(__pyx_m);\n if (!global_dict)\n goto bad;\n empty_dict = PyDict_New();\n if (!empty_dict)\n goto bad;\n module = PyObject_CallFunction(__import__, \"OOOO\",\n name, global_dict, empty_dict, list);\nbad:\n Py_XDECREF(empty_list);\n Py_XDECREF(__import__);\n Py_XDECREF(empty_dict);\n return module;\n}\n\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {\n PyObject *result;\n result = PyObject_GetAttr(dict, name);\n if (!result)\n PyErr_SetObject(PyExc_NameError, name);\n return result;\n}\n\nstatic void __Pyx_WriteUnraisable(char *name) {\n PyObject *old_exc, *old_val, *old_tb;\n PyObject *ctx;\n PyErr_Fetch(&old_exc, &old_val, &old_tb);\n ctx = PyString_FromString(name);\n PyErr_Restore(old_exc, old_val, old_tb);\n if (!ctx)\n ctx = Py_None;\n PyErr_WriteUnraisable(ctx);\n}\n\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {\n Py_XINCREF(type);\n Py_XINCREF(value);\n Py_XINCREF(tb);\n /* First, check the traceback argument, replacing None with NULL. */\n if (tb == Py_None) {\n Py_DECREF(tb);\n tb = 0;\n }\n else if (tb != NULL && !PyTraceBack_Check(tb)) {\n PyErr_SetString(PyExc_TypeError,\n \"raise: arg 3 must be a traceback or None\");\n goto raise_error;\n }\n /* Next, replace a missing value with None */\n if (value == NULL) {\n value = Py_None;\n Py_INCREF(value);\n }\n /* Next, repeatedly, replace a tuple exception with its first item */\n while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {\n PyObject *tmp = type;\n type = PyTuple_GET_ITEM(type, 0);\n Py_INCREF(type);\n Py_DECREF(tmp);\n }\n if (PyString_Check(type))\n ;\n else if (PyClass_Check(type))\n ; /*PyErr_NormalizeException(&type, &value, &tb);*/\n else if (PyInstance_Check(type)) {\n /* Raising an instance. The value should be a dummy. */\n if (value != Py_None) {\n PyErr_SetString(PyExc_TypeError,\n \"instance exception may not have a separate value\");\n goto raise_error;\n }\n else {\n /* Normalize to raise , */\n Py_DECREF(value);\n value = type;\n type = (PyObject*) ((PyInstanceObject*)type)->in_class;\n Py_INCREF(type);\n }\n }\n else {\n /* Not something you can raise. You get an exception\n anyway, just not what you specified :-) */\n PyErr_Format(PyExc_TypeError,\n \"exceptions must be strings, classes, or \"\n \"instances, not %s\", type->ob_type->tp_name);\n goto raise_error;\n }\n PyErr_Restore(type, value, tb);\n return;\nraise_error:\n Py_XDECREF(value);\n Py_XDECREF(type);\n Py_XDECREF(tb);\n return;\n}\n\nstatic void __Pyx_UnpackError(void) {\n PyErr_SetString(PyExc_ValueError, \"unpack sequence of wrong size\");\n}\n\nstatic PyObject *__Pyx_UnpackItem(PyObject *seq, int i) {\n PyObject *item;\n if (!(item = PySequence_GetItem(seq, i))) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n \t__Pyx_UnpackError();\n }\n return item;\n}\n\nstatic int __Pyx_EndUnpack(PyObject *seq, int i) {\n PyObject *item;\n if (item = PySequence_GetItem(seq, i)) {\n Py_DECREF(item);\n __Pyx_UnpackError();\n return -1;\n }\n PyErr_Clear();\n return 0;\n}\n\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {\n while (t->p) {\n *t->p = PyString_InternFromString(t->s);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {\n while (t->p) {\n *t->p = PyString_FromStringAndSize(t->s, t->n - 1);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, \n long size) \n{\n PyObject *py_module_name = 0;\n PyObject *py_class_name = 0;\n PyObject *py_name_list = 0;\n PyObject *py_module = 0;\n PyObject *result = 0;\n \n py_module_name = PyString_FromString(module_name);\n if (!py_module_name)\n goto bad;\n py_class_name = PyString_FromString(class_name);\n if (!py_class_name)\n goto bad;\n py_name_list = PyList_New(1);\n if (!py_name_list)\n goto bad;\n Py_INCREF(py_class_name);\n if (PyList_SetItem(py_name_list, 0, py_class_name) < 0)\n goto bad;\n py_module = __Pyx_Import(py_module_name, py_name_list);\n if (!py_module)\n goto bad;\n result = PyObject_GetAttr(py_module, py_class_name);\n if (!result)\n goto bad;\n if (!PyType_Check(result)) {\n PyErr_Format(PyExc_TypeError, \n \"%s.%s is not a type object\",\n module_name, class_name);\n goto bad;\n }\n if (((PyTypeObject *)result)->tp_basicsize != size) {\n PyErr_Format(PyExc_ValueError, \n \"%s.%s does not appear to be the correct type object\",\n module_name, class_name);\n goto bad;\n }\n goto done;\nbad:\n Py_XDECREF(result);\n result = 0;\ndone:\n Py_XDECREF(py_module_name);\n Py_XDECREF(py_class_name);\n Py_XDECREF(py_name_list);\n return (PyTypeObject *)result;\n}\n\n#include \"compile.h\"\n#include \"frameobject.h\"\n#include \"traceback.h\"\n\nstatic void __Pyx_AddTraceback(char *funcname) {\n PyObject *py_srcfile = 0;\n PyObject *py_funcname = 0;\n PyObject *py_globals = 0;\n PyObject *empty_tuple = 0;\n PyObject *empty_string = 0;\n PyCodeObject *py_code = 0;\n PyFrameObject *py_frame = 0;\n \n py_srcfile = PyString_FromString(__pyx_filename);\n if (!py_srcfile) goto bad;\n py_funcname = PyString_FromString(funcname);\n if (!py_funcname) goto bad;\n py_globals = PyModule_GetDict(__pyx_m);\n if (!py_globals) goto bad;\n empty_tuple = PyTuple_New(0);\n if (!empty_tuple) goto bad;\n empty_string = PyString_FromString(\"\");\n if (!empty_string) goto bad;\n py_code = PyCode_New(\n 0, /*int argcount,*/\n 0, /*int nlocals,*/\n 0, /*int stacksize,*/\n 0, /*int flags,*/\n empty_string, /*PyObject *code,*/\n empty_tuple, /*PyObject *consts,*/\n empty_tuple, /*PyObject *names,*/\n empty_tuple, /*PyObject *varnames,*/\n empty_tuple, /*PyObject *freevars,*/\n empty_tuple, /*PyObject *cellvars,*/\n py_srcfile, /*PyObject *filename,*/\n py_funcname, /*PyObject *name,*/\n __pyx_lineno, /*int firstlineno,*/\n empty_string /*PyObject *lnotab*/\n );\n if (!py_code) goto bad;\n py_frame = PyFrame_New(\n PyThreadState_Get(), /*PyThreadState *tstate,*/\n py_code, /*PyCodeObject *code,*/\n py_globals, /*PyObject *globals,*/\n 0 /*PyObject *locals*/\n );\n if (!py_frame) goto bad;\n py_frame->f_lineno = __pyx_lineno;\n PyTraceBack_Here(py_frame);\nbad:\n Py_XDECREF(py_srcfile);\n Py_XDECREF(py_funcname);\n Py_XDECREF(empty_tuple);\n Py_XDECREF(empty_string);\n Py_XDECREF(py_code);\n Py_XDECREF(py_frame);\n}\n", "source_code_before": "/* Generated by Pyrex 0.9.3.1 on Wed Sep 28 22:52:52 2005 */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n#ifndef PY_LONG_LONG\n #define PY_LONG_LONG LONG_LONG\n#endif\n#include \"string.h\"\n#include \"math.h\"\n#include \"scipy/arrayobject.h\"\n#include \"randomkit.h\"\n#include \"distributions.h\"\n#include \"initarray.h\"\n\n\ntypedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/\ntypedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/\nstatic PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/\nstatic int __Pyx_EndUnpack(PyObject *, int); /*proto*/\nstatic int __Pyx_PrintItem(PyObject *); /*proto*/\nstatic int __Pyx_PrintNewline(void); /*proto*/\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/\nstatic void __Pyx_ReRaise(void); /*proto*/\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/\nstatic PyObject *__Pyx_GetExcValue(void); /*proto*/\nstatic int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/\nstatic int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/\nstatic int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/\nstatic void __Pyx_WriteUnraisable(char *name); /*proto*/\nstatic void __Pyx_AddTraceback(char *funcname); /*proto*/\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/\nstatic int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/\nstatic int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/\nstatic PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/\n\nstatic PyObject *__pyx_m;\nstatic PyObject *__pyx_b;\nstatic int __pyx_lineno;\nstatic char *__pyx_filename;\nstaticforward char **__pyx_f;\n\n/* Declarations from mtrand */\n\nstaticforward PyTypeObject __pyx_type_6mtrand_RandomState;\n\nstruct __pyx_obj_6mtrand_RandomState {\n PyObject_HEAD\n rk_state (*internal_state);\n};\n\nstatic PyTypeObject *__pyx_ptype_6mtrand_ArrayType = 0;\nstatic PyTypeObject *__pyx_ptype_6mtrand_RandomState = 0;\nstatic PyObject *__pyx_k2;\nstatic PyObject *__pyx_k3;\nstatic PyObject *__pyx_k4;\nstatic PyObject *__pyx_k5;\nstatic PyObject *__pyx_k6;\nstatic PyObject *__pyx_k7;\nstatic double __pyx_k8;\nstatic double __pyx_k9;\nstatic PyObject *__pyx_k10;\nstatic PyObject *__pyx_k11;\nstatic PyObject *__pyx_k12;\nstatic PyObject *__pyx_k13;\nstatic double __pyx_k14;\nstatic double __pyx_k15;\nstatic PyObject *__pyx_k16;\nstatic PyObject *__pyx_k17;\nstatic double __pyx_k18;\nstatic PyObject *__pyx_k19;\nstatic PyObject *__pyx_k20;\nstatic PyObject *__pyx_k21;\nstatic double __pyx_k22;\nstatic PyObject *__pyx_k23;\nstatic PyObject *__pyx_k24;\nstatic PyObject *__pyx_k25;\nstatic PyObject *__pyx_k26;\nstatic PyObject *__pyx_k27;\nstatic PyObject *__pyx_k28;\nstatic PyObject *__pyx_k29;\nstatic PyObject *__pyx_k30;\nstatic PyObject *__pyx_k31;\nstatic PyObject *__pyx_k32;\nstatic PyObject *__pyx_k33;\nstatic PyObject *__pyx_k34;\nstatic PyObject *__pyx_k35;\nstatic double __pyx_k36;\nstatic PyObject *__pyx_k37;\nstatic PyObject *__pyx_k38;\nstatic PyObject *__pyx_k39;\nstatic PyObject *(__pyx_f_6mtrand_cont0_array(rk_state (*),double ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont1_array(rk_state (*),double ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont2_array(rk_state (*),double ((*)(rk_state (*),double ,double )),PyObject *,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont3_array(rk_state (*),double ((*)(rk_state (*),double ,double ,double )),PyObject *,double ,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_disc0_array(rk_state (*),long ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discnp_array(rk_state (*),long ((*)(rk_state (*),long ,double )),PyObject *,long ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discd_array(rk_state (*),long ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic double (__pyx_f_6mtrand_kahan_sum(double (*),long )); /*proto*/\n\n/* Implementation of mtrand */\n\n\nstatic PyObject *__pyx_n_scipy;\nstatic PyObject *__pyx_n__rand;\nstatic PyObject *__pyx_n_get_state;\nstatic PyObject *__pyx_n_set_state;\nstatic PyObject *__pyx_n_random_sample;\nstatic PyObject *__pyx_n_randint;\nstatic PyObject *__pyx_n_bytes;\nstatic PyObject *__pyx_n_uniform;\nstatic PyObject *__pyx_n_rand;\nstatic PyObject *__pyx_n_randn;\nstatic PyObject *__pyx_n_random_integers;\nstatic PyObject *__pyx_n_standard_normal;\nstatic PyObject *__pyx_n_normal;\nstatic PyObject *__pyx_n_beta;\nstatic PyObject *__pyx_n_exponential;\nstatic PyObject *__pyx_n_standard_exponential;\nstatic PyObject *__pyx_n_standard_gamma;\nstatic PyObject *__pyx_n_gamma;\nstatic PyObject *__pyx_n_f;\nstatic PyObject *__pyx_n_noncentral_f;\nstatic PyObject *__pyx_n_chisquare;\nstatic PyObject *__pyx_n_noncentral_chisquare;\nstatic PyObject *__pyx_n_standard_cauchy;\nstatic PyObject *__pyx_n_standard_t;\nstatic PyObject *__pyx_n_vonmises;\nstatic PyObject *__pyx_n_pareto;\nstatic PyObject *__pyx_n_weibull;\nstatic PyObject *__pyx_n_power;\nstatic PyObject *__pyx_n_binomial;\nstatic PyObject *__pyx_n_negative_binomial;\nstatic PyObject *__pyx_n_poisson;\nstatic PyObject *__pyx_n_multivariate_normal;\nstatic PyObject *__pyx_n_multinomial;\nstatic PyObject *__pyx_n_shuffle;\nstatic PyObject *__pyx_n_permutation;\n\nstatic PyObject *__pyx_n_empty;\nstatic PyObject *__pyx_n_Float64;\n\nstatic PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":111 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":112 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":114 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":115 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":116 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":117 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":118 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":119 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":127 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":130 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":132 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":133 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":134 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":135 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont1_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":148 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":149 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":150 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":151 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":152 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont2_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b,double __pyx_v_c) {\n double (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":163 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":165 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":166 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":167 */\n __pyx_v_array_data = ((double (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":168 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":169 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":170 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont3_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_Int;\n\nstatic PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":178 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":181 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":183 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":184 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":185 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":186 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.disc0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,double )),PyObject *__pyx_v_size,long __pyx_v_n,double __pyx_v_p) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":194 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":197 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":199 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":200 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":201 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":202 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discnp_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":210 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":213 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":215 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":216 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":217 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n __pyx_L3:;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":218 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discd_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic double __pyx_f_6mtrand_kahan_sum(double (*__pyx_v_darr),long __pyx_v_n) {\n double __pyx_v_c;\n double __pyx_v_y;\n double __pyx_v_t;\n double __pyx_v_sum;\n long __pyx_v_i;\n double __pyx_r;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":223 */\n __pyx_v_sum = (__pyx_v_darr[0]);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":224 */\n __pyx_v_c = 0.0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":225 */\n for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":226 */\n __pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":227 */\n __pyx_v_t = (__pyx_v_sum + __pyx_v_y);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */\n __pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */\n __pyx_v_sum = __pyx_v_t;\n __pyx_L2:;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":230 */\n __pyx_r = __pyx_v_sum;\n goto __pyx_L0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __pyx_L1:;\n __Pyx_WriteUnraisable(\"mtrand.kahan_sum\");\n __pyx_L0:;\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_seed;\n\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n int __pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k2;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return -1;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":253 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state (*))PyMem_Malloc((sizeof(rk_state ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":255 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__init__\");\n __pyx_r = -1;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self); /*proto*/\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {\n int __pyx_1;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */\n __pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */\n PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n goto __pyx_L0;\n __pyx_L1:;\n __Pyx_AddTraceback(\"mtrand.RandomState.__dealloc__\");\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n}\n\nstatic PyObject *__pyx_n_type;\nstatic PyObject *__pyx_n_int;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_seed[] = \"Seed the generator.\\n\\n seed(seed=None)\\n\\n seed can be an integer, an array (or other sequence) of integers of any\\n length, or None. If seed is None, then RandomState will try to read data\\n from /dev/urandom (or the Windows analogue) if available or seed from\\n the clock otherwise.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n rk_error __pyx_v_errcode;\n PyArrayObject *__pyx_v_obj;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n unsigned long __pyx_5;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k3;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n __pyx_v_obj = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_obj);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":273 */\n __pyx_1 = __pyx_v_seed == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":274 */\n __pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_seed);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}\n __pyx_1 = __pyx_4 == __pyx_2;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":276 */\n __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}\n rk_seed(__pyx_5,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":278 */\n __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_obj));\n __pyx_v_obj = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":279 */\n init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long (*))__pyx_v_obj->data),(__pyx_v_obj->dimensions[0]));\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.seed\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_obj);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_MT19937;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_get_state[] = \"Return a tuple representing the internal state of the generator.\\n\\n get_state() -> (\\'MT19937\\', int key[624], int pos)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyArrayObject *__pyx_v_state;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n __pyx_v_state = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":288 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_1 = 0;\n __pyx_4 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_1));\n Py_DECREF(((PyObject *)__pyx_v_state));\n __pyx_v_state = ((PyObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":289 */\n memcpy(((void (*))__pyx_v_state->data),((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":290 */\n __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}\n Py_INCREF(__pyx_n_MT19937);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_MT19937);\n Py_INCREF(((PyObject *)__pyx_v_state));\n PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_state));\n PyTuple_SET_ITEM(__pyx_2, 2, __pyx_4);\n __pyx_4 = 0;\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.get_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_state);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_ValueError;\n\nstatic PyObject *__pyx_k42p;\nstatic PyObject *__pyx_k43p;\n\nstatic char (__pyx_k42[]) = \"algorithm must be 'MT19937'\";\nstatic char (__pyx_k43[]) = \"state must be 624 longs\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_set_state[] = \"Set the state from a tuple.\\n \\n state = (\\'MT19937\\', int key[624], int pos)\\n \\n set_state(state)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyArrayObject *__pyx_v_obj;\n int __pyx_v_pos;\n PyObject *__pyx_v_algorithm_name;\n PyObject *__pyx_v_key;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n int __pyx_3;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n __pyx_v_obj = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_obj);\n __pyx_v_algorithm_name = Py_None; Py_INCREF(__pyx_v_algorithm_name);\n __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":301 */\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_algorithm_name);\n __pyx_v_algorithm_name = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":302 */\n if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}\n __pyx_3 = __pyx_3 != 0;\n if (__pyx_3) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":303 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n Py_INCREF(__pyx_k42p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k42p);\n __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":304 */\n __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n Py_DECREF(__pyx_v_key);\n __pyx_v_key = __pyx_2;\n __pyx_2 = 0;\n __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_v_pos = __pyx_3;\n if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":305 */\n __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_obj));\n __pyx_v_obj = __pyx_4;\n __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":306 */\n __pyx_3 = ((__pyx_v_obj->dimensions[0]) != 624);\n if (__pyx_3) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n Py_INCREF(__pyx_k43p);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k43p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */\n memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,((void (*))__pyx_v_obj->data),(624 * (sizeof(long ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":309 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.set_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_obj);\n Py_DECREF(__pyx_v_algorithm_name);\n Py_DECREF(__pyx_v_key);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":313 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__getstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":316 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}\n Py_INCREF(__pyx_v_state);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__setstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_stats;\nstatic PyObject *__pyx_n___RandomState_ctor;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":319 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stats); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_5);\n __pyx_1 = 0;\n __pyx_2 = 0;\n __pyx_5 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.__reduce__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_sample[] = \"Return random floats in the half-open interval [0.0, 1.0).\\n\\n random_sample(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k4;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":327 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_sample\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_tomaxint[] = \"Returns random integers x such that 0 <= x <= sys.maxint.\\n\\n tomaxint(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k5;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":334 */\n __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.tomaxint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k44p;\n\nstatic char (__pyx_k44[]) = \"low >= high\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randint[] = \"Return random integers x such that low <= x < high.\\n\\n randint(low, high=None, size=None) -> random values\\n\\n If high is None, then 0 <= x < low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_lo;\n long __pyx_v_hi;\n long __pyx_v_diff;\n long (*__pyx_v_array_data);\n PyArrayObject *__pyx_v_array;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n long __pyx_2;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k6;\n __pyx_v_size = __pyx_k7;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":349 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":350 */\n __pyx_v_lo = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":351 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":353 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_v_lo = __pyx_2;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":354 */\n __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */\n __pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":357 */\n __pyx_1 = (__pyx_v_diff < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":358 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n Py_INCREF(__pyx_k44p);\n PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k44p);\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __Pyx_Raise(__pyx_5, 0, 0);\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":360 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":361 */\n __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;}\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n goto __pyx_L4;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */\n __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)__pyx_v_array));\n __pyx_v_array = ((PyObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":364 */\n __pyx_v_length = PyArray_SIZE(__pyx_v_array);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":365 */\n __pyx_v_array_data = ((long (*))__pyx_v_array->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":366 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":367 */\n (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state));\n __pyx_L5:;\n }\n __pyx_L6:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":368 */\n Py_INCREF(((PyObject *)__pyx_v_array));\n __pyx_r = ((PyObject *)__pyx_v_array);\n goto __pyx_L0;\n }\n __pyx_L4:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.randint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_array);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_bytes[] = \"Return random bytes.\\n\\n bytes(length) -> str\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n unsigned int __pyx_v_length;\n void (*__pyx_v_bytes);\n PyObject *__pyx_v_bytestring;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"length\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"i\", __pyx_argnames, &__pyx_v_length)) return 0;\n Py_INCREF(__pyx_v_self);\n __pyx_v_bytestring = Py_None; Py_INCREF(__pyx_v_bytestring);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":376 */\n __pyx_v_bytes = PyMem_Malloc(__pyx_v_length);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":377 */\n rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":378 */\n __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}\n Py_DECREF(__pyx_v_bytestring);\n __pyx_v_bytestring = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":379 */\n PyMem_Free(__pyx_v_bytes);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":380 */\n Py_INCREF(__pyx_v_bytestring);\n __pyx_r = __pyx_v_bytestring;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.bytes\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_bytestring);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_uniform[] = \"Uniform distribution over [low, high).\\n\\n uniform(low=0.0, high=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_low;\n double __pyx_v_high;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_low = __pyx_k8;\n __pyx_v_high = __pyx_k9;\n __pyx_v_size = __pyx_k10;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */\n __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.uniform\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_len;\nstatic PyObject *__pyx_n_size;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_rand[] = \"Return an array of the given dimensions which is initialized to \\n random numbers from a uniform distribution in the range [0,1).\\n\\n randn(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":396 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":399 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_r = __pyx_5;\n __pyx_5 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.rand\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randn[] = \"Returns zero-mean, unit-variance Gaussian random numbers in an \\n array of shape (d0, d1, ..., dn).\\n\\n randn(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":407 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":408 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":410 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_args);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.randn\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_integers[] = \"Return random integers x such that low <= x <= high.\\n\\n random_integers(low, high=None, size=None) -> random values.\\n\\n If high is None, then 1 <= x <= low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k11;\n __pyx_v_size = __pyx_k12;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":419 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":420 */\n Py_INCREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n __pyx_v_high = __pyx_v_low;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":421 */\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}\n Py_DECREF(__pyx_v_low);\n __pyx_v_low = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":422 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n Py_INCREF(__pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_size);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_4;\n __pyx_4 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_integers\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_normal[] = \"Standard Normal distribution (mean=0, stdev=1).\\n\\n standard_normal(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k13;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":430 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k46p;\n\nstatic char (__pyx_k46[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_normal[] = \"Normal distribution (mean=loc, stdev=scale).\\n\\n normal(loc=0.0, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k14;\n __pyx_v_scale = __pyx_k15;\n __pyx_v_size = __pyx_k16;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":437 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":438 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n Py_INCREF(__pyx_k46p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k46p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":439 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k47p;\nstatic PyObject *__pyx_k48p;\n\nstatic char (__pyx_k47[]) = \"a <= 0\";\nstatic char (__pyx_k48[]) = \"b <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_beta[] = \"Beta distribution over [0, 1].\\n\\n beta(a, b, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n double __pyx_v_b;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"b\",\"size\",0};\n __pyx_v_size = __pyx_k17;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":446 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":447 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n Py_INCREF(__pyx_k47p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k47p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_b <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":449 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n Py_INCREF(__pyx_k48p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":450 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.beta\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k49p;\n\nstatic char (__pyx_k49[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_exponential[] = \"Exponential distribution.\\n\\n exponential(scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k18;\n __pyx_v_size = __pyx_k19;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":457 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":458 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n Py_INCREF(__pyx_k49p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k49p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_exponential[] = \"Standard exponential distribution (scale=1).\\n\\n standard_exponential(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k20;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k50p;\n\nstatic char (__pyx_k50[]) = \"shape <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = \"Standard Gamma distribution.\\n\\n standard_gamma(shape, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"size\",0};\n __pyx_v_size = __pyx_k21;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":473 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":474 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n Py_INCREF(__pyx_k50p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k50p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k51p;\nstatic PyObject *__pyx_k52p;\n\nstatic char (__pyx_k51[]) = \"shape <= 0\";\nstatic char (__pyx_k52[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_gamma[] = \"Gamma distribution.\\n\\n gamma(shape, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k22;\n __pyx_v_size = __pyx_k23;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|dO\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":482 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":483 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n Py_INCREF(__pyx_k51p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k51p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":485 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n Py_INCREF(__pyx_k52p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k52p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k53p;\nstatic PyObject *__pyx_k54p;\n\nstatic char (__pyx_k53[]) = \"dfnum <= 0\";\nstatic char (__pyx_k54[]) = \"dfden <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_f[] = \"F distribution.\\n\\n f(dfnum, dfden, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"size\",0};\n __pyx_v_size = __pyx_k24;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":493 */\n __pyx_1 = (__pyx_v_dfnum <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":494 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n Py_INCREF(__pyx_k53p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k53p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":496 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n Py_INCREF(__pyx_k54p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k54p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":497 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k55p;\nstatic PyObject *__pyx_k56p;\nstatic PyObject *__pyx_k57p;\n\nstatic char (__pyx_k55[]) = \"dfnum <= 1\";\nstatic char (__pyx_k56[]) = \"dfden <= 0\";\nstatic char (__pyx_k57[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = \"Noncentral F distribution.\\n\\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k25;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":504 */\n __pyx_1 = (__pyx_v_dfnum <= 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":505 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n Py_INCREF(__pyx_k55p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k55p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":507 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n Py_INCREF(__pyx_k56p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k56p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":509 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n Py_INCREF(__pyx_k57p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k57p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":510 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k58p;\n\nstatic char (__pyx_k58[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_chisquare[] = \"Chi^2 distribution.\\n\\n chisquare(df, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k26;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":518 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":519 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n Py_INCREF(__pyx_k58p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k58p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":520 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k59p;\nstatic PyObject *__pyx_k60p;\n\nstatic char (__pyx_k59[]) = \"df <= 1\";\nstatic char (__pyx_k60[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = \"Noncentral Chi^2 distribution.\\n\\n noncentral_chisquare(df, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k27;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":527 */\n __pyx_1 = (__pyx_v_df <= 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n Py_INCREF(__pyx_k59p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k59p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":530 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n Py_INCREF(__pyx_k60p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k60p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":531 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_cauchy[] = \"Standard Cauchy with mode=0.\\n\\n standard_cauchy(size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k28;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_cauchy\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k61p;\n\nstatic char (__pyx_k61[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_t[] = \"Standard Student\\'s t distribution with df degrees of freedom.\\n\\n standard_t(df, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k29;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":546 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n Py_INCREF(__pyx_k61p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k61p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":548 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_t\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k62p;\n\nstatic char (__pyx_k62[]) = \"kappa < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_vonmises[] = \"von Mises circular distribution with mode mu and dispersion parameter\\n kappa on [-pi, pi].\\n\\n vonmises(mu, kappa, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mu;\n double __pyx_v_kappa;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mu\",\"kappa\",\"size\",0};\n __pyx_v_size = __pyx_k30;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mu, &__pyx_v_kappa, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */\n __pyx_1 = (__pyx_v_kappa < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":557 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n Py_INCREF(__pyx_k62p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k62p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":558 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.vonmises\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k63p;\n\nstatic char (__pyx_k63[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_pareto[] = \"Pareto distribution.\\n\\n pareto(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k31;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":565 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":566 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n Py_INCREF(__pyx_k63p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k63p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":567 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.pareto\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k64p;\n\nstatic char (__pyx_k64[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_weibull[] = \"Weibull distribution.\\n\\n weibull(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k32;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":574 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n Py_INCREF(__pyx_k64p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":576 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.weibull\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k65p;\n\nstatic char (__pyx_k65[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_power[] = \"Power distribution.\\n\\n power(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k33;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":583 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":584 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n Py_INCREF(__pyx_k65p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k65p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":585 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.power\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k66p;\nstatic PyObject *__pyx_k67p;\nstatic PyObject *__pyx_k68p;\n\nstatic char (__pyx_k66[]) = \"n <= 0\";\nstatic char (__pyx_k67[]) = \"p < 0\";\nstatic char (__pyx_k68[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k34;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":593 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n Py_INCREF(__pyx_k66p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":596 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n Py_INCREF(__pyx_k67p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":598 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n Py_INCREF(__pyx_k68p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":599 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k69p;\nstatic PyObject *__pyx_k70p;\nstatic PyObject *__pyx_k71p;\n\nstatic char (__pyx_k69[]) = \"n <= 0\";\nstatic char (__pyx_k70[]) = \"p < 0\";\nstatic char (__pyx_k71[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k35;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":606 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":607 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n Py_INCREF(__pyx_k69p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":609 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n Py_INCREF(__pyx_k70p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":611 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n Py_INCREF(__pyx_k71p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.negative_binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k72p;\n\nstatic char (__pyx_k72[]) = \"lam <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_poisson[] = \"Poisson distribution.\\n\\n poisson(lam=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_lam;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"lam\",\"size\",0};\n __pyx_v_lam = __pyx_k36;\n __pyx_v_size = __pyx_k37;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_lam, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":620 */\n __pyx_1 = (__pyx_v_lam <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n Py_INCREF(__pyx_k72p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":622 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.poisson\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_array;\nstatic PyObject *__pyx_n_shape;\nstatic PyObject *__pyx_n_ArgumentError;\nstatic PyObject *__pyx_n_isinstance;\nstatic PyObject *__pyx_n_list;\nstatic PyObject *__pyx_n_append;\nstatic PyObject *__pyx_n_multiply;\nstatic PyObject *__pyx_n_reduce;\nstatic PyObject *__pyx_n_linalg;\nstatic PyObject *__pyx_n_singular_value_decomposition;\nstatic PyObject *__pyx_n_matrixmultiply;\nstatic PyObject *__pyx_n_Numeric;\nstatic PyObject *__pyx_n_sqrt;\nstatic PyObject *__pyx_n_add;\nstatic PyObject *__pyx_n_tuple;\n\nstatic PyObject *__pyx_k73p;\nstatic PyObject *__pyx_k74p;\nstatic PyObject *__pyx_k75p;\n\nstatic char (__pyx_k73[]) = \"mean must be 1 dimensional\";\nstatic char (__pyx_k74[]) = \"cov must be 2 dimensional and square\";\nstatic char (__pyx_k75[]) = \"mean and cov must have same length\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = \"Return an array containing multivariate normally distributed random numbers\\n with specified mean and covariance.\\n\\n multivariate_normal(mean, cov) -> random values\\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\\n\\n mean must be a 1 dimensional array. cov must be a square two dimensional\\n array with the same number of rows and columns as mean has elements.\\n\\n The first form returns a single 1-D array containing a multivariate\\n normal.\\n\\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\\n normal.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_mean = 0;\n PyObject *__pyx_v_cov = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_final_shape;\n PyObject *__pyx_v_x;\n PyObject *__pyx_v_u;\n PyObject *__pyx_v_s;\n PyObject *__pyx_v_v;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"cov\",\"size\",0};\n __pyx_v_size = __pyx_k38;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"OO|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_cov, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_mean);\n Py_INCREF(__pyx_v_cov);\n Py_INCREF(__pyx_v_size);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_final_shape = Py_None; Py_INCREF(__pyx_v_final_shape);\n __pyx_v_x = Py_None; Py_INCREF(__pyx_v_x);\n __pyx_v_u = Py_None; Py_INCREF(__pyx_v_u);\n __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);\n __pyx_v_v = Py_None; Py_INCREF(__pyx_v_v);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":643 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_mean);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_mean);\n __pyx_v_mean = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":644 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cov);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_cov);\n __pyx_v_cov = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":645 */\n __pyx_4 = __pyx_v_size == Py_None;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":646 */\n __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":648 */\n Py_INCREF(__pyx_v_size);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_v_size;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":649 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":650 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n Py_INCREF(__pyx_k73p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k73p);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_3, 0, 0);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":651 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (!__pyx_4) {\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n }\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":652 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n Py_INCREF(__pyx_k74p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k74p);\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}\n goto __pyx_L4;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":653 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":654 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n Py_INCREF(__pyx_k75p);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k75p);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __Pyx_Raise(__pyx_2, 0, 0);\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}\n goto __pyx_L5;\n }\n __pyx_L5:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":656 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":657 */\n __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyList_SET_ITEM(__pyx_1, 0, __pyx_v_shape);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L6;\n }\n __pyx_L6:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":658 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);\n __pyx_5 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_final_shape);\n __pyx_v_final_shape = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":659 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":663 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);\n __pyx_3 = 0;\n __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_5;\n __pyx_5 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":664 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_final_shape);\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);\n PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);\n __pyx_3 = 0;\n __pyx_5 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":672 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_linalg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_singular_value_decomposition); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_cov);\n __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_v_u);\n __pyx_v_u = __pyx_3;\n __pyx_3 = 0;\n __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_v_s);\n __pyx_v_s = __pyx_5;\n __pyx_5 = 0;\n __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_v_v);\n __pyx_v_v = __pyx_1;\n __pyx_1 = 0;\n if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":673 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_Numeric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n Py_INCREF(__pyx_v_s);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n Py_INCREF(__pyx_v_v);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_v);\n __pyx_2 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":676 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_mean);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_x);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_x);\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":678 */\n Py_INCREF(__pyx_v_x);\n __pyx_r = __pyx_v_x;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.multivariate_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_final_shape);\n Py_DECREF(__pyx_v_x);\n Py_DECREF(__pyx_v_u);\n Py_DECREF(__pyx_v_s);\n Py_DECREF(__pyx_v_v);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_mean);\n Py_DECREF(__pyx_v_cov);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_zeros;\n\nstatic PyObject *__pyx_k76p;\n\nstatic char (__pyx_k76[]) = \"sum(pvals) > 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multinomial[] = \"Multinomial distribution.\\n \\n multinomial(n, pvals, size=None) -> random values\\n\\n pvals is a sequence of probabilities that should sum to 1 (however, the\\n last element is always assumed to account for the remaining probability\\n as long as sum(pvals[:-1]) <= 1).\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n PyObject *__pyx_v_pvals = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_d;\n PyArrayObject *__pyx_v_parr;\n PyArrayObject *__pyx_v_mnarr;\n double (*__pyx_v_pix);\n long (*__pyx_v_mnix);\n long __pyx_v_i;\n long __pyx_v_j;\n long __pyx_v_dn;\n double __pyx_v_Sum;\n double __pyx_v_prob;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_multin;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"n\",\"pvals\",\"size\",0};\n __pyx_v_size = __pyx_k39;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lO|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_pvals, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_pvals);\n Py_INCREF(__pyx_v_size);\n __pyx_v_parr = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_parr);\n __pyx_v_mnarr = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_mnarr);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_multin = Py_None; Py_INCREF(__pyx_v_multin);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":696 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n Py_INCREF(__pyx_v_pvals);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pvals);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_v_d = __pyx_4;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":697 */\n __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; goto __pyx_L1;}\n Py_DECREF(((PyObject *)__pyx_v_parr));\n __pyx_v_parr = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */\n __pyx_v_pix = ((double (*))__pyx_v_parr->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":700 */\n __pyx_5 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > 1.0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":701 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n Py_INCREF(__pyx_k76p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */\n __pyx_5 = __pyx_v_size == Py_None;\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}\n __pyx_5 = __pyx_3 == __pyx_1;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":708 */\n __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":710 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_multin);\n __pyx_v_multin = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */\n Py_INCREF(((PyObject *)__pyx_v_multin));\n Py_DECREF(((PyObject *)__pyx_v_mnarr));\n __pyx_v_mnarr = ((PyObject *)__pyx_v_multin);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":712 */\n __pyx_v_mnix = ((long (*))__pyx_v_mnarr->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":713 */\n __pyx_v_i = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":714 */\n while (1) {\n __pyx_L4:;\n __pyx_5 = (__pyx_v_i < PyArray_SIZE(__pyx_v_mnarr));\n if (!__pyx_5) break;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":715 */\n __pyx_v_Sum = 1.0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */\n __pyx_v_dn = __pyx_v_n;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */\n __pyx_4 = (__pyx_v_d - 1);\n for (__pyx_v_j = 0; __pyx_v_j < __pyx_4; ++__pyx_v_j) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":718 */\n (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":719 */\n __pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":720 */\n __pyx_5 = (__pyx_v_dn <= 0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":721 */\n goto __pyx_L7;\n goto __pyx_L8;\n }\n __pyx_L8:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":722 */\n __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j]));\n __pyx_L6:;\n }\n __pyx_L7:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":723 */\n __pyx_5 = (__pyx_v_dn > 0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":724 */\n (__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn;\n goto __pyx_L9;\n }\n __pyx_L9:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":726 */\n __pyx_v_i = (__pyx_v_i + __pyx_v_d);\n }\n __pyx_L5:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":728 */\n Py_INCREF(__pyx_v_multin);\n __pyx_r = __pyx_v_multin;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.multinomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_parr);\n Py_DECREF(__pyx_v_mnarr);\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_multin);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_pvals);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_shuffle[] = \"Modify a sequence in-place by shuffling its contents.\\n \\n shuffle(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n long __pyx_v_i;\n long __pyx_v_j;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":739 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_v_i = __pyx_4;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":740 */\n while (1) {\n __pyx_L2:;\n __pyx_5 = (__pyx_v_i > 0);\n if (!__pyx_5) break;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":741 */\n __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":742 */\n __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":743 */\n __pyx_v_i = (__pyx_v_i - 1);\n }\n __pyx_L3:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.shuffle\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_arange;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_permutation[] = \"Given an integer, return a shuffled sequence of integers >= 0 and \\n < x.\\n\\n permutation(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n PyObject *__pyx_v_arr;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":751 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_arange); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_arr);\n __pyx_v_arr = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":752 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n Py_INCREF(__pyx_v_arr);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_arr);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":753 */\n Py_INCREF(__pyx_v_arr);\n __pyx_r = __pyx_v_arr;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.permutation\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_arr);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_ArgumentError, \"ArgumentError\"},\n {&__pyx_n_Float64, \"Float64\"},\n {&__pyx_n_Int, \"Int\"},\n {&__pyx_n_MT19937, \"MT19937\"},\n {&__pyx_n_Numeric, \"scipy\"},\n {&__pyx_n_ValueError, \"ValueError\"},\n {&__pyx_n___RandomState_ctor, \"__RandomState_ctor\"},\n {&__pyx_n__rand, \"_rand\"},\n {&__pyx_n_add, \"add\"},\n {&__pyx_n_append, \"append\"},\n {&__pyx_n_arange, \"arange\"},\n {&__pyx_n_array, \"array\"},\n {&__pyx_n_beta, \"beta\"},\n {&__pyx_n_binomial, \"binomial\"},\n {&__pyx_n_bytes, \"bytes\"},\n {&__pyx_n_chisquare, \"chisquare\"},\n {&__pyx_n_empty, \"empty\"},\n {&__pyx_n_exponential, \"exponential\"},\n {&__pyx_n_f, \"f\"},\n {&__pyx_n_gamma, \"gamma\"},\n {&__pyx_n_get_state, \"get_state\"},\n {&__pyx_n_int, \"int\"},\n {&__pyx_n_isinstance, \"isinstance\"},\n {&__pyx_n_len, \"len\"},\n {&__pyx_n_linalg, \"linalg\"},\n {&__pyx_n_list, \"list\"},\n {&__pyx_n_matrixmultiply, \"matrixmultiply\"},\n {&__pyx_n_multinomial, \"multinomial\"},\n {&__pyx_n_multiply, \"multiply\"},\n {&__pyx_n_multivariate_normal, \"multivariate_normal\"},\n {&__pyx_n_negative_binomial, \"negative_binomial\"},\n {&__pyx_n_noncentral_chisquare, \"noncentral_chisquare\"},\n {&__pyx_n_noncentral_f, \"noncentral_f\"},\n {&__pyx_n_normal, \"normal\"},\n {&__pyx_n_pareto, \"pareto\"},\n {&__pyx_n_permutation, \"permutation\"},\n {&__pyx_n_poisson, \"poisson\"},\n {&__pyx_n_power, \"power\"},\n {&__pyx_n_rand, \"rand\"},\n {&__pyx_n_randint, \"randint\"},\n {&__pyx_n_randn, \"randn\"},\n {&__pyx_n_random_integers, \"random_integers\"},\n {&__pyx_n_random_sample, \"random_sample\"},\n {&__pyx_n_reduce, \"reduce\"},\n {&__pyx_n_scipy, \"scipy\"},\n {&__pyx_n_seed, \"seed\"},\n {&__pyx_n_set_state, \"set_state\"},\n {&__pyx_n_shape, \"shape\"},\n {&__pyx_n_shuffle, \"shuffle\"},\n {&__pyx_n_singular_value_decomposition, \"singular_value_decomposition\"},\n {&__pyx_n_size, \"size\"},\n {&__pyx_n_sqrt, \"sqrt\"},\n {&__pyx_n_standard_cauchy, \"standard_cauchy\"},\n {&__pyx_n_standard_exponential, \"standard_exponential\"},\n {&__pyx_n_standard_gamma, \"standard_gamma\"},\n {&__pyx_n_standard_normal, \"standard_normal\"},\n {&__pyx_n_standard_t, \"standard_t\"},\n {&__pyx_n_stats, \"stats\"},\n {&__pyx_n_tuple, \"tuple\"},\n {&__pyx_n_type, \"type\"},\n {&__pyx_n_uniform, \"uniform\"},\n {&__pyx_n_vonmises, \"vonmises\"},\n {&__pyx_n_weibull, \"weibull\"},\n {&__pyx_n_zeros, \"zeros\"},\n {0, 0}\n};\n\nstatic __Pyx_StringTabEntry __pyx_string_tab[] = {\n {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)},\n {&__pyx_k43p, __pyx_k43, sizeof(__pyx_k43)},\n {&__pyx_k44p, __pyx_k44, sizeof(__pyx_k44)},\n {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)},\n {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)},\n {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)},\n {&__pyx_k49p, __pyx_k49, sizeof(__pyx_k49)},\n {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)},\n {&__pyx_k51p, __pyx_k51, sizeof(__pyx_k51)},\n {&__pyx_k52p, __pyx_k52, sizeof(__pyx_k52)},\n {&__pyx_k53p, __pyx_k53, sizeof(__pyx_k53)},\n {&__pyx_k54p, __pyx_k54, sizeof(__pyx_k54)},\n {&__pyx_k55p, __pyx_k55, sizeof(__pyx_k55)},\n {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)},\n {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)},\n {&__pyx_k58p, __pyx_k58, sizeof(__pyx_k58)},\n {&__pyx_k59p, __pyx_k59, sizeof(__pyx_k59)},\n {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)},\n {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)},\n {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)},\n {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)},\n {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)},\n {&__pyx_k65p, __pyx_k65, sizeof(__pyx_k65)},\n {&__pyx_k66p, __pyx_k66, sizeof(__pyx_k66)},\n {&__pyx_k67p, __pyx_k67, sizeof(__pyx_k67)},\n {&__pyx_k68p, __pyx_k68, sizeof(__pyx_k68)},\n {&__pyx_k69p, __pyx_k69, sizeof(__pyx_k69)},\n {&__pyx_k70p, __pyx_k70, sizeof(__pyx_k70)},\n {&__pyx_k71p, __pyx_k71, sizeof(__pyx_k71)},\n {&__pyx_k72p, __pyx_k72, sizeof(__pyx_k72)},\n {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)},\n {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)},\n {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)},\n {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)},\n {0, 0, 0}\n};\n\nstatic PyObject *__pyx_tp_new_6mtrand_RandomState(PyTypeObject *t, PyObject *a, PyObject *k) {\n PyObject *o = (*t->tp_alloc)(t, 0);\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return o;\n}\n\nstatic void __pyx_tp_dealloc_6mtrand_RandomState(PyObject *o) {\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n {\n PyObject *etype, *eval, *etb;\n PyErr_Fetch(&etype, &eval, &etb);\n ++o->ob_refcnt;\n __pyx_f_6mtrand_11RandomState___dealloc__(o);\n if (PyErr_Occurred()) PyErr_WriteUnraisable(o);\n --o->ob_refcnt;\n PyErr_Restore(etype, eval, etb);\n }\n (*o->ob_type->tp_free)(o);\n}\n\nstatic int __pyx_tp_traverse_6mtrand_RandomState(PyObject *o, visitproc v, void *a) {\n int e;\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return 0;\n}\n\nstatic int __pyx_tp_clear_6mtrand_RandomState(PyObject *o) {\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return 0;\n}\n\nstatic struct PyMethodDef __pyx_methods_6mtrand_RandomState[] = {\n {\"seed\", (PyCFunction)__pyx_f_6mtrand_11RandomState_seed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_seed},\n {\"get_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_get_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_get_state},\n {\"set_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_set_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_set_state},\n {\"__getstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___getstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__setstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___setstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__reduce__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___reduce__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"random_sample\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_sample},\n {\"tomaxint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_tomaxint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_tomaxint},\n {\"randint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randint},\n {\"bytes\", (PyCFunction)__pyx_f_6mtrand_11RandomState_bytes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_bytes},\n {\"uniform\", (PyCFunction)__pyx_f_6mtrand_11RandomState_uniform, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_uniform},\n {\"rand\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rand, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rand},\n {\"randn\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randn, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randn},\n {\"random_integers\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_integers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_integers},\n {\"standard_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_normal},\n {\"normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_normal},\n {\"beta\", (PyCFunction)__pyx_f_6mtrand_11RandomState_beta, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_beta},\n {\"exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_exponential},\n {\"standard_exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_exponential},\n {\"standard_gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_gamma},\n {\"gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gamma},\n {\"f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_f},\n {\"noncentral_f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_f},\n {\"chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_chisquare},\n {\"noncentral_chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_chisquare},\n {\"standard_cauchy\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_cauchy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_cauchy},\n {\"standard_t\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_t, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_t},\n {\"vonmises\", (PyCFunction)__pyx_f_6mtrand_11RandomState_vonmises, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_vonmises},\n {\"pareto\", (PyCFunction)__pyx_f_6mtrand_11RandomState_pareto, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_pareto},\n {\"weibull\", (PyCFunction)__pyx_f_6mtrand_11RandomState_weibull, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_weibull},\n {\"power\", (PyCFunction)__pyx_f_6mtrand_11RandomState_power, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_power},\n {\"binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_binomial},\n {\"negative_binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_negative_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_negative_binomial},\n {\"poisson\", (PyCFunction)__pyx_f_6mtrand_11RandomState_poisson, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_poisson},\n {\"multivariate_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multivariate_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multivariate_normal},\n {\"multinomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multinomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multinomial},\n {\"shuffle\", (PyCFunction)__pyx_f_6mtrand_11RandomState_shuffle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_shuffle},\n {\"permutation\", (PyCFunction)__pyx_f_6mtrand_11RandomState_permutation, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_permutation},\n {0, 0, 0, 0}\n};\n\nstatic PyNumberMethods __pyx_tp_as_number_RandomState = {\n 0, /*nb_add*/\n 0, /*nb_subtract*/\n 0, /*nb_multiply*/\n 0, /*nb_divide*/\n 0, /*nb_remainder*/\n 0, /*nb_divmod*/\n 0, /*nb_power*/\n 0, /*nb_negative*/\n 0, /*nb_positive*/\n 0, /*nb_absolute*/\n 0, /*nb_nonzero*/\n 0, /*nb_invert*/\n 0, /*nb_lshift*/\n 0, /*nb_rshift*/\n 0, /*nb_and*/\n 0, /*nb_xor*/\n 0, /*nb_or*/\n 0, /*nb_coerce*/\n 0, /*nb_int*/\n 0, /*nb_long*/\n 0, /*nb_float*/\n 0, /*nb_oct*/\n 0, /*nb_hex*/\n 0, /*nb_inplace_add*/\n 0, /*nb_inplace_subtract*/\n 0, /*nb_inplace_multiply*/\n 0, /*nb_inplace_divide*/\n 0, /*nb_inplace_remainder*/\n 0, /*nb_inplace_power*/\n 0, /*nb_inplace_lshift*/\n 0, /*nb_inplace_rshift*/\n 0, /*nb_inplace_and*/\n 0, /*nb_inplace_xor*/\n 0, /*nb_inplace_or*/\n 0, /*nb_floor_divide*/\n 0, /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n};\n\nstatic PySequenceMethods __pyx_tp_as_sequence_RandomState = {\n 0, /*sq_length*/\n 0, /*sq_concat*/\n 0, /*sq_repeat*/\n 0, /*sq_item*/\n 0, /*sq_slice*/\n 0, /*sq_ass_item*/\n 0, /*sq_ass_slice*/\n 0, /*sq_contains*/\n 0, /*sq_inplace_concat*/\n 0, /*sq_inplace_repeat*/\n};\n\nstatic PyMappingMethods __pyx_tp_as_mapping_RandomState = {\n 0, /*mp_length*/\n 0, /*mp_subscript*/\n 0, /*mp_ass_subscript*/\n};\n\nstatic PyBufferProcs __pyx_tp_as_buffer_RandomState = {\n 0, /*bf_getreadbuffer*/\n 0, /*bf_getwritebuffer*/\n 0, /*bf_getsegcount*/\n 0, /*bf_getcharbuffer*/\n};\n\nstatichere PyTypeObject __pyx_type_6mtrand_RandomState = {\n PyObject_HEAD_INIT(0)\n 0, /*ob_size*/\n \"mtrand.RandomState\", /*tp_name*/\n sizeof(struct __pyx_obj_6mtrand_RandomState), /*tp_basicsize*/\n 0, /*tp_itemsize*/\n __pyx_tp_dealloc_6mtrand_RandomState, /*tp_dealloc*/\n 0, /*tp_print*/\n 0, /*tp_getattr*/\n 0, /*tp_setattr*/\n 0, /*tp_compare*/\n 0, /*tp_repr*/\n &__pyx_tp_as_number_RandomState, /*tp_as_number*/\n &__pyx_tp_as_sequence_RandomState, /*tp_as_sequence*/\n &__pyx_tp_as_mapping_RandomState, /*tp_as_mapping*/\n 0, /*tp_hash*/\n 0, /*tp_call*/\n 0, /*tp_str*/\n 0, /*tp_getattro*/\n 0, /*tp_setattro*/\n &__pyx_tp_as_buffer_RandomState, /*tp_as_buffer*/\n Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/\n \"Container for the Mersenne Twister PRNG.\\n\\n Constructor\\n -----------\\n RandomState(seed=None): initializes the PRNG with the given seed. See the\\n seed() method for details.\\n\\n Distribution Methods\\n -----------------\\n RandomState exposes a number of methods for generating random numbers drawn\\n from a variety of probability distributions. In addition to the\\n distribution-specific arguments, each method takes a keyword argument\\n size=None. If size is None, then a single value is generated and returned.\\n If size is an integer, then a 1-D scipy array filled with generated values\\n is returned. If size is a tuple, then a scipy array with that shape is\\n filled and returned.\\n \", /*tp_doc*/\n __pyx_tp_traverse_6mtrand_RandomState, /*tp_traverse*/\n __pyx_tp_clear_6mtrand_RandomState, /*tp_clear*/\n 0, /*tp_richcompare*/\n 0, /*tp_weaklistoffset*/\n 0, /*tp_iter*/\n 0, /*tp_iternext*/\n __pyx_methods_6mtrand_RandomState, /*tp_methods*/\n 0, /*tp_members*/\n 0, /*tp_getset*/\n 0, /*tp_base*/\n 0, /*tp_dict*/\n 0, /*tp_descr_get*/\n 0, /*tp_descr_set*/\n 0, /*tp_dictoffset*/\n __pyx_f_6mtrand_11RandomState___init__, /*tp_init*/\n 0, /*tp_alloc*/\n __pyx_tp_new_6mtrand_RandomState, /*tp_new*/\n 0, /*tp_free*/\n 0, /*tp_is_gc*/\n 0, /*tp_bases*/\n 0, /*tp_mro*/\n 0, /*tp_cache*/\n 0, /*tp_subclasses*/\n 0, /*tp_weaklist*/\n};\n\nstatic struct PyMethodDef __pyx_methods[] = {\n {0, 0, 0, 0}\n};\n\nDL_EXPORT(void) initmtrand(void); /*proto*/\nDL_EXPORT(void) initmtrand(void) {\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n __pyx_m = Py_InitModule4(\"mtrand\", __pyx_methods, 0, 0, PYTHON_API_VERSION);\n if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_b = PyImport_AddModule(\"__builtin__\");\n if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (PyObject_SetAttrString(__pyx_m, \"__builtins__\", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_ptype_6mtrand_ArrayType = __Pyx_ImportType(\"scipy\", \"ArrayType\", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ArrayType) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L1;}\n if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}\n if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}\n __pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":101 */\n import_array();\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":103 */\n __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;}\n if (PyObject_SetAttr(__pyx_m, __pyx_n_scipy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */\n Py_INCREF(Py_None);\n __pyx_k2 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":261 */\n Py_INCREF(Py_None);\n __pyx_k3 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":322 */\n Py_INCREF(Py_None);\n __pyx_k4 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":329 */\n Py_INCREF(Py_None);\n __pyx_k5 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */\n Py_INCREF(Py_None);\n __pyx_k6 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k7 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":382 */\n __pyx_k8 = 0.0;\n __pyx_k9 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k10 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":412 */\n Py_INCREF(Py_None);\n __pyx_k11 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k12 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":425 */\n Py_INCREF(Py_None);\n __pyx_k13 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":432 */\n __pyx_k14 = 0.0;\n __pyx_k15 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k16 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */\n Py_INCREF(Py_None);\n __pyx_k17 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":452 */\n __pyx_k18 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k19 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":461 */\n Py_INCREF(Py_None);\n __pyx_k20 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":468 */\n Py_INCREF(Py_None);\n __pyx_k21 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":477 */\n __pyx_k22 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k23 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":488 */\n Py_INCREF(Py_None);\n __pyx_k24 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":499 */\n Py_INCREF(Py_None);\n __pyx_k25 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":513 */\n Py_INCREF(Py_None);\n __pyx_k26 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */\n Py_INCREF(Py_None);\n __pyx_k27 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":534 */\n Py_INCREF(Py_None);\n __pyx_k28 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":541 */\n Py_INCREF(Py_None);\n __pyx_k29 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":550 */\n Py_INCREF(Py_None);\n __pyx_k30 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":560 */\n Py_INCREF(Py_None);\n __pyx_k31 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":569 */\n Py_INCREF(Py_None);\n __pyx_k32 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":578 */\n Py_INCREF(Py_None);\n __pyx_k33 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":588 */\n Py_INCREF(Py_None);\n __pyx_k34 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":601 */\n Py_INCREF(Py_None);\n __pyx_k35 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":615 */\n __pyx_k36 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k37 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":625 */\n Py_INCREF(Py_None);\n __pyx_k38 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":680 */\n Py_INCREF(Py_None);\n __pyx_k39 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":756 */\n __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}\n __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":757 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":758 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":759 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":760 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":761 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":762 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":763 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":764 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":766 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":767 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":769 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":770 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":771 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":773 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":774 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":775 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":776 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":777 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":778 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":779 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":780 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":781 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":782 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":783 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":784 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":785 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":786 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":787 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":788 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":789 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n return;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n __Pyx_AddTraceback(\"mtrand\");\n}\n\nstatic char *__pyx_filenames[] = {\n \"mtrand.pyx\",\n \"scipy.pxi\",\n};\nstatichere char **__pyx_f = __pyx_filenames;\n\n/* Runtime support code */\n\nstatic int __Pyx_GetStarArgs(\n PyObject **args, \n PyObject **kwds,\n char *kwd_list[], \n int nargs,\n PyObject **args2, \n PyObject **kwds2)\n{\n PyObject *x = 0, *args1 = 0, *kwds1 = 0;\n \n if (args2)\n *args2 = 0;\n if (kwds2)\n *kwds2 = 0;\n \n if (args2) {\n args1 = PyTuple_GetSlice(*args, 0, nargs);\n if (!args1)\n goto bad;\n *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args));\n if (!*args2)\n goto bad;\n }\n else {\n args1 = *args;\n Py_INCREF(args1);\n }\n \n if (kwds2) {\n if (*kwds) {\n char **p;\n kwds1 = PyDict_New();\n if (!kwds)\n goto bad;\n *kwds2 = PyDict_Copy(*kwds);\n if (!*kwds2)\n goto bad;\n for (p = kwd_list; *p; p++) {\n x = PyDict_GetItemString(*kwds, *p);\n if (x) {\n if (PyDict_SetItemString(kwds1, *p, x) < 0)\n goto bad;\n if (PyDict_DelItemString(*kwds2, *p) < 0)\n goto bad;\n }\n }\n }\n else {\n *kwds2 = PyDict_New();\n if (!*kwds2)\n goto bad;\n }\n }\n else {\n kwds1 = *kwds;\n Py_XINCREF(kwds1);\n }\n \n *args = args1;\n *kwds = kwds1;\n return 0;\nbad:\n Py_XDECREF(args1);\n Py_XDECREF(kwds1);\n if (*args2)\n Py_XDECREF(*args2);\n if (*kwds2)\n Py_XDECREF(*kwds2);\n return -1;\n}\n\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {\n PyObject *__import__ = 0;\n PyObject *empty_list = 0;\n PyObject *module = 0;\n PyObject *global_dict = 0;\n PyObject *empty_dict = 0;\n PyObject *list;\n __import__ = PyObject_GetAttrString(__pyx_b, \"__import__\");\n if (!__import__)\n goto bad;\n if (from_list)\n list = from_list;\n else {\n empty_list = PyList_New(0);\n if (!empty_list)\n goto bad;\n list = empty_list;\n }\n global_dict = PyModule_GetDict(__pyx_m);\n if (!global_dict)\n goto bad;\n empty_dict = PyDict_New();\n if (!empty_dict)\n goto bad;\n module = PyObject_CallFunction(__import__, \"OOOO\",\n name, global_dict, empty_dict, list);\nbad:\n Py_XDECREF(empty_list);\n Py_XDECREF(__import__);\n Py_XDECREF(empty_dict);\n return module;\n}\n\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {\n PyObject *result;\n result = PyObject_GetAttr(dict, name);\n if (!result)\n PyErr_SetObject(PyExc_NameError, name);\n return result;\n}\n\nstatic void __Pyx_WriteUnraisable(char *name) {\n PyObject *old_exc, *old_val, *old_tb;\n PyObject *ctx;\n PyErr_Fetch(&old_exc, &old_val, &old_tb);\n ctx = PyString_FromString(name);\n PyErr_Restore(old_exc, old_val, old_tb);\n if (!ctx)\n ctx = Py_None;\n PyErr_WriteUnraisable(ctx);\n}\n\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {\n Py_XINCREF(type);\n Py_XINCREF(value);\n Py_XINCREF(tb);\n /* First, check the traceback argument, replacing None with NULL. */\n if (tb == Py_None) {\n Py_DECREF(tb);\n tb = 0;\n }\n else if (tb != NULL && !PyTraceBack_Check(tb)) {\n PyErr_SetString(PyExc_TypeError,\n \"raise: arg 3 must be a traceback or None\");\n goto raise_error;\n }\n /* Next, replace a missing value with None */\n if (value == NULL) {\n value = Py_None;\n Py_INCREF(value);\n }\n /* Next, repeatedly, replace a tuple exception with its first item */\n while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {\n PyObject *tmp = type;\n type = PyTuple_GET_ITEM(type, 0);\n Py_INCREF(type);\n Py_DECREF(tmp);\n }\n if (PyString_Check(type))\n ;\n else if (PyClass_Check(type))\n ; /*PyErr_NormalizeException(&type, &value, &tb);*/\n else if (PyInstance_Check(type)) {\n /* Raising an instance. The value should be a dummy. */\n if (value != Py_None) {\n PyErr_SetString(PyExc_TypeError,\n \"instance exception may not have a separate value\");\n goto raise_error;\n }\n else {\n /* Normalize to raise , */\n Py_DECREF(value);\n value = type;\n type = (PyObject*) ((PyInstanceObject*)type)->in_class;\n Py_INCREF(type);\n }\n }\n else {\n /* Not something you can raise. You get an exception\n anyway, just not what you specified :-) */\n PyErr_Format(PyExc_TypeError,\n \"exceptions must be strings, classes, or \"\n \"instances, not %s\", type->ob_type->tp_name);\n goto raise_error;\n }\n PyErr_Restore(type, value, tb);\n return;\nraise_error:\n Py_XDECREF(value);\n Py_XDECREF(type);\n Py_XDECREF(tb);\n return;\n}\n\nstatic void __Pyx_UnpackError(void) {\n PyErr_SetString(PyExc_ValueError, \"unpack sequence of wrong size\");\n}\n\nstatic PyObject *__Pyx_UnpackItem(PyObject *seq, int i) {\n PyObject *item;\n if (!(item = PySequence_GetItem(seq, i))) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n \t__Pyx_UnpackError();\n }\n return item;\n}\n\nstatic int __Pyx_EndUnpack(PyObject *seq, int i) {\n PyObject *item;\n if (item = PySequence_GetItem(seq, i)) {\n Py_DECREF(item);\n __Pyx_UnpackError();\n return -1;\n }\n PyErr_Clear();\n return 0;\n}\n\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {\n while (t->p) {\n *t->p = PyString_InternFromString(t->s);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {\n while (t->p) {\n *t->p = PyString_FromStringAndSize(t->s, t->n - 1);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, \n long size) \n{\n PyObject *py_module_name = 0;\n PyObject *py_class_name = 0;\n PyObject *py_name_list = 0;\n PyObject *py_module = 0;\n PyObject *result = 0;\n \n py_module_name = PyString_FromString(module_name);\n if (!py_module_name)\n goto bad;\n py_class_name = PyString_FromString(class_name);\n if (!py_class_name)\n goto bad;\n py_name_list = PyList_New(1);\n if (!py_name_list)\n goto bad;\n Py_INCREF(py_class_name);\n if (PyList_SetItem(py_name_list, 0, py_class_name) < 0)\n goto bad;\n py_module = __Pyx_Import(py_module_name, py_name_list);\n if (!py_module)\n goto bad;\n result = PyObject_GetAttr(py_module, py_class_name);\n if (!result)\n goto bad;\n if (!PyType_Check(result)) {\n PyErr_Format(PyExc_TypeError, \n \"%s.%s is not a type object\",\n module_name, class_name);\n goto bad;\n }\n if (((PyTypeObject *)result)->tp_basicsize != size) {\n PyErr_Format(PyExc_ValueError, \n \"%s.%s does not appear to be the correct type object\",\n module_name, class_name);\n goto bad;\n }\n goto done;\nbad:\n Py_XDECREF(result);\n result = 0;\ndone:\n Py_XDECREF(py_module_name);\n Py_XDECREF(py_class_name);\n Py_XDECREF(py_name_list);\n return (PyTypeObject *)result;\n}\n\n#include \"compile.h\"\n#include \"frameobject.h\"\n#include \"traceback.h\"\n\nstatic void __Pyx_AddTraceback(char *funcname) {\n PyObject *py_srcfile = 0;\n PyObject *py_funcname = 0;\n PyObject *py_globals = 0;\n PyObject *empty_tuple = 0;\n PyObject *empty_string = 0;\n PyCodeObject *py_code = 0;\n PyFrameObject *py_frame = 0;\n \n py_srcfile = PyString_FromString(__pyx_filename);\n if (!py_srcfile) goto bad;\n py_funcname = PyString_FromString(funcname);\n if (!py_funcname) goto bad;\n py_globals = PyModule_GetDict(__pyx_m);\n if (!py_globals) goto bad;\n empty_tuple = PyTuple_New(0);\n if (!empty_tuple) goto bad;\n empty_string = PyString_FromString(\"\");\n if (!empty_string) goto bad;\n py_code = PyCode_New(\n 0, /*int argcount,*/\n 0, /*int nlocals,*/\n 0, /*int stacksize,*/\n 0, /*int flags,*/\n empty_string, /*PyObject *code,*/\n empty_tuple, /*PyObject *consts,*/\n empty_tuple, /*PyObject *names,*/\n empty_tuple, /*PyObject *varnames,*/\n empty_tuple, /*PyObject *freevars,*/\n empty_tuple, /*PyObject *cellvars,*/\n py_srcfile, /*PyObject *filename,*/\n py_funcname, /*PyObject *name,*/\n __pyx_lineno, /*int firstlineno,*/\n empty_string /*PyObject *lnotab*/\n );\n if (!py_code) goto bad;\n py_frame = PyFrame_New(\n PyThreadState_Get(), /*PyThreadState *tstate,*/\n py_code, /*PyCodeObject *code,*/\n py_globals, /*PyObject *globals,*/\n 0 /*PyObject *locals*/\n );\n if (!py_frame) goto bad;\n py_frame->f_lineno = __pyx_lineno;\n PyTraceBack_Here(py_frame);\nbad:\n Py_XDECREF(py_srcfile);\n Py_XDECREF(py_funcname);\n Py_XDECREF(empty_tuple);\n Py_XDECREF(empty_string);\n Py_XDECREF(py_code);\n Py_XDECREF(py_frame);\n}\n", "methods": [ { "name": "__pyx_f_6mtrand_cont0_array", "long_name": "__pyx_f_6mtrand_cont0_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 568, "parameters": [ "rk_state", "double", "__pyx_v_size" ], "start_line": 175, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont1_array", "long_name": "__pyx_f_6mtrand_cont1_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 577, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a" ], "start_line": 257, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont2_array", "long_name": "__pyx_f_6mtrand_cont2_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 586, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a", "__pyx_v_b" ], "start_line": 339, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont3_array", "long_name": "__pyx_f_6mtrand_cont3_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b , double __pyx_v_c)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 595, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a", "__pyx_v_b", "__pyx_v_c" ], "start_line": 421, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_disc0_array", "long_name": "__pyx_f_6mtrand_disc0_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 568, "parameters": [ "rk_state", "long", "__pyx_v_size" ], "start_line": 505, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discnp_array", "long_name": "__pyx_f_6mtrand_discnp_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,double)) , PyObject * __pyx_v_size , long __pyx_v_n , double __pyx_v_p)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 586, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_n", "__pyx_v_p" ], "start_line": 587, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discnmN_array", "long_name": "__pyx_f_6mtrand_discnmN_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,long,long)) , PyObject * __pyx_v_size , long __pyx_v_n , long __pyx_v_m , long __pyx_v_N)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 595, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_n", "__pyx_v_m", "__pyx_v_N" ], "start_line": 669, "end_line": 749, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discd_array", "long_name": "__pyx_f_6mtrand_discd_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 577, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_a" ], "start_line": 751, "end_line": 831, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_kahan_sum", "long_name": "__pyx_f_6mtrand_kahan_sum( double(*__pyx_v_darr) , long __pyx_v_n)", "filename": "mtrand.c", "nloc": 26, "complexity": 2, "token_count": 130, "parameters": [ "double", "__pyx_v_n" ], "start_line": 833, "end_line": 875, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___init__", "long_name": "__pyx_f_6mtrand_11RandomState___init__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 33, "complexity": 5, "token_count": 300, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 880, "end_line": 917, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___dealloc__", "long_name": "__pyx_f_6mtrand_11RandomState___dealloc__( PyObject * __pyx_v_self)", "filename": "mtrand.c", "nloc": 15, "complexity": 2, "token_count": 78, "parameters": [ "__pyx_v_self" ], "start_line": 920, "end_line": 939, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_seed", "long_name": "__pyx_f_6mtrand_11RandomState_seed( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 59, "complexity": 10, "token_count": 541, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 946, "end_line": 1015, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_get_state", "long_name": "__pyx_f_6mtrand_11RandomState_get_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 56, "complexity": 11, "token_count": 637, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1022, "end_line": 1084, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_set_state", "long_name": "__pyx_f_6mtrand_11RandomState_set_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 88, "complexity": 19, "token_count": 969, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1096, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___getstate__", "long_name": "__pyx_f_6mtrand_11RandomState___getstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 28, "complexity": 5, "token_count": 238, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1205, "end_line": 1235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___setstate__", "long_name": "__pyx_f_6mtrand_11RandomState___setstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 31, "complexity": 5, "token_count": 271, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1238, "end_line": 1271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___reduce__", "long_name": "__pyx_f_6mtrand_11RandomState___reduce__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 10, "token_count": 463, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1277, "end_line": 1324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_random_sample", "long_name": "__pyx_f_6mtrand_11RandomState_random_sample( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1328, "end_line": 1354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_tomaxint", "long_name": "__pyx_f_6mtrand_11RandomState_tomaxint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1358, "end_line": 1384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_randint", "long_name": "__pyx_f_6mtrand_11RandomState_randint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 111, "complexity": 19, "token_count": 1002, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1392, "end_line": 1535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 144, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_bytes", "long_name": "__pyx_f_6mtrand_11RandomState_bytes( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 31, "complexity": 3, "token_count": 223, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1539, "end_line": 1580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_uniform", "long_name": "__pyx_f_6mtrand_11RandomState_uniform( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 28, "complexity": 3, "token_count": 208, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1584, "end_line": 1614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_rand", "long_name": "__pyx_f_6mtrand_11RandomState_rand( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 70, "complexity": 17, "token_count": 715, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1622, "end_line": 1698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_randn", "long_name": "__pyx_f_6mtrand_11RandomState_randn( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 67, "complexity": 15, "token_count": 651, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1702, "end_line": 1775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 74, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_random_integers", "long_name": "__pyx_f_6mtrand_11RandomState_random_integers( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 61, "complexity": 9, "token_count": 493, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1779, "end_line": 1848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_normal", "long_name": "__pyx_f_6mtrand_11RandomState_standard_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1852, "end_line": 1878, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_normal", "long_name": "__pyx_f_6mtrand_11RandomState_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1886, "end_line": 1940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_beta", "long_name": "__pyx_f_6mtrand_11RandomState_beta( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1950, "end_line": 2018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_exponential", "long_name": "__pyx_f_6mtrand_11RandomState_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 389, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2026, "end_line": 2078, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_exponential", "long_name": "__pyx_f_6mtrand_11RandomState_standard_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2082, "end_line": 2108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_gamma", "long_name": "__pyx_f_6mtrand_11RandomState_standard_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2116, "end_line": 2167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_gamma", "long_name": "__pyx_f_6mtrand_11RandomState_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 61, "complexity": 11, "token_count": 570, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2177, "end_line": 2246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_f", "long_name": "__pyx_f_6mtrand_11RandomState_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2256, "end_line": 2324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_noncentral_f", "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 75, "complexity": 15, "token_count": 747, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2336, "end_line": 2421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 86, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_chisquare", "long_name": "__pyx_f_6mtrand_11RandomState_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2429, "end_line": 2480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare", "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2490, "end_line": 2558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_cauchy", "long_name": "__pyx_f_6mtrand_11RandomState_standard_cauchy( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2562, "end_line": 2588, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_t", "long_name": "__pyx_f_6mtrand_11RandomState_standard_t( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2596, "end_line": 2647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_vonmises", "long_name": "__pyx_f_6mtrand_11RandomState_vonmises( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 395, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2655, "end_line": 2707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_pareto", "long_name": "__pyx_f_6mtrand_11RandomState_pareto( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2715, "end_line": 2766, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_weibull", "long_name": "__pyx_f_6mtrand_11RandomState_weibull( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2774, "end_line": 2825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_power", "long_name": "__pyx_f_6mtrand_11RandomState_power( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2833, "end_line": 2884, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_laplace", "long_name": "__pyx_f_6mtrand_11RandomState_laplace( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2892, "end_line": 2946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_gumbel", "long_name": "__pyx_f_6mtrand_11RandomState_gumbel( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2954, "end_line": 3008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_logistic", "long_name": "__pyx_f_6mtrand_11RandomState_logistic( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3016, "end_line": 3070, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_lognormal", "long_name": "__pyx_f_6mtrand_11RandomState_lognormal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3078, "end_line": 3132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_rayleigh", "long_name": "__pyx_f_6mtrand_11RandomState_rayleigh( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3140, "end_line": 3191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_wald", "long_name": "__pyx_f_6mtrand_11RandomState_wald( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3201, "end_line": 3269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_triangular", "long_name": "__pyx_f_6mtrand_11RandomState_triangular( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 75, "complexity": 15, "token_count": 747, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3281, "end_line": 3366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 86, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_binomial", "long_name": "__pyx_f_6mtrand_11RandomState_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 74, "complexity": 15, "token_count": 737, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3378, "end_line": 3462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_negative_binomial", "long_name": "__pyx_f_6mtrand_11RandomState_negative_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 74, "complexity": 15, "token_count": 737, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3474, "end_line": 3558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_poisson", "long_name": "__pyx_f_6mtrand_11RandomState_poisson( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 389, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3566, "end_line": 3618, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_zipf", "long_name": "__pyx_f_6mtrand_11RandomState_zipf( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3626, "end_line": 3677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_geometric", "long_name": "__pyx_f_6mtrand_11RandomState_geometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 59, "complexity": 11, "token_count": 556, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3687, "end_line": 3754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_hypergeometric", "long_name": "__pyx_f_6mtrand_11RandomState_hypergeometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 89, "complexity": 19, "token_count": 922, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3768, "end_line": 3869, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 102, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_multivariate_normal", "long_name": "__pyx_f_6mtrand_11RandomState_multivariate_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 367, "complexity": 119, "token_count": 4997, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3896, "end_line": 4307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 412, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_multinomial", "long_name": "__pyx_f_6mtrand_11RandomState_multinomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 180, "complexity": 35, "token_count": 1738, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 4317, "end_line": 4549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 233, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_shuffle", "long_name": "__pyx_f_6mtrand_11RandomState_shuffle( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 63, "complexity": 18, "token_count": 729, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 4553, "end_line": 4626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 74, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_permutation", "long_name": "__pyx_f_6mtrand_11RandomState_permutation( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 49, "complexity": 9, "token_count": 473, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 4632, "end_line": 4687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "__pyx_tp_new_6mtrand_RandomState", "long_name": "__pyx_tp_new_6mtrand_RandomState( PyTypeObject * t , PyObject * a , PyObject * k)", "filename": "mtrand.c", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "t", "a", "k" ], "start_line": 4822, "end_line": 4826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "__pyx_tp_dealloc_6mtrand_RandomState", "long_name": "__pyx_tp_dealloc_6mtrand_RandomState( PyObject * o)", "filename": "mtrand.c", "nloc": 13, "complexity": 2, "token_count": 91, "parameters": [ "o" ], "start_line": 4828, "end_line": 4840, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "__pyx_tp_traverse_6mtrand_RandomState", "long_name": "__pyx_tp_traverse_6mtrand_RandomState( PyObject * o , visitproc v , * a)", "filename": "mtrand.c", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "o", "v", "a" ], "start_line": 4842, "end_line": 4846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "__pyx_tp_clear_6mtrand_RandomState", "long_name": "__pyx_tp_clear_6mtrand_RandomState( PyObject * o)", "filename": "mtrand.c", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "o" ], "start_line": 4848, "end_line": 4851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "initmtrand", "long_name": "initmtrand()", "filename": "mtrand.c", "nloc": 341, "complexity": 143, "token_count": 5498, "parameters": [], "start_line": 5026, "end_line": 5536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 511, "top_nesting_level": 0 }, { "name": "__Pyx_GetStarArgs", "long_name": "__Pyx_GetStarArgs( PyObject ** args , PyObject ** kwds , char * kwd_list [ ] , int nargs , PyObject ** args2 , PyObject ** kwds2)", "filename": "mtrand.c", "nloc": 66, "complexity": 17, "token_count": 324, "parameters": [ "args", "kwds", "nargs", "args2", "kwds2" ], "start_line": 5546, "end_line": 5615, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__Pyx_Import", "long_name": "__Pyx_Import( PyObject * name , PyObject * from_list)", "filename": "mtrand.c", "nloc": 32, "complexity": 6, "token_count": 159, "parameters": [ "name", "from_list" ], "start_line": 5617, "end_line": 5648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "__Pyx_GetName", "long_name": "__Pyx_GetName( PyObject * dict , PyObject * name)", "filename": "mtrand.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "dict", "name" ], "start_line": 5650, "end_line": 5656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "__Pyx_WriteUnraisable", "long_name": "__Pyx_WriteUnraisable( char * name)", "filename": "mtrand.c", "nloc": 10, "complexity": 2, "token_count": 64, "parameters": [ "name" ], "start_line": 5658, "end_line": 5667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "__Pyx_Raise", "long_name": "__Pyx_Raise( PyObject * type , PyObject * value , PyObject * tb)", "filename": "mtrand.c", "nloc": 54, "complexity": 11, "token_count": 259, "parameters": [ "type", "value", "tb" ], "start_line": 5669, "end_line": 5729, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "__Pyx_UnpackError", "long_name": "__Pyx_UnpackError()", "filename": "mtrand.c", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 5731, "end_line": 5733, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "__Pyx_UnpackItem", "long_name": "__Pyx_UnpackItem( PyObject * seq , int i)", "filename": "mtrand.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "seq", "i" ], "start_line": 5735, "end_line": 5742, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__Pyx_EndUnpack", "long_name": "__Pyx_EndUnpack( PyObject * seq , int i)", "filename": "mtrand.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "seq", "i" ], "start_line": 5744, "end_line": 5753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "__Pyx_InternStrings", "long_name": "__Pyx_InternStrings( __Pyx_InternTabEntry * t)", "filename": "mtrand.c", "nloc": 9, "complexity": 3, "token_count": 46, "parameters": [ "t" ], "start_line": 5755, "end_line": 5763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "__Pyx_InitStrings", "long_name": "__Pyx_InitStrings( __Pyx_StringTabEntry * t)", "filename": "mtrand.c", "nloc": 9, "complexity": 3, "token_count": 52, "parameters": [ "t" ], "start_line": 5765, "end_line": 5773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "__Pyx_ImportType", "long_name": "__Pyx_ImportType( char * module_name , char * class_name , long size)", "filename": "mtrand.c", "nloc": 48, "complexity": 9, "token_count": 237, "parameters": [ "module_name", "class_name", "size" ], "start_line": 5775, "end_line": 5823, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__Pyx_AddTraceback", "long_name": "__Pyx_AddTraceback( char * funcname)", "filename": "mtrand.c", "nloc": 52, "complexity": 8, "token_count": 232, "parameters": [ "funcname" ], "start_line": 5829, "end_line": 5881, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__pyx_f_6mtrand_cont0_array", "long_name": "__pyx_f_6mtrand_cont0_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 568, "parameters": [ "rk_state", "double", "__pyx_v_size" ], "start_line": 145, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont1_array", "long_name": "__pyx_f_6mtrand_cont1_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 577, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a" ], "start_line": 227, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont2_array", "long_name": "__pyx_f_6mtrand_cont2_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 586, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a", "__pyx_v_b" ], "start_line": 309, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont3_array", "long_name": "__pyx_f_6mtrand_cont3_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b , double __pyx_v_c)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 595, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a", "__pyx_v_b", "__pyx_v_c" ], "start_line": 391, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_disc0_array", "long_name": "__pyx_f_6mtrand_disc0_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 568, "parameters": [ "rk_state", "long", "__pyx_v_size" ], "start_line": 475, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discnp_array", "long_name": "__pyx_f_6mtrand_discnp_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,double)) , PyObject * __pyx_v_size , long __pyx_v_n , double __pyx_v_p)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 586, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_n", "__pyx_v_p" ], "start_line": 557, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discd_array", "long_name": "__pyx_f_6mtrand_discd_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 577, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_a" ], "start_line": 639, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_kahan_sum", "long_name": "__pyx_f_6mtrand_kahan_sum( double(*__pyx_v_darr) , long __pyx_v_n)", "filename": "mtrand.c", "nloc": 26, "complexity": 2, "token_count": 130, "parameters": [ "double", "__pyx_v_n" ], "start_line": 721, "end_line": 763, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___init__", "long_name": "__pyx_f_6mtrand_11RandomState___init__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 33, "complexity": 5, "token_count": 300, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 768, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___dealloc__", "long_name": "__pyx_f_6mtrand_11RandomState___dealloc__( PyObject * __pyx_v_self)", "filename": "mtrand.c", "nloc": 15, "complexity": 2, "token_count": 78, "parameters": [ "__pyx_v_self" ], "start_line": 808, "end_line": 827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_seed", "long_name": "__pyx_f_6mtrand_11RandomState_seed( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 59, "complexity": 10, "token_count": 541, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 834, "end_line": 903, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_get_state", "long_name": "__pyx_f_6mtrand_11RandomState_get_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 56, "complexity": 11, "token_count": 637, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 910, "end_line": 972, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_set_state", "long_name": "__pyx_f_6mtrand_11RandomState_set_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 88, "complexity": 19, "token_count": 969, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 984, "end_line": 1090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___getstate__", "long_name": "__pyx_f_6mtrand_11RandomState___getstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 28, "complexity": 5, "token_count": 238, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1093, "end_line": 1123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___setstate__", "long_name": "__pyx_f_6mtrand_11RandomState___setstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 31, "complexity": 5, "token_count": 271, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1126, "end_line": 1159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___reduce__", "long_name": "__pyx_f_6mtrand_11RandomState___reduce__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 10, "token_count": 463, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1165, "end_line": 1212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_random_sample", "long_name": "__pyx_f_6mtrand_11RandomState_random_sample( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1216, "end_line": 1242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_tomaxint", "long_name": "__pyx_f_6mtrand_11RandomState_tomaxint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1246, "end_line": 1272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_randint", "long_name": "__pyx_f_6mtrand_11RandomState_randint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 111, "complexity": 19, "token_count": 1002, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1280, "end_line": 1423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 144, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_bytes", "long_name": "__pyx_f_6mtrand_11RandomState_bytes( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 31, "complexity": 3, "token_count": 223, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1427, "end_line": 1468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_uniform", "long_name": "__pyx_f_6mtrand_11RandomState_uniform( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 28, "complexity": 3, "token_count": 208, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1472, "end_line": 1502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_rand", "long_name": "__pyx_f_6mtrand_11RandomState_rand( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 70, "complexity": 17, "token_count": 715, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1510, "end_line": 1586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_randn", "long_name": "__pyx_f_6mtrand_11RandomState_randn( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 67, "complexity": 15, "token_count": 651, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1590, "end_line": 1663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 74, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_random_integers", "long_name": "__pyx_f_6mtrand_11RandomState_random_integers( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 61, "complexity": 9, "token_count": 493, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1667, "end_line": 1736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_normal", "long_name": "__pyx_f_6mtrand_11RandomState_standard_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1740, "end_line": 1766, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_normal", "long_name": "__pyx_f_6mtrand_11RandomState_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1774, "end_line": 1828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_beta", "long_name": "__pyx_f_6mtrand_11RandomState_beta( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1838, "end_line": 1906, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_exponential", "long_name": "__pyx_f_6mtrand_11RandomState_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 389, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1914, "end_line": 1966, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_exponential", "long_name": "__pyx_f_6mtrand_11RandomState_standard_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1970, "end_line": 1996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_gamma", "long_name": "__pyx_f_6mtrand_11RandomState_standard_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2004, "end_line": 2055, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_gamma", "long_name": "__pyx_f_6mtrand_11RandomState_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 61, "complexity": 11, "token_count": 570, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2065, "end_line": 2134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_f", "long_name": "__pyx_f_6mtrand_11RandomState_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2144, "end_line": 2212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_noncentral_f", "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 75, "complexity": 15, "token_count": 747, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2224, "end_line": 2309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 86, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_chisquare", "long_name": "__pyx_f_6mtrand_11RandomState_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2317, "end_line": 2368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare", "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2378, "end_line": 2446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_cauchy", "long_name": "__pyx_f_6mtrand_11RandomState_standard_cauchy( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2450, "end_line": 2476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_t", "long_name": "__pyx_f_6mtrand_11RandomState_standard_t( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2484, "end_line": 2535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_vonmises", "long_name": "__pyx_f_6mtrand_11RandomState_vonmises( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 395, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2543, "end_line": 2595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_pareto", "long_name": "__pyx_f_6mtrand_11RandomState_pareto( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2603, "end_line": 2654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_weibull", "long_name": "__pyx_f_6mtrand_11RandomState_weibull( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2662, "end_line": 2713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_power", "long_name": "__pyx_f_6mtrand_11RandomState_power( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2721, "end_line": 2772, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_binomial", "long_name": "__pyx_f_6mtrand_11RandomState_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 74, "complexity": 15, "token_count": 737, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2784, "end_line": 2868, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_negative_binomial", "long_name": "__pyx_f_6mtrand_11RandomState_negative_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 74, "complexity": 15, "token_count": 737, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2880, "end_line": 2964, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_poisson", "long_name": "__pyx_f_6mtrand_11RandomState_poisson( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 389, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2972, "end_line": 3024, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_multivariate_normal", "long_name": "__pyx_f_6mtrand_11RandomState_multivariate_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 367, "complexity": 119, "token_count": 4997, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3052, "end_line": 3463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 412, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_multinomial", "long_name": "__pyx_f_6mtrand_11RandomState_multinomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 180, "complexity": 35, "token_count": 1738, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3473, "end_line": 3705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 233, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_shuffle", "long_name": "__pyx_f_6mtrand_11RandomState_shuffle( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 63, "complexity": 18, "token_count": 729, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3709, "end_line": 3782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 74, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_permutation", "long_name": "__pyx_f_6mtrand_11RandomState_permutation( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 49, "complexity": 9, "token_count": 473, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3788, "end_line": 3843, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "__pyx_tp_new_6mtrand_RandomState", "long_name": "__pyx_tp_new_6mtrand_RandomState( PyTypeObject * t , PyObject * a , PyObject * k)", "filename": "mtrand.c", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "t", "a", "k" ], "start_line": 3951, "end_line": 3955, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "__pyx_tp_dealloc_6mtrand_RandomState", "long_name": "__pyx_tp_dealloc_6mtrand_RandomState( PyObject * o)", "filename": "mtrand.c", "nloc": 13, "complexity": 2, "token_count": 91, "parameters": [ "o" ], "start_line": 3957, "end_line": 3969, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "__pyx_tp_traverse_6mtrand_RandomState", "long_name": "__pyx_tp_traverse_6mtrand_RandomState( PyObject * o , visitproc v , * a)", "filename": "mtrand.c", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "o", "v", "a" ], "start_line": 3971, "end_line": 3975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "__pyx_tp_clear_6mtrand_RandomState", "long_name": "__pyx_tp_clear_6mtrand_RandomState( PyObject * o)", "filename": "mtrand.c", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "o" ], "start_line": 3977, "end_line": 3980, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "initmtrand", "long_name": "initmtrand()", "filename": "mtrand.c", "nloc": 263, "complexity": 113, "token_count": 4306, "parameters": [], "start_line": 4145, "end_line": 4537, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 393, "top_nesting_level": 0 }, { "name": "__Pyx_GetStarArgs", "long_name": "__Pyx_GetStarArgs( PyObject ** args , PyObject ** kwds , char * kwd_list [ ] , int nargs , PyObject ** args2 , PyObject ** kwds2)", "filename": "mtrand.c", "nloc": 66, "complexity": 17, "token_count": 324, "parameters": [ "args", "kwds", "nargs", "args2", "kwds2" ], "start_line": 4547, "end_line": 4616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__Pyx_Import", "long_name": "__Pyx_Import( PyObject * name , PyObject * from_list)", "filename": "mtrand.c", "nloc": 32, "complexity": 6, "token_count": 159, "parameters": [ "name", "from_list" ], "start_line": 4618, "end_line": 4649, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "__Pyx_GetName", "long_name": "__Pyx_GetName( PyObject * dict , PyObject * name)", "filename": "mtrand.c", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "dict", "name" ], "start_line": 4651, "end_line": 4657, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "__Pyx_WriteUnraisable", "long_name": "__Pyx_WriteUnraisable( char * name)", "filename": "mtrand.c", "nloc": 10, "complexity": 2, "token_count": 64, "parameters": [ "name" ], "start_line": 4659, "end_line": 4668, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "__Pyx_Raise", "long_name": "__Pyx_Raise( PyObject * type , PyObject * value , PyObject * tb)", "filename": "mtrand.c", "nloc": 54, "complexity": 11, "token_count": 259, "parameters": [ "type", "value", "tb" ], "start_line": 4670, "end_line": 4730, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "__Pyx_UnpackError", "long_name": "__Pyx_UnpackError()", "filename": "mtrand.c", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 4732, "end_line": 4734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "__Pyx_UnpackItem", "long_name": "__Pyx_UnpackItem( PyObject * seq , int i)", "filename": "mtrand.c", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "seq", "i" ], "start_line": 4736, "end_line": 4743, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__Pyx_EndUnpack", "long_name": "__Pyx_EndUnpack( PyObject * seq , int i)", "filename": "mtrand.c", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "seq", "i" ], "start_line": 4745, "end_line": 4754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "__Pyx_InternStrings", "long_name": "__Pyx_InternStrings( __Pyx_InternTabEntry * t)", "filename": "mtrand.c", "nloc": 9, "complexity": 3, "token_count": 46, "parameters": [ "t" ], "start_line": 4756, "end_line": 4764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "__Pyx_InitStrings", "long_name": "__Pyx_InitStrings( __Pyx_StringTabEntry * t)", "filename": "mtrand.c", "nloc": 9, "complexity": 3, "token_count": 52, "parameters": [ "t" ], "start_line": 4766, "end_line": 4774, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "__Pyx_ImportType", "long_name": "__Pyx_ImportType( char * module_name , char * class_name , long size)", "filename": "mtrand.c", "nloc": 48, "complexity": 9, "token_count": 237, "parameters": [ "module_name", "class_name", "size" ], "start_line": 4776, "end_line": 4824, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__Pyx_AddTraceback", "long_name": "__Pyx_AddTraceback( char * funcname)", "filename": "mtrand.c", "nloc": 52, "complexity": 8, "token_count": 232, "parameters": [ "funcname" ], "start_line": 4830, "end_line": 4882, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__pyx_f_6mtrand_11RandomState_lognormal", "long_name": "__pyx_f_6mtrand_11RandomState_lognormal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3078, "end_line": 3132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_tomaxint", "long_name": "__pyx_f_6mtrand_11RandomState_tomaxint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1358, "end_line": 1384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont2_array", "long_name": "__pyx_f_6mtrand_cont2_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 586, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a", "__pyx_v_b" ], "start_line": 339, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_laplace", "long_name": "__pyx_f_6mtrand_11RandomState_laplace( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2892, "end_line": 2946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_permutation", "long_name": "__pyx_f_6mtrand_11RandomState_permutation( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 49, "complexity": 9, "token_count": 473, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 4632, "end_line": 4687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 56, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_exponential", "long_name": "__pyx_f_6mtrand_11RandomState_standard_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2082, "end_line": 2108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_triangular", "long_name": "__pyx_f_6mtrand_11RandomState_triangular( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 75, "complexity": 15, "token_count": 747, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3281, "end_line": 3366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 86, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_geometric", "long_name": "__pyx_f_6mtrand_11RandomState_geometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 59, "complexity": 11, "token_count": 556, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3687, "end_line": 3754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discd_array", "long_name": "__pyx_f_6mtrand_discd_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 577, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_a" ], "start_line": 751, "end_line": 831, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_random_sample", "long_name": "__pyx_f_6mtrand_11RandomState_random_sample( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1328, "end_line": 1354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___reduce__", "long_name": "__pyx_f_6mtrand_11RandomState___reduce__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 10, "token_count": 463, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1277, "end_line": 1324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_weibull", "long_name": "__pyx_f_6mtrand_11RandomState_weibull( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2774, "end_line": 2825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_normal", "long_name": "__pyx_f_6mtrand_11RandomState_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1886, "end_line": 1940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_rand", "long_name": "__pyx_f_6mtrand_11RandomState_rand( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 70, "complexity": 17, "token_count": 715, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1622, "end_line": 1698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_set_state", "long_name": "__pyx_f_6mtrand_11RandomState_set_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 88, "complexity": 19, "token_count": 969, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1096, "end_line": 1202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___dealloc__", "long_name": "__pyx_f_6mtrand_11RandomState___dealloc__( PyObject * __pyx_v_self)", "filename": "mtrand.c", "nloc": 15, "complexity": 2, "token_count": 78, "parameters": [ "__pyx_v_self" ], "start_line": 920, "end_line": 939, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_gamma", "long_name": "__pyx_f_6mtrand_11RandomState_standard_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2116, "end_line": 2167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont1_array", "long_name": "__pyx_f_6mtrand_cont1_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 577, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a" ], "start_line": 257, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_poisson", "long_name": "__pyx_f_6mtrand_11RandomState_poisson( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 389, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3566, "end_line": 3618, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___getstate__", "long_name": "__pyx_f_6mtrand_11RandomState___getstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 28, "complexity": 5, "token_count": 238, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1205, "end_line": 1235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_kahan_sum", "long_name": "__pyx_f_6mtrand_kahan_sum( double(*__pyx_v_darr) , long __pyx_v_n)", "filename": "mtrand.c", "nloc": 26, "complexity": 2, "token_count": 130, "parameters": [ "double", "__pyx_v_n" ], "start_line": 833, "end_line": 875, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_chisquare", "long_name": "__pyx_f_6mtrand_11RandomState_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2429, "end_line": 2480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_negative_binomial", "long_name": "__pyx_f_6mtrand_11RandomState_negative_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 74, "complexity": 15, "token_count": 737, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3474, "end_line": 3558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_logistic", "long_name": "__pyx_f_6mtrand_11RandomState_logistic( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3016, "end_line": 3070, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_t", "long_name": "__pyx_f_6mtrand_11RandomState_standard_t( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2596, "end_line": 2647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_multivariate_normal", "long_name": "__pyx_f_6mtrand_11RandomState_multivariate_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 367, "complexity": 119, "token_count": 4997, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3896, "end_line": 4307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 412, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_randn", "long_name": "__pyx_f_6mtrand_11RandomState_randn( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 67, "complexity": 15, "token_count": 651, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1702, "end_line": 1775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 74, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_randint", "long_name": "__pyx_f_6mtrand_11RandomState_randint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 111, "complexity": 19, "token_count": 1002, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1392, "end_line": 1535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 144, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_uniform", "long_name": "__pyx_f_6mtrand_11RandomState_uniform( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 28, "complexity": 3, "token_count": 208, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1584, "end_line": 1614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_random_integers", "long_name": "__pyx_f_6mtrand_11RandomState_random_integers( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 61, "complexity": 9, "token_count": 493, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1779, "end_line": 1848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discnmN_array", "long_name": "__pyx_f_6mtrand_discnmN_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,long,long)) , PyObject * __pyx_v_size , long __pyx_v_n , long __pyx_v_m , long __pyx_v_N)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 595, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_n", "__pyx_v_m", "__pyx_v_N" ], "start_line": 669, "end_line": 749, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_normal", "long_name": "__pyx_f_6mtrand_11RandomState_standard_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1852, "end_line": 1878, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_wald", "long_name": "__pyx_f_6mtrand_11RandomState_wald( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3201, "end_line": 3269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "initmtrand", "long_name": "initmtrand()", "filename": "mtrand.c", "nloc": 341, "complexity": 143, "token_count": 5498, "parameters": [], "start_line": 5026, "end_line": 5536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 511, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_disc0_array", "long_name": "__pyx_f_6mtrand_disc0_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 568, "parameters": [ "rk_state", "long", "__pyx_v_size" ], "start_line": 505, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_vonmises", "long_name": "__pyx_f_6mtrand_11RandomState_vonmises( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 395, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2655, "end_line": 2707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_discnp_array", "long_name": "__pyx_f_6mtrand_discnp_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,double)) , PyObject * __pyx_v_size , long __pyx_v_n , double __pyx_v_p)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 586, "parameters": [ "rk_state", "long", "__pyx_v_size", "__pyx_v_n", "__pyx_v_p" ], "start_line": 587, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_f", "long_name": "__pyx_f_6mtrand_11RandomState_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2256, "end_line": 2324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_shuffle", "long_name": "__pyx_f_6mtrand_11RandomState_shuffle( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 63, "complexity": 18, "token_count": 729, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 4553, "end_line": 4626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 74, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___setstate__", "long_name": "__pyx_f_6mtrand_11RandomState___setstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 31, "complexity": 5, "token_count": 271, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1238, "end_line": 1271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_gamma", "long_name": "__pyx_f_6mtrand_11RandomState_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 61, "complexity": 11, "token_count": 570, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2177, "end_line": 2246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_standard_cauchy", "long_name": "__pyx_f_6mtrand_11RandomState_standard_cauchy( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 24, "complexity": 3, "token_count": 176, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2562, "end_line": 2588, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_multinomial", "long_name": "__pyx_f_6mtrand_11RandomState_multinomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 180, "complexity": 35, "token_count": 1738, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 4317, "end_line": 4549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 233, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_power", "long_name": "__pyx_f_6mtrand_11RandomState_power( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2833, "end_line": 2884, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_seed", "long_name": "__pyx_f_6mtrand_11RandomState_seed( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 59, "complexity": 10, "token_count": 541, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 946, "end_line": 1015, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_binomial", "long_name": "__pyx_f_6mtrand_11RandomState_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 74, "complexity": 15, "token_count": 737, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3378, "end_line": 3462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_zipf", "long_name": "__pyx_f_6mtrand_11RandomState_zipf( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3626, "end_line": 3677, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState___init__", "long_name": "__pyx_f_6mtrand_11RandomState___init__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 33, "complexity": 5, "token_count": 300, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 880, "end_line": 917, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_beta", "long_name": "__pyx_f_6mtrand_11RandomState_beta( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1950, "end_line": 2018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_rayleigh", "long_name": "__pyx_f_6mtrand_11RandomState_rayleigh( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3140, "end_line": 3191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_exponential", "long_name": "__pyx_f_6mtrand_11RandomState_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 46, "complexity": 7, "token_count": 389, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2026, "end_line": 2078, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_noncentral_f", "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 75, "complexity": 15, "token_count": 747, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2336, "end_line": 2421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 86, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_gumbel", "long_name": "__pyx_f_6mtrand_11RandomState_gumbel( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 48, "complexity": 7, "token_count": 403, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2954, "end_line": 3008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare", "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 60, "complexity": 11, "token_count": 566, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2490, "end_line": 2558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_bytes", "long_name": "__pyx_f_6mtrand_11RandomState_bytes( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 31, "complexity": 3, "token_count": 223, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1539, "end_line": 1580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_hypergeometric", "long_name": "__pyx_f_6mtrand_11RandomState_hypergeometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 89, "complexity": 19, "token_count": 922, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 3768, "end_line": 3869, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 102, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont0_array", "long_name": "__pyx_f_6mtrand_cont0_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 568, "parameters": [ "rk_state", "double", "__pyx_v_size" ], "start_line": 175, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_get_state", "long_name": "__pyx_f_6mtrand_11RandomState_get_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 56, "complexity": 11, "token_count": 637, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 1022, "end_line": 1084, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_cont3_array", "long_name": "__pyx_f_6mtrand_cont3_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b , double __pyx_v_c)", "filename": "mtrand.c", "nloc": 64, "complexity": 10, "token_count": 595, "parameters": [ "rk_state", "double", "__pyx_v_size", "__pyx_v_a", "__pyx_v_b", "__pyx_v_c" ], "start_line": 421, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 81, "top_nesting_level": 0 }, { "name": "__pyx_f_6mtrand_11RandomState_pareto", "long_name": "__pyx_f_6mtrand_11RandomState_pareto( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", "filename": "mtrand.c", "nloc": 45, "complexity": 7, "token_count": 385, "parameters": [ "__pyx_v_self", "__pyx_args", "__pyx_kwds" ], "start_line": 2715, "end_line": 2766, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 } ], "nloc": 4884, "complexity": 883, "token_count": 46873, "diff_parsed": { "added": [ "/* Generated by Pyrex 0.9.3.1 on Thu Oct 6 21:56:32 2005 */", "static double __pyx_k34;", "static double __pyx_k35;", "static PyObject *__pyx_k36;", "static double __pyx_k37;", "static double __pyx_k38;", "static double __pyx_k40;", "static double __pyx_k41;", "static PyObject *__pyx_k42;", "static double __pyx_k43;", "static double __pyx_k44;", "static PyObject *__pyx_k45;", "static PyObject *__pyx_k46;", "static PyObject *__pyx_k47;", "static PyObject *__pyx_k48;", "static PyObject *__pyx_k49;", "static PyObject *__pyx_k50;", "static double __pyx_k51;", "static PyObject *__pyx_k52;", "static PyObject *__pyx_k53;", "static PyObject *__pyx_k54;", "static PyObject *__pyx_k55;", "static PyObject *__pyx_k56;", "static PyObject *__pyx_k57;", "static PyObject *(__pyx_f_6mtrand_discnmN_array(rk_state (*),long ((*)(rk_state (*),long ,long ,long )),PyObject *,long ,long ,long )); /*proto*/", "static PyObject *__pyx_n__sp;", "static PyObject *__pyx_n_laplace;", "static PyObject *__pyx_n_gumbel;", "static PyObject *__pyx_n_logistic;", "static PyObject *__pyx_n_lognormal;", "static PyObject *__pyx_n_rayleigh;", "static PyObject *__pyx_n_wald;", "static PyObject *__pyx_n_triangular;", "static PyObject *__pyx_n_zipf;", "static PyObject *__pyx_n_geometric;", "static PyObject *__pyx_n_hypergeometric;", "static PyObject *__pyx_n_scipy;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":123 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":124 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":126 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":127 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":129 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":130 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":139 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":140 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":142 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":143 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":146 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":156 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":157 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":159 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":160 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":161 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":163 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":164 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":174 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":175 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":177 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":178 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":180 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":181 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":190 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":191 */", " __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":193 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":194 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":196 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":197 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":206 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":207 */", " __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":209 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":210 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":212 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":213 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */", "static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,long ,long )),PyObject *__pyx_v_size,long __pyx_v_n,long __pyx_v_m,long __pyx_v_N) {", " long (*__pyx_v_array_data);", " PyArrayObject *__pyx_v_array;", " long __pyx_v_length;", " long __pyx_v_i;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " Py_INCREF(__pyx_v_size);", " __pyx_v_array = (void *)Py_None; Py_INCREF((PyObject *) __pyx_v_array);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":223 */", " __pyx_1 = __pyx_v_size == Py_None;", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":224 */", " __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", " goto __pyx_L2;", " }", " /*else*/ {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":226 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}", " Py_INCREF(__pyx_v_size);", " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);", " PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);", " __pyx_4 = 0;", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_INCREF(((PyObject *)__pyx_4));", " Py_DECREF(((PyObject *)__pyx_v_array));", " __pyx_v_array = ((PyObject *)__pyx_4);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":227 */", " __pyx_v_length = PyArray_SIZE(__pyx_v_array);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */", " __pyx_v_array_data = ((long (*))__pyx_v_array->data);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */", " for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":230 */", " (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N);", " __pyx_L3:;", " }", " __pyx_L4:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":231 */", " Py_INCREF(((PyObject *)__pyx_v_array));", " __pyx_r = ((PyObject *)__pyx_v_array);", " goto __pyx_L0;", " }", " __pyx_L2:;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.discnmN_array\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_array);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":239 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":240 */", " __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":242 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":243 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":244 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":245 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":246 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":247 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":253 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":254 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":255 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":256 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":257 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":282 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":284 */", " __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":287 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":288 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":302 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":303 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":305 */", " __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */", " __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":317 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":318 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":319 */", " __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", "static PyObject *__pyx_k60p;", "static PyObject *__pyx_k61p;", "static char (__pyx_k60[]) = \"algorithm must be 'MT19937'\";", "static char (__pyx_k61[]) = \"state must be 624 longs\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":330 */", " __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;}", " __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":331 */", " if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":332 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}", " Py_INCREF(__pyx_k60p);", " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k60p);", " __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":333 */", " __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}", " __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}", " __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}", " __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}", " if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":334 */", " __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":335 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}", " Py_INCREF(__pyx_k61p);", " PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k61p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":337 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":338 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":342 */", " __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":345 */", " __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":348 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stats); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */", " __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}", "static PyObject *__pyx_k62p;", "static char (__pyx_k62[]) = \"low >= high\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":378 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":379 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":380 */", " __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":382 */", " __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":383 */", " __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":385 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":386 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}", " __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}", " Py_INCREF(__pyx_k62p);", " PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k62p);", " __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":389 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":390 */", " __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":392 */", " __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":393 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":394 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":395 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":396 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":405 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":406 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":407 */", " __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":408 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":409 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":416 */", " __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":425 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":426 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":428 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}", " __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}", " if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}", " __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":436 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":437 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":439 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":448 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":449 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":450 */", " __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":451 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}", " __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}", " __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;}", "static PyObject *__pyx_k64p;", "static char (__pyx_k64[]) = \"scale <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":467 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}", " Py_INCREF(__pyx_k64p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":468 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;}", "static PyObject *__pyx_k65p;", "static PyObject *__pyx_k66p;", "static char (__pyx_k65[]) = \"a <= 0\";", "static char (__pyx_k66[]) = \"b <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":476 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}", " Py_INCREF(__pyx_k65p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k65p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":478 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}", " Py_INCREF(__pyx_k66p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":479 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; goto __pyx_L1;}", "static PyObject *__pyx_k67p;", "static char (__pyx_k67[]) = \"scale <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":487 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}", " Py_INCREF(__pyx_k67p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":488 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":495 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; goto __pyx_L1;}", "static PyObject *__pyx_k68p;", "static char (__pyx_k68[]) = \"shape <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":502 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":503 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}", " Py_INCREF(__pyx_k68p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":504 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; goto __pyx_L1;}", "static PyObject *__pyx_k69p;", "static PyObject *__pyx_k70p;", "static char (__pyx_k69[]) = \"shape <= 0\";", "static char (__pyx_k70[]) = \"scale <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":511 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":512 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}", " Py_INCREF(__pyx_k69p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":514 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}", " Py_INCREF(__pyx_k70p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":515 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;}", "static PyObject *__pyx_k71p;", "static PyObject *__pyx_k72p;", "static char (__pyx_k71[]) = \"dfnum <= 0\";", "static char (__pyx_k72[]) = \"dfden <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":523 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}", " Py_INCREF(__pyx_k71p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":525 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}", " Py_INCREF(__pyx_k72p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":526 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; goto __pyx_L1;}", "static PyObject *__pyx_k73p;", "static PyObject *__pyx_k74p;", "static PyObject *__pyx_k75p;", "static char (__pyx_k73[]) = \"dfnum <= 1\";", "static char (__pyx_k74[]) = \"dfden <= 0\";", "static char (__pyx_k75[]) = \"nonc < 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":533 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":534 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}", " Py_INCREF(__pyx_k73p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k73p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":536 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}", " Py_INCREF(__pyx_k74p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k74p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":538 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}", " Py_INCREF(__pyx_k75p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k75p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */", " __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}", "static PyObject *__pyx_k76p;", "static char (__pyx_k76[]) = \"df <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":548 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}", " Py_INCREF(__pyx_k76p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":549 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; goto __pyx_L1;}", "static PyObject *__pyx_k77p;", "static PyObject *__pyx_k78p;", "static char (__pyx_k77[]) = \"df <= 1\";", "static char (__pyx_k78[]) = \"nonc < 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":557 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " Py_INCREF(__pyx_k77p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k77p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":559 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}", " Py_INCREF(__pyx_k78p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k78p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":560 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":568 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;}", "static PyObject *__pyx_k79p;", "static char (__pyx_k79[]) = \"df <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":576 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}", " Py_INCREF(__pyx_k79p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k79p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":577 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; goto __pyx_L1;}", "static PyObject *__pyx_k80p;", "static char (__pyx_k80[]) = \"kappa < 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":585 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":586 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}", " Py_INCREF(__pyx_k80p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k80p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":587 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; goto __pyx_L1;}", "static PyObject *__pyx_k81p;", "static char (__pyx_k81[]) = \"a <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":595 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}", " Py_INCREF(__pyx_k81p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k81p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":596 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}", "static PyObject *__pyx_k82p;", "static char (__pyx_k82[]) = \"a <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":603 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":604 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}", " Py_INCREF(__pyx_k82p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k82p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":605 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; goto __pyx_L1;}", "static PyObject *__pyx_k83p;", "static char (__pyx_k83[]) = \"a <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":613 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}", " Py_INCREF(__pyx_k83p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k83p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":614 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;}", "static PyObject *__pyx_k84p;", "static char (__pyx_k84[]) = \"scale <= 0.0\";", "static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_laplace[] = \"Laplace distribution.\\n \\n laplace(loc=0.0, scale=1.0, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_loc;", " double __pyx_v_scale;", " static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};", " __pyx_v_loc = __pyx_k34;", " __pyx_v_scale = __pyx_k35;", " __pyx_v_size = __pyx_k36;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */", " __pyx_1 = (__pyx_v_scale <= 0.0);", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":622 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}", " Py_INCREF(__pyx_k84p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k84p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":623 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; goto __pyx_L1;}", " __Pyx_AddTraceback(\"mtrand.RandomState.laplace\");", "static PyObject *__pyx_k85p;", "static char (__pyx_k85[]) = \"scale <= 0.0\";", "static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_gumbel[] = \"Gumbel distribution.\\n \\n gumbel(loc=0.0, scale=1.0, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_loc;", " double __pyx_v_scale;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};", " __pyx_v_loc = __pyx_k37;", " __pyx_v_scale = __pyx_k38;", " __pyx_v_size = __pyx_k39;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":630 */", " __pyx_1 = (__pyx_v_scale <= 0.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":631 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}", " Py_INCREF(__pyx_k85p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k85p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":632 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.gumbel\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k86p;", "", "static char (__pyx_k86[]) = \"scale <= 0.0\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_logistic[] = \"Logistic distribution.\\n \\n logistic(loc=0.0, scale=1.0, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_loc;", " double __pyx_v_scale;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};", " __pyx_v_loc = __pyx_k40;", " __pyx_v_scale = __pyx_k41;", " __pyx_v_size = __pyx_k42;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":639 */", " __pyx_1 = (__pyx_v_scale <= 0.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":640 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}", " Py_INCREF(__pyx_k86p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k86p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":641 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.logistic\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k87p;", "", "static char (__pyx_k87[]) = \"sigma <= 0.0\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_lognormal[] = \"Log-normal distribution.\\n \\n Note that the mean parameter is not the mean of this distribution, but \\n the underlying normal distribution.\\n \\n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\\n \\n lognormal(mean=0.0, sigma=1.0, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_mean;", " double __pyx_v_sigma;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"mean\",\"sigma\",\"size\",0};", " __pyx_v_mean = __pyx_k43;", " __pyx_v_sigma = __pyx_k44;", " __pyx_v_size = __pyx_k45;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_sigma, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":653 */", " __pyx_1 = (__pyx_v_sigma <= 0.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":654 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " Py_INCREF(__pyx_k87p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k87p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":655 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_mean,__pyx_v_sigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.lognormal\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k88p;", "", "static char (__pyx_k88[]) = \"mode <= 0.0\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_rayleigh[] = \"Rayleigh distribution.\\n \\n rayleigh(mode, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_mode;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"mode\",\"size\",0};", " __pyx_v_size = __pyx_k46;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_mode, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":662 */", " __pyx_1 = (__pyx_v_mode <= 0.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":663 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " Py_INCREF(__pyx_k88p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k88p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":664 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_mode); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.rayleigh\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k89p;", "static PyObject *__pyx_k90p;", "", "static char (__pyx_k89[]) = \"mean <= 0.0\";", "static char (__pyx_k90[]) = \"scale <= 0.0\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_wald[] = \"Wald (inverse Gaussian) distribution.\\n \\n wald(mean, scale, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_mean;", " double __pyx_v_scale;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"mean\",\"scale\",\"size\",0};", " __pyx_v_size = __pyx_k47;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_scale, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":671 */", " __pyx_1 = (__pyx_v_mean <= 0.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":672 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " Py_INCREF(__pyx_k89p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k89p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_scale <= 0.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":674 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}", " Py_INCREF(__pyx_k90p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k90p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":675 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_mean,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.wald\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k91p;", "static PyObject *__pyx_k92p;", "static PyObject *__pyx_k93p;", "", "static char (__pyx_k91[]) = \"left > mode\";", "static char (__pyx_k92[]) = \"mode > right\";", "static char (__pyx_k93[]) = \"left == right\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_triangular[] = \"Triangular distribution starting at left, peaking at mode, and \\n ending at right (left <= mode <= right).\\n \\n triangular(left, mode, right, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_left;", " double __pyx_v_mode;", " double __pyx_v_right;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"left\",\"mode\",\"right\",\"size\",0};", " __pyx_v_size = __pyx_k48;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_left, &__pyx_v_mode, &__pyx_v_right, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":683 */", " __pyx_1 = (__pyx_v_left > __pyx_v_mode);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":684 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}", " Py_INCREF(__pyx_k91p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k91p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_mode > __pyx_v_right);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":686 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}", " Py_INCREF(__pyx_k92p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k92p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_left == __pyx_v_right);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":688 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}", " Py_INCREF(__pyx_k93p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k93p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":689 */", " __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_left,__pyx_v_mode,__pyx_v_right); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.triangular\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k94p;", "static PyObject *__pyx_k95p;", "static PyObject *__pyx_k96p;", "", "static char (__pyx_k94[]) = \"n <= 0\";", "static char (__pyx_k95[]) = \"p < 0\";", "static char (__pyx_k96[]) = \"p > 1\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " long __pyx_v_n;", " __pyx_v_size = __pyx_k49;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":699 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}", " Py_INCREF(__pyx_k94p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k94p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_p < 0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":701 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " Py_INCREF(__pyx_k95p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k95p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_p > 1);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}", " Py_INCREF(__pyx_k96p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k96p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */", " __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k97p;", "static PyObject *__pyx_k98p;", "static PyObject *__pyx_k99p;", "", "static char (__pyx_k97[]) = \"n <= 0\";", "static char (__pyx_k98[]) = \"p < 0\";", "static char (__pyx_k99[]) = \"p > 1\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " long __pyx_v_n;", " double __pyx_v_p;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};", " __pyx_v_size = __pyx_k50;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */", " __pyx_1 = (__pyx_v_n <= 0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":712 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}", " Py_INCREF(__pyx_k97p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k97p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":714 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}", " Py_INCREF(__pyx_k98p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k98p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}", " Py_INCREF(__pyx_k99p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k99p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */", " __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}", "static PyObject *__pyx_k100p;", "static char (__pyx_k100[]) = \"lam <= 0\";", " __pyx_v_lam = __pyx_k51;", " __pyx_v_size = __pyx_k52;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":725 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":726 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}", " Py_INCREF(__pyx_k100p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k100p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":727 */", " __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; goto __pyx_L1;}", "static PyObject *__pyx_k101p;", "", "static char (__pyx_k101[]) = \"a <= 1.0\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_zipf[] = \"Zipf distribution.\\n \\n zipf(a, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_a;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"a\",\"size\",0};", " __pyx_v_size = __pyx_k53;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":734 */", " __pyx_1 = (__pyx_v_a <= 1.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":735 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}", " Py_INCREF(__pyx_k101p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k101p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":736 */", " __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.zipf\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k102p;", "static PyObject *__pyx_k103p;", "", "static char (__pyx_k102[]) = \"p < 0.0\";", "static char (__pyx_k103[]) = \"p > 1.0\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_geometric[] = \"Geometric distribution with p being the probability of \\\"success\\\" on\\n an individual trial.\\n \\n geometric(p, size=None)\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " double __pyx_v_p;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"p\",\"size\",0};", " __pyx_v_size = __pyx_k54;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":744 */", " __pyx_1 = (__pyx_v_p < 0.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":745 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}", " Py_INCREF(__pyx_k102p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k102p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_p > 1.0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":747 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}", " Py_INCREF(__pyx_k103p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k103p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":748 */", " __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.geometric\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k104p;", "static PyObject *__pyx_k105p;", "static PyObject *__pyx_k106p;", "static PyObject *__pyx_k107p;", "", "static char (__pyx_k104[]) = \"ngood < 1\";", "static char (__pyx_k105[]) = \"nbad < 1\";", "static char (__pyx_k106[]) = \"ngood + nbad < nsample\";", "static char (__pyx_k107[]) = \"nsample < 1\";", "", "static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = \"Hypergeometric distribution.\\n \\n Consider an urn with ngood \\\"good\\\" balls and nbad \\\"bad\\\" balls. If one \\n were to draw nsample balls from the urn without replacement, then \\n the hypergeometric distribution describes the distribution of \\\"good\\\" \\n balls in the sample.\\n \\n hypergeometric(ngood, nbad, nsample, size=None) \\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " long __pyx_v_ngood;", " long __pyx_v_nbad;", " long __pyx_v_nsample;", " PyObject *__pyx_v_size = 0;", " PyObject *__pyx_r;", " int __pyx_1;", " PyObject *__pyx_2 = 0;", " PyObject *__pyx_3 = 0;", " PyObject *__pyx_4 = 0;", " static char *__pyx_argnames[] = {\"ngood\",\"nbad\",\"nsample\",\"size\",0};", " __pyx_v_size = __pyx_k55;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lll|O\", __pyx_argnames, &__pyx_v_ngood, &__pyx_v_nbad, &__pyx_v_nsample, &__pyx_v_size)) return 0;", " Py_INCREF(__pyx_v_self);", " Py_INCREF(__pyx_v_size);", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":760 */", " __pyx_1 = (__pyx_v_ngood < 1);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":761 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}", " Py_INCREF(__pyx_k104p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k104p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_nbad < 1);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":763 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}", " Py_INCREF(__pyx_k105p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k105p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = ((__pyx_v_ngood + __pyx_v_nbad) < __pyx_v_nsample);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}", " Py_INCREF(__pyx_k106p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k106p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_nsample < 1);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":767 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}", " Py_INCREF(__pyx_k107p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k107p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_L2:;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */", " __pyx_2 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ngood,__pyx_v_nbad,__pyx_v_nsample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}", " __pyx_r = __pyx_2;", " __pyx_2 = 0;", " goto __pyx_L0;", "", " __pyx_r = Py_None; Py_INCREF(__pyx_r);", " goto __pyx_L0;", " __pyx_L1:;", " Py_XDECREF(__pyx_2);", " Py_XDECREF(__pyx_3);", " Py_XDECREF(__pyx_4);", " __Pyx_AddTraceback(\"mtrand.RandomState.hypergeometric\");", " __pyx_r = 0;", " __pyx_L0:;", " Py_DECREF(__pyx_v_self);", " Py_DECREF(__pyx_v_size);", " return __pyx_r;", "}", "", "static PyObject *__pyx_k108p;", "static PyObject *__pyx_k109p;", "static PyObject *__pyx_k110p;", "static char (__pyx_k108[]) = \"mean must be 1 dimensional\";", "static char (__pyx_k109[]) = \"cov must be 2 dimensional and square\";", "static char (__pyx_k110[]) = \"mean and cov must have same length\";", " __pyx_v_size = __pyx_k56;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":790 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":791 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":792 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":793 */", " __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":795 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":796 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}", " __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":797 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}", " Py_INCREF(__pyx_k108p);", " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k108p);", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":798 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":799 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}", " Py_INCREF(__pyx_k109p);", " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k109p);", " __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":800 */", " __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}", " __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}", " __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}", " __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}", " __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":801 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}", " Py_INCREF(__pyx_k110p);", " PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k110p);", " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":803 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}", " __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":804 */", " __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":805 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}", " __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":806 */", " __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}", " __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":810 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":811 */", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}", " __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":821 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_linalg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_singular_value_decomposition); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":822 */", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":825 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":826 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":827 */", "static PyObject *__pyx_k111p;", "static char (__pyx_k111[]) = \"sum(pvals) > 1.0\";", " __pyx_v_size = __pyx_k57;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":845 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}", " __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":846 */", " __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":847 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":849 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":850 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}", " Py_INCREF(__pyx_k111p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k111p);", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":852 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":853 */", " __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":855 */", " __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":857 */", " __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}", " __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":859 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":860 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":861 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":862 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":863 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":864 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":865 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":866 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":867 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":868 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":869 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":870 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":871 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":872 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":873 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":875 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":877 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":888 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}", " __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}", " __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":889 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":890 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":891 */", " __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":892 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":900 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_arange); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":901 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":902 */", " {&__pyx_n__sp, \"_sp\"},", " {&__pyx_n_geometric, \"geometric\"},", " {&__pyx_n_gumbel, \"gumbel\"},", " {&__pyx_n_hypergeometric, \"hypergeometric\"},", " {&__pyx_n_laplace, \"laplace\"},", " {&__pyx_n_logistic, \"logistic\"},", " {&__pyx_n_lognormal, \"lognormal\"},", " {&__pyx_n_rayleigh, \"rayleigh\"},", " {&__pyx_n_triangular, \"triangular\"},", " {&__pyx_n_wald, \"wald\"},", " {&__pyx_n_zipf, \"zipf\"},", " {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)},", " {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)},", " {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)},", " {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)},", " {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)},", " {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)},", " {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)},", " {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)},", " {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)},", " {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)},", " {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)},", " {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)},", " {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)},", " {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)},", " {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)},", " {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)},", " {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)},", " {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)},", " {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)},", " {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)},", " {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)},", " {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)},", " {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)},", " {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)},", " {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)},", " {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)},", " {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)},", " {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)},", " {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)},", " {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)},", " {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)},", " {&__pyx_k108p, __pyx_k108, sizeof(__pyx_k108)},", " {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)},", " {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)},", " {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)},", " {\"laplace\", (PyCFunction)__pyx_f_6mtrand_11RandomState_laplace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_laplace},", " {\"gumbel\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gumbel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gumbel},", " {\"logistic\", (PyCFunction)__pyx_f_6mtrand_11RandomState_logistic, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_logistic},", " {\"lognormal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_lognormal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_lognormal},", " {\"rayleigh\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rayleigh, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rayleigh},", " {\"wald\", (PyCFunction)__pyx_f_6mtrand_11RandomState_wald, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_wald},", " {\"triangular\", (PyCFunction)__pyx_f_6mtrand_11RandomState_triangular, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_triangular},", " {\"zipf\", (PyCFunction)__pyx_f_6mtrand_11RandomState_zipf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_zipf},", " {\"geometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_geometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_geometric},", " {\"hypergeometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_hypergeometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_hypergeometric},", " if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}", " if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":113 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":115 */", " __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n__sp, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":281 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":290 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":351 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":358 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":365 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":411 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":454 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":461 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":470 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":481 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":490 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":497 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":506 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":517 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":542 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":551 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":563 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":570 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":579 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":589 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":598 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":607 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":616 */", " __pyx_k34 = 0.0;", " __pyx_k35 = 1.0;", " __pyx_k36 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":625 */", " __pyx_k37 = 0.0;", " __pyx_k38 = 1.0;", " __pyx_k39 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":634 */", " __pyx_k40 = 0.0;", " __pyx_k41 = 1.0;", " __pyx_k42 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":643 */", " __pyx_k43 = 0.0;", " __pyx_k44 = 1.0;", " __pyx_k45 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":657 */", " __pyx_k46 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":666 */", " Py_INCREF(Py_None);", " __pyx_k47 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */", " Py_INCREF(Py_None);", " __pyx_k48 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":693 */", " Py_INCREF(Py_None);", " __pyx_k49 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */", " Py_INCREF(Py_None);", " __pyx_k50 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":720 */", " __pyx_k51 = 1.0;", " Py_INCREF(Py_None);", " __pyx_k52 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":729 */", " Py_INCREF(Py_None);", " __pyx_k53 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":738 */", " Py_INCREF(Py_None);", " __pyx_k54 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":750 */", " Py_INCREF(Py_None);", " __pyx_k55 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */", " Py_INCREF(Py_None);", " __pyx_k56 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":829 */", " Py_INCREF(Py_None);", " __pyx_k57 = Py_None;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":905 */", " __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":906 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":907 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":908 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":909 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":910 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":911 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":912 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":913 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":914 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":915 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":916 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":917 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":918 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":919 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":920 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":921 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":922 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":923 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":924 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":925 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":926 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":927 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":928 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":929 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":930 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}", " Py_DECREF(__pyx_1); __pyx_1 = 0;", " if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":931 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":932 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_laplace); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":933 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gumbel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":934 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logistic); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":935 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_lognormal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":936 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rayleigh); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":937 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_wald); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":938 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_triangular); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":940 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":941 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":942 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":943 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zipf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":944 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_geometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":945 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_hypergeometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":947 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":948 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":950 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":951 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}" ], "deleted": [ "/* Generated by Pyrex 0.9.3.1 on Wed Sep 28 22:52:52 2005 */", "static PyObject *__pyx_k34;", "static PyObject *__pyx_k35;", "static double __pyx_k36;", "static PyObject *__pyx_k37;", "static PyObject *__pyx_k38;", "static PyObject *__pyx_n_scipy;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":111 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":112 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":114 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":115 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":116 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":117 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":118 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":119 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":127 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":130 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":132 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":133 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":134 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":135 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":148 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":149 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":150 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":151 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":152 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":163 */", " __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":165 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":166 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":167 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":168 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":169 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":170 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":178 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */", " __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":181 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":183 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":184 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":185 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":186 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":194 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */", " __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":197 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":199 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":200 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":201 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":202 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":210 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */", " __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":213 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":215 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":216 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":217 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":218 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":223 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":224 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":225 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":226 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":227 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":230 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":253 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":255 */", " __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":273 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":274 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":276 */", " __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":278 */", " __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":279 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":288 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":289 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":290 */", " __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}", "static PyObject *__pyx_k42p;", "static PyObject *__pyx_k43p;", "static char (__pyx_k42[]) = \"algorithm must be 'MT19937'\";", "static char (__pyx_k43[]) = \"state must be 624 longs\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":301 */", " __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}", " __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":302 */", " if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":303 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}", " Py_INCREF(__pyx_k42p);", " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k42p);", " __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":304 */", " __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":305 */", " __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":306 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}", " Py_INCREF(__pyx_k43p);", " PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k43p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":309 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":313 */", " __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":316 */", " __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":319 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stats); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":327 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":334 */", " __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}", "static PyObject *__pyx_k44p;", "static char (__pyx_k44[]) = \"low >= high\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":349 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":350 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":351 */", " __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":353 */", " __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":354 */", " __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":357 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":358 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}", " __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}", " Py_INCREF(__pyx_k44p);", " PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k44p);", " __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":360 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":361 */", " __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */", " __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}", " __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":364 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":365 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":366 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":367 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":368 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":376 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":377 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":378 */", " __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":379 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":380 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */", " __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":396 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":399 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}", " __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}", " if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}", " __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":407 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":408 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":410 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":419 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":420 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":421 */", " __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":422 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}", " __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}", " __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":430 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}", "static PyObject *__pyx_k46p;", "static char (__pyx_k46[]) = \"scale <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":437 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":438 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}", " Py_INCREF(__pyx_k46p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k46p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":439 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}", "static PyObject *__pyx_k47p;", "static PyObject *__pyx_k48p;", "static char (__pyx_k47[]) = \"a <= 0\";", "static char (__pyx_k48[]) = \"b <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":446 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":447 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}", " Py_INCREF(__pyx_k47p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k47p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":449 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}", " Py_INCREF(__pyx_k48p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":450 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}", "static PyObject *__pyx_k49p;", "static char (__pyx_k49[]) = \"scale <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":457 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":458 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}", " Py_INCREF(__pyx_k49p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k49p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;}", "static PyObject *__pyx_k50p;", "static char (__pyx_k50[]) = \"shape <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":473 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":474 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}", " Py_INCREF(__pyx_k50p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k50p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;}", "static PyObject *__pyx_k51p;", "static PyObject *__pyx_k52p;", "static char (__pyx_k51[]) = \"shape <= 0\";", "static char (__pyx_k52[]) = \"scale <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":482 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":483 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}", " Py_INCREF(__pyx_k51p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k51p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":485 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}", " Py_INCREF(__pyx_k52p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k52p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;}", "static PyObject *__pyx_k53p;", "static PyObject *__pyx_k54p;", "static char (__pyx_k53[]) = \"dfnum <= 0\";", "static char (__pyx_k54[]) = \"dfden <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":493 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":494 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}", " Py_INCREF(__pyx_k53p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k53p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":496 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}", " Py_INCREF(__pyx_k54p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k54p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":497 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; goto __pyx_L1;}", "static PyObject *__pyx_k55p;", "static PyObject *__pyx_k56p;", "static PyObject *__pyx_k57p;", "static char (__pyx_k55[]) = \"dfnum <= 1\";", "static char (__pyx_k56[]) = \"dfden <= 0\";", "static char (__pyx_k57[]) = \"nonc < 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":504 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":505 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}", " Py_INCREF(__pyx_k55p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k55p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":507 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}", " Py_INCREF(__pyx_k56p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k56p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":509 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}", " Py_INCREF(__pyx_k57p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k57p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":510 */", " __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;}", "static PyObject *__pyx_k58p;", "static char (__pyx_k58[]) = \"df <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":518 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":519 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}", " Py_INCREF(__pyx_k58p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k58p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":520 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;}", "static PyObject *__pyx_k59p;", "static PyObject *__pyx_k60p;", "static char (__pyx_k59[]) = \"df <= 1\";", "static char (__pyx_k60[]) = \"nonc < 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":527 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}", " Py_INCREF(__pyx_k59p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k59p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":530 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}", " Py_INCREF(__pyx_k60p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k60p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":531 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */", " __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}", "static PyObject *__pyx_k61p;", "static char (__pyx_k61[]) = \"df <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":546 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}", " Py_INCREF(__pyx_k61p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k61p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":548 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;}", "static PyObject *__pyx_k62p;", "static char (__pyx_k62[]) = \"kappa < 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":557 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " Py_INCREF(__pyx_k62p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k62p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":558 */", " __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; goto __pyx_L1;}", "static PyObject *__pyx_k63p;", "static char (__pyx_k63[]) = \"a <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":565 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":566 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}", " Py_INCREF(__pyx_k63p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k63p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":567 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}", "static PyObject *__pyx_k64p;", "static char (__pyx_k64[]) = \"a <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":574 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}", " Py_INCREF(__pyx_k64p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":576 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;}", "static PyObject *__pyx_k65p;", "static char (__pyx_k65[]) = \"a <= 0\";", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":583 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":584 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}", " Py_INCREF(__pyx_k65p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k65p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":585 */", " __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; goto __pyx_L1;}", "static PyObject *__pyx_k66p;", "static PyObject *__pyx_k67p;", "static PyObject *__pyx_k68p;", "static char (__pyx_k66[]) = \"n <= 0\";", "static char (__pyx_k67[]) = \"p < 0\";", "static char (__pyx_k68[]) = \"p > 1\";", "static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " long __pyx_v_n;", " double __pyx_v_p;", " static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};", " __pyx_v_size = __pyx_k34;", " if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":593 */", " __pyx_1 = (__pyx_v_n <= 0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}", " Py_INCREF(__pyx_k66p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_p < 0);", " if (__pyx_1) {", "", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":596 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}", " Py_INCREF(__pyx_k67p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}", " Py_DECREF(__pyx_2); __pyx_2 = 0;", " Py_DECREF(__pyx_3); __pyx_3 = 0;", " __Pyx_Raise(__pyx_4, 0, 0);", " Py_DECREF(__pyx_4); __pyx_4 = 0;", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;}", " goto __pyx_L2;", " }", " __pyx_1 = (__pyx_v_p > 1);", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":598 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}", " Py_INCREF(__pyx_k68p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":599 */", " __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; goto __pyx_L1;}", " __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");", "static PyObject *__pyx_k69p;", "static PyObject *__pyx_k70p;", "static PyObject *__pyx_k71p;", "static char (__pyx_k69[]) = \"n <= 0\";", "static char (__pyx_k70[]) = \"p < 0\";", "static char (__pyx_k71[]) = \"p > 1\";", "static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/", "static char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";", "static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {", " long __pyx_v_n;", " __pyx_v_size = __pyx_k35;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":606 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":607 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}", " Py_INCREF(__pyx_k69p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":609 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}", " Py_INCREF(__pyx_k70p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":611 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}", " Py_INCREF(__pyx_k71p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */", " __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;}", "static PyObject *__pyx_k72p;", "static char (__pyx_k72[]) = \"lam <= 0\";", " __pyx_v_lam = __pyx_k36;", " __pyx_v_size = __pyx_k37;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":620 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}", " Py_INCREF(__pyx_k72p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);", " __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":622 */", " __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}", "static PyObject *__pyx_n_Numeric;", "static PyObject *__pyx_k73p;", "static PyObject *__pyx_k74p;", "static PyObject *__pyx_k75p;", "static char (__pyx_k73[]) = \"mean must be 1 dimensional\";", "static char (__pyx_k74[]) = \"cov must be 2 dimensional and square\";", "static char (__pyx_k75[]) = \"mean and cov must have same length\";", " __pyx_v_size = __pyx_k38;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":643 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":644 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":645 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":646 */", " __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":648 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":649 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}", " __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":650 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}", " Py_INCREF(__pyx_k73p);", " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k73p);", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":651 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":652 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}", " Py_INCREF(__pyx_k74p);", " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k74p);", " __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":653 */", " __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}", " __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}", " __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}", " __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}", " __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}", " if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":654 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " Py_INCREF(__pyx_k75p);", " PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k75p);", " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":656 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}", " __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":657 */", " __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":658 */", " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}", " __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":659 */", " __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}", " __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":663 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":664 */", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}", " __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":672 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_linalg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_singular_value_decomposition); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":673 */", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_Numeric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":676 */", " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}", " __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}", " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":678 */", "static PyObject *__pyx_k76p;", "static char (__pyx_k76[]) = \"sum(pvals) > 1.0\";", " __pyx_v_size = __pyx_k39;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":696 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}", " __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":697 */", " __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":700 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":701 */", " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " Py_INCREF(__pyx_k76p);", " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */", " __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */", " __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":708 */", " __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}", " __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":710 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}", " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}", " __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}", " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}", " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":712 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":713 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":714 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":715 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":718 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":719 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":720 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":721 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":722 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":723 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":724 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":726 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":728 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":739 */", " __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}", " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}", " __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}", " __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}", " __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":740 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":741 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":742 */", " __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":743 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":751 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_scipy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_arange); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":752 */", " __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}", " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}", " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":753 */", " {&__pyx_n_Numeric, \"scipy\"},", " {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)},", " {&__pyx_k43p, __pyx_k43, sizeof(__pyx_k43)},", " {&__pyx_k44p, __pyx_k44, sizeof(__pyx_k44)},", " {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)},", " {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)},", " {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)},", " {&__pyx_k49p, __pyx_k49, sizeof(__pyx_k49)},", " {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)},", " {&__pyx_k51p, __pyx_k51, sizeof(__pyx_k51)},", " {&__pyx_k52p, __pyx_k52, sizeof(__pyx_k52)},", " {&__pyx_k53p, __pyx_k53, sizeof(__pyx_k53)},", " {&__pyx_k54p, __pyx_k54, sizeof(__pyx_k54)},", " {&__pyx_k55p, __pyx_k55, sizeof(__pyx_k55)},", " {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)},", " {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)},", " {&__pyx_k58p, __pyx_k58, sizeof(__pyx_k58)},", " {&__pyx_k59p, __pyx_k59, sizeof(__pyx_k59)},", " {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)},", " if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}", " if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":101 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":103 */", " __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_scipy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":261 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":322 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":329 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":382 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":412 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":425 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":432 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":452 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":461 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":468 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":477 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":488 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":499 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":513 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":534 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":541 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":550 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":560 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":569 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":578 */", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":588 */", " __pyx_k34 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":601 */", " __pyx_k35 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":615 */", " __pyx_k36 = 1.0;", " __pyx_k37 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":625 */", " __pyx_k38 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":680 */", " __pyx_k39 = Py_None;", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":756 */", " __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}", " __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":757 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":758 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":759 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":760 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":761 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":762 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":763 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":764 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":766 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":767 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":769 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":770 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":771 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":773 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":774 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":775 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":776 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":777 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":778 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":779 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":780 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":781 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":782 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":783 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":784 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":785 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":786 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":787 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":788 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;}", " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":789 */", " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}", " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}", " if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}" ] } }, { "old_path": "scipy/corelib/mtrand/mtrand.pyx", "new_path": "scipy/corelib/mtrand/mtrand.pyx", "filename": "mtrand.pyx", "extension": "pyx", "change_type": "MODIFY", "diff": "@@ -79,10 +79,21 @@\n double rk_pareto(rk_state *state, double a)\n double rk_weibull(rk_state *state, double a)\n double rk_power(rk_state *state, double a)\n+ double rk_laplace(rk_state *state, double loc, double scale)\n+ double rk_gumbel(rk_state *state, double loc, double scale)\n+ double rk_logistic(rk_state *state, double loc, double scale)\n+ double rk_lognormal(rk_state *state, double mode, double sigma)\n+ double rk_rayleigh(rk_state *state, double mode)\n+ double rk_wald(rk_state *state, double mean, double scale)\n+ double rk_triangular(rk_state *state, double left, double mode, double right)\n+ \n long rk_binomial(rk_state *state, long n, double p)\n long rk_negative_binomial(rk_state *state, long n, double p)\n long rk_poisson(rk_state *state, double lam)\n-\n+ long rk_zipf(rk_state *state, double a)\n+ long rk_geometric(rk_state *state, double p)\n+ long rk_hypergeometric(rk_state *state, long good, long bad, long sample)\n+ \n ctypedef double (* rk_cont0)(rk_state *state)\n ctypedef double (* rk_cont1)(rk_state *state, double a)\n ctypedef double (* rk_cont2)(rk_state *state, double a, double b)\n@@ -90,6 +101,7 @@\n \n ctypedef long (* rk_disc0)(rk_state *state)\n ctypedef long (* rk_discnp)(rk_state *state, long n, double p)\n+ctypedef long (* rk_discnmN)(rk_state *state, long n, long m, long N)\n ctypedef long (* rk_discd)(rk_state *state, double a)\n \n \n@@ -100,7 +112,7 @@\n # Initialize scipy\n import_array()\n \n-import scipy\n+import scipy as _sp\n \n cdef object cont0_array(rk_state *state, rk_cont0 func, object size):\n cdef double *array_data\n@@ -111,7 +123,7 @@\n if size is None:\n return func(state)\n else:\n- array = scipy.empty(size, scipy.Float64)\n+ array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n@@ -127,7 +139,7 @@\n if size is None:\n return func(state, a)\n else:\n- array = scipy.empty(size, scipy.Float64)\n+ array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n@@ -144,7 +156,7 @@\n if size is None:\n return func(state, a, b)\n else:\n- array = scipy.empty(size, scipy.Float64)\n+ array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n@@ -162,7 +174,7 @@\n if size is None:\n return func(state, a, b, c)\n else:\n- array = scipy.empty(size, scipy.Float64)\n+ array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n@@ -178,7 +190,7 @@\n if size is None:\n return func(state)\n else:\n- array = scipy.empty(size, scipy.Int)\n+ array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n@@ -194,13 +206,30 @@\n if size is None:\n return func(state, n, p)\n else:\n- array = scipy.empty(size, scipy.Int)\n+ array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, p)\n return array\n \n+cdef object discnmN_array(rk_state *state, rk_discnmN func, object size, \n+ long n, long m, long N):\n+ cdef long *array_data\n+ cdef ArrayType array\n+ cdef long length\n+ cdef long i\n+\n+ if size is None:\n+ return func(state, n, m, N)\n+ else:\n+ array = _sp.empty(size, _sp.Int)\n+ length = PyArray_SIZE(array)\n+ array_data = array.data\n+ for i from 0 <= i < length:\n+ array_data[i] = func(state, n, m, N)\n+ return array\n+\n cdef object discd_array(rk_state *state, rk_discd func, object size, double a):\n cdef long *array_data\n cdef ArrayType array\n@@ -210,7 +239,7 @@\n if size is None:\n return func(state, a)\n else:\n- array = scipy.empty(size, scipy.Int)\n+ array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n@@ -285,7 +314,7 @@ def get_state(self):\n get_state() -> ('MT19937', int key[624], int pos)\n \"\"\"\n cdef ArrayType state\n- state = scipy.empty(624, scipy.Int)\n+ state = _sp.empty(624, _sp.Int)\n memcpy((state.data), self.internal_state.key, 624*sizeof(long))\n return ('MT19937', state, self.internal_state.pos)\n \n@@ -316,7 +345,7 @@ def __setstate__(self, state):\n self.set_state(state)\n \n def __reduce__(self):\n- return (scipy.stats.__RandomState_ctor, (), self.get_state())\n+ return (_sp.stats.__RandomState_ctor, (), self.get_state())\n \n # Basic distributions:\n def random_sample(self, size=None):\n@@ -360,7 +389,7 @@ def randint(self, low, high=None, size=None):\n if size is None:\n return rk_interval(diff, self.internal_state)\n else:\n- array = scipy.empty(size, scipy.Int)\n+ array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n@@ -584,6 +613,82 @@ def power(self, double a, size=None):\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_power, size, a)\n \n+ def laplace(self, double loc=0.0, double scale=1.0, size=None):\n+ \"\"\"Laplace distribution.\n+ \n+ laplace(loc=0.0, scale=1.0, size=None)\n+ \"\"\"\n+ if scale <= 0.0:\n+ raise ValueError(\"scale <= 0.0\")\n+ return cont2_array(self.internal_state, rk_laplace, size, loc, scale)\n+ \n+ def gumbel(self, double loc=0.0, double scale=1.0, size=None):\n+ \"\"\"Gumbel distribution.\n+ \n+ gumbel(loc=0.0, scale=1.0, size=None)\n+ \"\"\"\n+ if scale <= 0.0:\n+ raise ValueError(\"scale <= 0.0\")\n+ return cont2_array(self.internal_state, rk_gumbel, size, loc, scale)\n+ \n+ def logistic(self, double loc=0.0, double scale=1.0, size=None):\n+ \"\"\"Logistic distribution.\n+ \n+ logistic(loc=0.0, scale=1.0, size=None)\n+ \"\"\"\n+ if scale <= 0.0:\n+ raise ValueError(\"scale <= 0.0\")\n+ return cont2_array(self.internal_state, rk_logistic, size, loc, scale)\n+\n+ def lognormal(self, double mean=0.0, double sigma=1.0, size=None):\n+ \"\"\"Log-normal distribution.\n+ \n+ Note that the mean parameter is not the mean of this distribution, but \n+ the underlying normal distribution.\n+ \n+ lognormal(mean, sigma) <=> exp(normal(mean, sigma))\n+ \n+ lognormal(mean=0.0, sigma=1.0, size=None)\n+ \"\"\"\n+ if sigma <= 0.0:\n+ raise ValueError(\"sigma <= 0.0\")\n+ return cont2_array(self.internal_state, rk_lognormal, size, mean, sigma)\n+ \n+ def rayleigh(self, double mode, size=None):\n+ \"\"\"Rayleigh distribution.\n+ \n+ rayleigh(mode, size=None)\n+ \"\"\"\n+ if mode <= 0.0:\n+ raise ValueError(\"mode <= 0.0\")\n+ return cont1_array(self.internal_state, rk_rayleigh, size, mode)\n+ \n+ def wald(self, double mean, double scale, size=None):\n+ \"\"\"Wald (inverse Gaussian) distribution.\n+ \n+ wald(mean, scale, size=None)\n+ \"\"\"\n+ if mean <= 0.0:\n+ raise ValueError(\"mean <= 0.0\")\n+ elif scale <= 0.0:\n+ raise ValueError(\"scale <= 0.0\")\n+ return cont2_array(self.internal_state, rk_wald, size, mean, scale)\n+\n+ def triangular(self, double left, double mode, double right, size=None):\n+ \"\"\"Triangular distribution starting at left, peaking at mode, and \n+ ending at right (left <= mode <= right).\n+ \n+ triangular(left, mode, right, size=None)\n+ \"\"\"\n+ if left > mode:\n+ raise ValueError(\"left > mode\")\n+ elif mode > right:\n+ raise ValueError(\"mode > right\")\n+ elif left == right:\n+ raise ValueError(\"left == right\")\n+ return cont3_array(self.internal_state, rk_triangular, size, left, \n+ mode, right)\n+\n # Complicated, discrete distributions:\n def binomial(self, long n, double p, size=None):\n \"\"\"Binomial distribution of n trials and p probability of success.\n@@ -621,6 +726,48 @@ def poisson(self, double lam=1.0, size=None):\n raise ValueError(\"lam <= 0\")\n return discd_array(self.internal_state, rk_poisson, size, lam)\n \n+ def zipf(self, double a, size=None):\n+ \"\"\"Zipf distribution.\n+ \n+ zipf(a, size=None)\n+ \"\"\"\n+ if a <= 1.0:\n+ raise ValueError(\"a <= 1.0\")\n+ return discd_array(self.internal_state, rk_zipf, size, a)\n+ \n+ def geometric(self, double p, size=None):\n+ \"\"\"Geometric distribution with p being the probability of \"success\" on\n+ an individual trial.\n+ \n+ geometric(p, size=None)\n+ \"\"\"\n+ if p < 0.0:\n+ raise ValueError(\"p < 0.0\")\n+ elif p > 1.0:\n+ raise ValueError(\"p > 1.0\")\n+ return discd_array(self.internal_state, rk_geometric, size, p)\n+ \n+ def hypergeometric(self, long ngood, long nbad, long nsample, size=None):\n+ \"\"\"Hypergeometric distribution.\n+ \n+ Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one \n+ were to draw nsample balls from the urn without replacement, then \n+ the hypergeometric distribution describes the distribution of \"good\" \n+ balls in the sample.\n+ \n+ hypergeometric(ngood, nbad, nsample, size=None) \n+ \"\"\"\n+ if ngood < 1:\n+ raise ValueError(\"ngood < 1\")\n+ elif nbad < 1:\n+ raise ValueError(\"nbad < 1\")\n+ elif ngood + nbad < nsample:\n+ raise ValueError(\"ngood + nbad < nsample\")\n+ elif nsample < 1:\n+ raise ValueError(\"nsample < 1\")\n+ return discnmN_array(self.internal_state, rk_hypergeometric, size,\n+ ngood, nbad, nsample)\n+\n # Multivariate distributions:\n def multivariate_normal(self, mean, cov, size=None):\n \"\"\"Return an array containing multivariate normally distributed random numbers\n@@ -640,8 +787,8 @@ def multivariate_normal(self, mean, cov, size=None):\n normal.\n \"\"\"\n # Check preconditions on arguments\n- mean = scipy.array(mean)\n- cov = scipy.array(cov)\n+ mean = _sp.array(mean)\n+ cov = _sp.array(cov)\n if size is None:\n shape = []\n else:\n@@ -660,8 +807,8 @@ def multivariate_normal(self, mean, cov, size=None):\n # Create a matrix of independent standard normally distributed random\n # numbers. The matrix has rows with the same length as mean and as\n # many rows are necessary to form a matrix of shape final_shape.\n- x = standard_normal(scipy.multiply.reduce(final_shape))\n- x.shape = (scipy.multiply.reduce(final_shape[0:len(final_shape)-1]),\n+ x = standard_normal(_sp.multiply.reduce(final_shape))\n+ x.shape = (_sp.multiply.reduce(final_shape[0:len(final_shape)-1]),\n mean.shape[0])\n # Transform matrix of standard normals into matrix where each row\n # contains multivariate normals with the desired covariance.\n@@ -669,11 +816,13 @@ def multivariate_normal(self, mean, cov, size=None):\n # Then the matrix products of the rows of x and A has the desired\n # covariance. Note that sqrt(s)*v where (u,s,v) is the singular value\n # decomposition of cov is such an A.\n- (u,s,v) = scipy.linalg.singular_value_decomposition(cov)\n- x = scipy.matrixmultiply(x*scipy.sqrt(s),v)\n+ \n+ # XXX: we really should be doing this by Cholesky decomposition\n+ (u,s,v) = _sp.linalg.singular_value_decomposition(cov)\n+ x = _sp.matrixmultiply(x*_sp.sqrt(s),v)\n # The rows of x now have the correct covariance but mean 0. Add\n # mean to each row. Then each row will have mean mean.\n- scipy.add(mean,x,x)\n+ _sp.add(mean,x,x)\n x.shape = tuple(final_shape)\n return x\n \n@@ -707,7 +856,7 @@ def multinomial(self, long n, object pvals, size=None):\n else:\n shape = size + (d,)\n \n- multin = scipy.zeros(shape, scipy.Int)\n+ multin = _sp.zeros(shape, _sp.Int)\n mnarr = multin\n mnix = mnarr.data\n i = 0\n@@ -748,7 +897,7 @@ def permutation(self, object x):\n \n permutation(x)\n \"\"\"\n- arr = scipy.arange(x)\n+ arr = _sp.arange(x)\n self.shuffle(arr)\n return arr\n \n@@ -780,10 +929,23 @@ def permutation(self, object x):\n pareto = _rand.pareto\n weibull = _rand.weibull\n power = _rand.power\n+laplace = _rand.laplace\n+gumbel = _rand.gumbel\n+logistic = _rand.logistic\n+lognormal = _rand.lognormal\n+rayleigh = _rand.rayleigh\n+wald = _rand.wald\n+triangular = _rand.triangular\n+\n binomial = _rand.binomial\n negative_binomial = _rand.negative_binomial\n poisson = _rand.poisson\n+zipf = _rand.zipf\n+geometric = _rand.geometric\n+hypergeometric = _rand.hypergeometric\n+\n multivariate_normal = _rand.multivariate_normal\n multinomial = _rand.multinomial\n+\n shuffle = _rand.shuffle\n permutation = _rand.permutation\n", "added_lines": 183, "deleted_lines": 21, "source_code": "# mtrand.pyx -- A Pyrex wrapper of Jean-Sebastien Roy's RandomKit\n#\n# Copyright 2005 Robert Kern (robert.kern@gmail.com)\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n# \n# The above copyright notice and this permission notice shall be included\n# in all copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\ninclude \"Python.pxi\"\ninclude \"scipy.pxi\"\n\ncdef extern from \"math.h\":\n double exp(double x)\n double log(double x)\n double floor(double x)\n double sin(double x)\n double cos(double x)\n\ncdef extern from \"randomkit.h\":\n\n ctypedef struct rk_state:\n unsigned long key[624]\n int pos\n\n ctypedef enum rk_error:\n RK_NOERR = 0\n RK_ENODEV = 1\n RK_ERR_MAX = 2\n\n char *rk_strerror[2]\n \n # 0xFFFFFFFFUL\n unsigned long RK_MAX\n\n void rk_seed(unsigned long seed, rk_state *state)\n rk_error rk_randomseed(rk_state *state)\n unsigned long rk_random(rk_state *state)\n long rk_long(rk_state *state)\n unsigned long rk_ulong(rk_state *state)\n unsigned long rk_interval(unsigned long max, rk_state *state)\n double rk_double(rk_state *state)\n void rk_fill(void *buffer, size_t size, rk_state *state)\n rk_error rk_devfill(void *buffer, size_t size, int strong)\n rk_error rk_altfill(void *buffer, size_t size, int strong,\n rk_state *state)\n double rk_gauss(rk_state *state)\n\ncdef extern from \"distributions.h\":\n \n double rk_normal(rk_state *state, double loc, double scale)\n double rk_standard_exponential(rk_state *state)\n double rk_exponential(rk_state *state, double scale)\n double rk_uniform(rk_state *state, double loc, double scale)\n double rk_standard_gamma(rk_state *state, double shape)\n double rk_gamma(rk_state *state, double shape, double scale)\n double rk_beta(rk_state *state, double a, double b)\n double rk_chisquare(rk_state *state, double df)\n double rk_noncentral_chisquare(rk_state *state, double df, double nonc)\n double rk_f(rk_state *state, double dfnum, double dfden)\n double rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc)\n double rk_standard_cauchy(rk_state *state)\n double rk_standard_t(rk_state *state, double df)\n double rk_vonmises(rk_state *state, double mu, double kappa)\n double rk_pareto(rk_state *state, double a)\n double rk_weibull(rk_state *state, double a)\n double rk_power(rk_state *state, double a)\n double rk_laplace(rk_state *state, double loc, double scale)\n double rk_gumbel(rk_state *state, double loc, double scale)\n double rk_logistic(rk_state *state, double loc, double scale)\n double rk_lognormal(rk_state *state, double mode, double sigma)\n double rk_rayleigh(rk_state *state, double mode)\n double rk_wald(rk_state *state, double mean, double scale)\n double rk_triangular(rk_state *state, double left, double mode, double right)\n \n long rk_binomial(rk_state *state, long n, double p)\n long rk_negative_binomial(rk_state *state, long n, double p)\n long rk_poisson(rk_state *state, double lam)\n long rk_zipf(rk_state *state, double a)\n long rk_geometric(rk_state *state, double p)\n long rk_hypergeometric(rk_state *state, long good, long bad, long sample)\n \nctypedef double (* rk_cont0)(rk_state *state)\nctypedef double (* rk_cont1)(rk_state *state, double a)\nctypedef double (* rk_cont2)(rk_state *state, double a, double b)\nctypedef double (* rk_cont3)(rk_state *state, double a, double b, double c)\n\nctypedef long (* rk_disc0)(rk_state *state)\nctypedef long (* rk_discnp)(rk_state *state, long n, double p)\nctypedef long (* rk_discnmN)(rk_state *state, long n, long m, long N)\nctypedef long (* rk_discd)(rk_state *state, double a)\n\n\ncdef extern from \"initarray.h\":\n void init_by_array(rk_state *self, unsigned long *init_key, \n unsigned long key_length)\n\n# Initialize scipy\nimport_array()\n\nimport scipy as _sp\n\ncdef object cont0_array(rk_state *state, rk_cont0 func, object size):\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object cont1_array(rk_state *state, rk_cont1 func, object size, double a):\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef object cont2_array(rk_state *state, rk_cont2 func, object size, double a, \n double b):\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a, b)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b)\n return array\n\ncdef object cont3_array(rk_state *state, rk_cont3 func, object size, double a, \n double b, double c):\n\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a, b, c)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b, c)\n return array\n\ncdef object disc0_array(rk_state *state, rk_disc0 func, object size):\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object discnp_array(rk_state *state, rk_discnp func, object size, long n, double p):\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, n, p)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, p)\n return array\n\ncdef object discnmN_array(rk_state *state, rk_discnmN func, object size, \n long n, long m, long N):\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, n, m, N)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, m, N)\n return array\n\ncdef object discd_array(rk_state *state, rk_discd func, object size, double a):\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef double kahan_sum(double *darr, long n):\n cdef double c, y, t, sum\n cdef long i\n sum = darr[0]\n c = 0.0\n for i from 1 <= i < n:\n y = darr[i] - c\n t = sum + y\n c = (t-sum) - y\n sum = t\n return sum\n\ncdef class RandomState:\n \"\"\"Container for the Mersenne Twister PRNG.\n\n Constructor\n -----------\n RandomState(seed=None): initializes the PRNG with the given seed. See the\n seed() method for details.\n\n Distribution Methods\n -----------------\n RandomState exposes a number of methods for generating random numbers drawn\n from a variety of probability distributions. In addition to the\n distribution-specific arguments, each method takes a keyword argument\n size=None. If size is None, then a single value is generated and returned.\n If size is an integer, then a 1-D scipy array filled with generated values\n is returned. If size is a tuple, then a scipy array with that shape is\n filled and returned.\n \"\"\"\n cdef rk_state *internal_state\n\n def __init__(self, seed=None):\n self.internal_state = PyMem_Malloc(sizeof(rk_state))\n\n self.seed(seed)\n\n def __dealloc__(self):\n if self.internal_state != NULL:\n PyMem_Free(self.internal_state)\n\n def seed(self, seed=None):\n \"\"\"Seed the generator.\n\n seed(seed=None)\n\n seed can be an integer, an array (or other sequence) of integers of any\n length, or None. If seed is None, then RandomState will try to read data\n from /dev/urandom (or the Windows analogue) if available or seed from\n the clock otherwise.\n \"\"\"\n cdef rk_error errcode\n cdef ArrayType obj\n if seed is None:\n errcode = rk_randomseed(self.internal_state)\n elif type(seed) is int:\n rk_seed(seed, self.internal_state)\n else:\n obj = PyArray_ContiguousFromObject(seed, PyArray_LONG, 1, 1)\n init_by_array(self.internal_state, (obj.data),\n obj.dimensions[0])\n\n def get_state(self):\n \"\"\"Return a tuple representing the internal state of the generator.\n\n get_state() -> ('MT19937', int key[624], int pos)\n \"\"\"\n cdef ArrayType state\n state = _sp.empty(624, _sp.Int)\n memcpy((state.data), self.internal_state.key, 624*sizeof(long))\n return ('MT19937', state, self.internal_state.pos)\n \n def set_state(self, state):\n \"\"\"Set the state from a tuple.\n \n state = ('MT19937', int key[624], int pos)\n \n set_state(state)\n \"\"\"\n cdef ArrayType obj\n cdef int pos\n algorithm_name = state[0]\n if algorithm_name != 'MT19937':\n raise ValueError(\"algorithm must be 'MT19937'\")\n key, pos = state[1:]\n obj = PyArray_ContiguousFromObject(key, PyArray_LONG, 1, 1)\n if obj.dimensions[0] != 624:\n raise ValueError(\"state must be 624 longs\")\n memcpy(self.internal_state.key, (obj.data), 624*sizeof(long))\n self.internal_state.pos = pos\n \n # Pickling support:\n def __getstate__(self):\n return self.get_state()\n\n def __setstate__(self, state):\n self.set_state(state)\n\n def __reduce__(self):\n return (_sp.stats.__RandomState_ctor, (), self.get_state())\n\n # Basic distributions:\n def random_sample(self, size=None):\n \"\"\"Return random floats in the half-open interval [0.0, 1.0).\n\n random_sample(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_double, size)\n\n def tomaxint(self, size=None):\n \"\"\"Returns random integers x such that 0 <= x <= sys.maxint.\n\n tomaxint(size=None) -> random values\n \"\"\"\n return disc0_array(self.internal_state, rk_long, size)\n\n def randint(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x < high.\n\n randint(low, high=None, size=None) -> random values\n\n If high is None, then 0 <= x < low.\n \"\"\"\n cdef long lo, hi, diff\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if high is None:\n lo = 0\n hi = low\n else:\n lo = low\n hi = high\n\n diff = hi - lo - 1\n if diff < 0:\n raise ValueError(\"low >= high\")\n \n if size is None:\n return rk_interval(diff, self.internal_state)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = lo + rk_interval(diff, self.internal_state)\n return array\n\n def bytes(self, unsigned int length):\n \"\"\"Return random bytes.\n\n bytes(length) -> str\n \"\"\"\n cdef void *bytes\n bytes = PyMem_Malloc(length)\n rk_fill(bytes, length, self.internal_state)\n bytestring = PyString_FromString(bytes)\n PyMem_Free(bytes)\n return bytestring\n\n def uniform(self, double low=0.0, double high=1.0, size=None):\n \"\"\"Uniform distribution over [low, high).\n\n uniform(low=0.0, high=1.0, size=None) -> random values\n \"\"\"\n return cont2_array(self.internal_state, rk_uniform, size, low, \n high-low)\n\n def rand(self, *args):\n \"\"\"Return an array of the given dimensions which is initialized to \n random numbers from a uniform distribution in the range [0,1).\n\n randn(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.random_sample()\n else:\n return self.random_sample(size=args)\n\n def randn(self, *args):\n \"\"\"Returns zero-mean, unit-variance Gaussian random numbers in an \n array of shape (d0, d1, ..., dn).\n\n randn(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.standard_normal()\n else:\n return self.standard_normal(args)\n\n def random_integers(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x <= high.\n\n random_integers(low, high=None, size=None) -> random values.\n\n If high is None, then 1 <= x <= low.\n \"\"\"\n if high is None:\n high = low\n low = 1\n return self.randint(low, high+1, size)\n\n # Complicated, continuous distributions:\n def standard_normal(self, size=None):\n \"\"\"Standard Normal distribution (mean=0, stdev=1).\n\n standard_normal(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_gauss, size)\n\n def normal(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Normal distribution (mean=loc, stdev=scale).\n\n normal(loc=0.0, scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_normal, size, loc, scale)\n\n def beta(self, double a, double b, size=None):\n \"\"\"Beta distribution over [0, 1].\n\n beta(a, b, size=None) -> random values\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n elif b <= 0:\n raise ValueError(\"b <= 0\")\n return cont2_array(self.internal_state, rk_beta, size, a, b)\n\n def exponential(self, double scale=1.0, size=None):\n \"\"\"Exponential distribution.\n\n exponential(scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont1_array(self.internal_state, rk_exponential, size, scale)\n\n def standard_exponential(self, size=None):\n \"\"\"Standard exponential distribution (scale=1).\n\n standard_exponential(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_exponential, size)\n\n def standard_gamma(self, double shape, size=None):\n \"\"\"Standard Gamma distribution.\n\n standard_gamma(shape, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n return cont1_array(self.internal_state, rk_standard_gamma, size, shape)\n\n def gamma(self, double shape, double scale=1.0, size=None):\n \"\"\"Gamma distribution.\n\n gamma(shape, scale=1.0, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n elif scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_gamma, size, shape, scale)\n\n def f(self, double dfnum, double dfden, size=None):\n \"\"\"F distribution.\n\n f(dfnum, dfden, size=None) -> random values\n \"\"\"\n if dfnum <= 0:\n raise ValueError(\"dfnum <= 0\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n return cont2_array(self.internal_state, rk_f, size, dfnum, dfden)\n\n def noncentral_f(self, double dfnum, double dfden, double nonc, size=None):\n \"\"\"Noncentral F distribution.\n\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\n \"\"\"\n if dfnum <= 1:\n raise ValueError(\"dfnum <= 1\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont3_array(self.internal_state, rk_noncentral_f, size, dfnum,\n dfden, nonc)\n\n def chisquare(self, double df, size=None):\n \"\"\"Chi^2 distribution.\n\n chisquare(df, size=None) -> random values\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_chisquare, size, df)\n\n def noncentral_chisquare(self, double df, double nonc, size=None):\n \"\"\"Noncentral Chi^2 distribution.\n\n noncentral_chisquare(df, nonc, size=None) -> random values\n \"\"\"\n if df <= 1:\n raise ValueError(\"df <= 1\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont2_array(self.internal_state, rk_noncentral_chisquare, size,\n df, nonc)\n \n def standard_cauchy(self, size=None):\n \"\"\"Standard Cauchy with mode=0.\n\n standard_cauchy(size=None)\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_cauchy, size)\n\n def standard_t(self, double df, size=None):\n \"\"\"Standard Student's t distribution with df degrees of freedom.\n\n standard_t(df, size=None)\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_standard_t, size, df)\n\n def vonmises(self, double mu, double kappa, size=None):\n \"\"\"von Mises circular distribution with mode mu and dispersion parameter\n kappa on [-pi, pi].\n\n vonmises(mu, kappa, size=None)\n \"\"\"\n if kappa < 0:\n raise ValueError(\"kappa < 0\")\n return cont2_array(self.internal_state, rk_vonmises, size, mu, kappa)\n\n def pareto(self, double a, size=None):\n \"\"\"Pareto distribution.\n\n pareto(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_pareto, size, a)\n\n def weibull(self, double a, size=None):\n \"\"\"Weibull distribution.\n\n weibull(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_weibull, size, a)\n\n def power(self, double a, size=None):\n \"\"\"Power distribution.\n\n power(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_power, size, a)\n\n def laplace(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Laplace distribution.\n \n laplace(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_laplace, size, loc, scale)\n \n def gumbel(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Gumbel distribution.\n \n gumbel(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_gumbel, size, loc, scale)\n \n def logistic(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Logistic distribution.\n \n logistic(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_logistic, size, loc, scale)\n\n def lognormal(self, double mean=0.0, double sigma=1.0, size=None):\n \"\"\"Log-normal distribution.\n \n Note that the mean parameter is not the mean of this distribution, but \n the underlying normal distribution.\n \n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\n \n lognormal(mean=0.0, sigma=1.0, size=None)\n \"\"\"\n if sigma <= 0.0:\n raise ValueError(\"sigma <= 0.0\")\n return cont2_array(self.internal_state, rk_lognormal, size, mean, sigma)\n \n def rayleigh(self, double mode, size=None):\n \"\"\"Rayleigh distribution.\n \n rayleigh(mode, size=None)\n \"\"\"\n if mode <= 0.0:\n raise ValueError(\"mode <= 0.0\")\n return cont1_array(self.internal_state, rk_rayleigh, size, mode)\n \n def wald(self, double mean, double scale, size=None):\n \"\"\"Wald (inverse Gaussian) distribution.\n \n wald(mean, scale, size=None)\n \"\"\"\n if mean <= 0.0:\n raise ValueError(\"mean <= 0.0\")\n elif scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_wald, size, mean, scale)\n\n def triangular(self, double left, double mode, double right, size=None):\n \"\"\"Triangular distribution starting at left, peaking at mode, and \n ending at right (left <= mode <= right).\n \n triangular(left, mode, right, size=None)\n \"\"\"\n if left > mode:\n raise ValueError(\"left > mode\")\n elif mode > right:\n raise ValueError(\"mode > right\")\n elif left == right:\n raise ValueError(\"left == right\")\n return cont3_array(self.internal_state, rk_triangular, size, left, \n mode, right)\n\n # Complicated, discrete distributions:\n def binomial(self, long n, double p, size=None):\n \"\"\"Binomial distribution of n trials and p probability of success.\n\n binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_binomial, size, n, p)\n\n def negative_binomial(self, long n, double p, size=None):\n \"\"\"Negative Binomial distribution.\n\n negative_binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_negative_binomial, size, n,\n p)\n\n def poisson(self, double lam=1.0, size=None):\n \"\"\"Poisson distribution.\n\n poisson(lam=1.0, size=None) -> random values\n \"\"\"\n if lam <= 0:\n raise ValueError(\"lam <= 0\")\n return discd_array(self.internal_state, rk_poisson, size, lam)\n\n def zipf(self, double a, size=None):\n \"\"\"Zipf distribution.\n \n zipf(a, size=None)\n \"\"\"\n if a <= 1.0:\n raise ValueError(\"a <= 1.0\")\n return discd_array(self.internal_state, rk_zipf, size, a)\n \n def geometric(self, double p, size=None):\n \"\"\"Geometric distribution with p being the probability of \"success\" on\n an individual trial.\n \n geometric(p, size=None)\n \"\"\"\n if p < 0.0:\n raise ValueError(\"p < 0.0\")\n elif p > 1.0:\n raise ValueError(\"p > 1.0\")\n return discd_array(self.internal_state, rk_geometric, size, p)\n \n def hypergeometric(self, long ngood, long nbad, long nsample, size=None):\n \"\"\"Hypergeometric distribution.\n \n Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one \n were to draw nsample balls from the urn without replacement, then \n the hypergeometric distribution describes the distribution of \"good\" \n balls in the sample.\n \n hypergeometric(ngood, nbad, nsample, size=None) \n \"\"\"\n if ngood < 1:\n raise ValueError(\"ngood < 1\")\n elif nbad < 1:\n raise ValueError(\"nbad < 1\")\n elif ngood + nbad < nsample:\n raise ValueError(\"ngood + nbad < nsample\")\n elif nsample < 1:\n raise ValueError(\"nsample < 1\")\n return discnmN_array(self.internal_state, rk_hypergeometric, size,\n ngood, nbad, nsample)\n\n # Multivariate distributions:\n def multivariate_normal(self, mean, cov, size=None):\n \"\"\"Return an array containing multivariate normally distributed random numbers\n with specified mean and covariance.\n\n multivariate_normal(mean, cov) -> random values\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\n\n mean must be a 1 dimensional array. cov must be a square two dimensional\n array with the same number of rows and columns as mean has elements.\n\n The first form returns a single 1-D array containing a multivariate\n normal.\n\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\n normal.\n \"\"\"\n # Check preconditions on arguments\n mean = _sp.array(mean)\n cov = _sp.array(cov)\n if size is None:\n shape = []\n else:\n shape = size\n if len(mean.shape) != 1:\n raise ArgumentError(\"mean must be 1 dimensional\")\n if (len(cov.shape) != 2) or (cov.shape[0] != cov.shape[1]):\n raise ArgumentError(\"cov must be 2 dimensional and square\")\n if mean.shape[0] != cov.shape[0]:\n raise ArgumentError(\"mean and cov must have same length\")\n # Compute shape of output\n if isinstance(shape, int):\n shape = [shape]\n final_shape = list(shape[:])\n final_shape.append(mean.shape[0])\n # Create a matrix of independent standard normally distributed random\n # numbers. The matrix has rows with the same length as mean and as\n # many rows are necessary to form a matrix of shape final_shape.\n x = standard_normal(_sp.multiply.reduce(final_shape))\n x.shape = (_sp.multiply.reduce(final_shape[0:len(final_shape)-1]),\n mean.shape[0])\n # Transform matrix of standard normals into matrix where each row\n # contains multivariate normals with the desired covariance.\n # Compute A such that matrixmultiply(transpose(A),A) == cov.\n # Then the matrix products of the rows of x and A has the desired\n # covariance. Note that sqrt(s)*v where (u,s,v) is the singular value\n # decomposition of cov is such an A.\n \n # XXX: we really should be doing this by Cholesky decomposition\n (u,s,v) = _sp.linalg.singular_value_decomposition(cov)\n x = _sp.matrixmultiply(x*_sp.sqrt(s),v)\n # The rows of x now have the correct covariance but mean 0. Add\n # mean to each row. Then each row will have mean mean.\n _sp.add(mean,x,x)\n x.shape = tuple(final_shape)\n return x\n\n def multinomial(self, long n, object pvals, size=None):\n \"\"\"Multinomial distribution.\n \n multinomial(n, pvals, size=None) -> random values\n\n pvals is a sequence of probabilities that should sum to 1 (however, the\n last element is always assumed to account for the remaining probability\n as long as sum(pvals[:-1]) <= 1).\n \"\"\"\n cdef long d\n cdef ArrayType parr, mnarr\n cdef double *pix\n cdef long *mnix\n cdef long i, j, dn\n cdef double Sum, prob\n\n d = len(pvals)\n parr = PyArray_ContiguousFromObject(pvals, PyArray_DOUBLE, 1, 1)\n pix = parr.data\n\n if kahan_sum(pix, d-1) > 1.0:\n raise ValueError(\"sum(pvals) > 1.0\")\n\n if size is None:\n shape = (d,)\n elif type(size) is int:\n shape = (size, d)\n else:\n shape = size + (d,)\n\n multin = _sp.zeros(shape, _sp.Int)\n mnarr = multin\n mnix = mnarr.data\n i = 0\n while i < PyArray_SIZE(mnarr):\n Sum = 1.0\n dn = n\n for j from 0 <= j < d-1:\n mnix[i+j] = rk_binomial(self.internal_state, dn, pix[j]/Sum)\n dn = dn - mnix[i+j]\n if dn <= 0:\n break\n Sum = Sum - pix[j]\n if dn > 0:\n mnix[i+d-1] = dn\n\n i = i + d\n\n return multin\n\n # Shuffling and permutations:\n def shuffle(self, object x):\n \"\"\"Modify a sequence in-place by shuffling its contents.\n \n shuffle(x)\n \"\"\"\n cdef long i, j\n\n # adaptation of random.shuffle()\n i = len(x) - 1\n while i > 0:\n j = rk_interval(i, self.internal_state)\n x[i], x[j] = x[j], x[i]\n i = i - 1\n \n def permutation(self, object x):\n \"\"\"Given an integer, return a shuffled sequence of integers >= 0 and \n < x.\n\n permutation(x)\n \"\"\"\n arr = _sp.arange(x)\n self.shuffle(arr)\n return arr\n\n\n_rand = RandomState()\nget_state = _rand.get_state\nset_state = _rand.set_state\nrandom_sample = _rand.random_sample\nrandint = _rand.randint\nbytes = _rand.bytes\nuniform = _rand.uniform\nrand = _rand.rand\nrandn = _rand.randn\nrandom_integers = _rand.random_integers\nstandard_normal = _rand.standard_normal\nnormal = _rand.normal\nbeta = _rand.beta\nexponential = _rand.exponential\nstandard_exponential = _rand.standard_exponential\nstandard_gamma = _rand.standard_gamma\ngamma = _rand.gamma\nf = _rand.f\nnoncentral_f = _rand.noncentral_f\nchisquare = _rand.chisquare\nnoncentral_chisquare = _rand.noncentral_chisquare\nstandard_cauchy = _rand.standard_cauchy\nstandard_t = _rand.standard_t\nvonmises = _rand.vonmises\npareto = _rand.pareto\nweibull = _rand.weibull\npower = _rand.power\nlaplace = _rand.laplace\ngumbel = _rand.gumbel\nlogistic = _rand.logistic\nlognormal = _rand.lognormal\nrayleigh = _rand.rayleigh\nwald = _rand.wald\ntriangular = _rand.triangular\n\nbinomial = _rand.binomial\nnegative_binomial = _rand.negative_binomial\npoisson = _rand.poisson\nzipf = _rand.zipf\ngeometric = _rand.geometric\nhypergeometric = _rand.hypergeometric\n\nmultivariate_normal = _rand.multivariate_normal\nmultinomial = _rand.multinomial\n\nshuffle = _rand.shuffle\npermutation = _rand.permutation\n", "source_code_before": "# mtrand.pyx -- A Pyrex wrapper of Jean-Sebastien Roy's RandomKit\n#\n# Copyright 2005 Robert Kern (robert.kern@gmail.com)\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n# \n# The above copyright notice and this permission notice shall be included\n# in all copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\ninclude \"Python.pxi\"\ninclude \"scipy.pxi\"\n\ncdef extern from \"math.h\":\n double exp(double x)\n double log(double x)\n double floor(double x)\n double sin(double x)\n double cos(double x)\n\ncdef extern from \"randomkit.h\":\n\n ctypedef struct rk_state:\n unsigned long key[624]\n int pos\n\n ctypedef enum rk_error:\n RK_NOERR = 0\n RK_ENODEV = 1\n RK_ERR_MAX = 2\n\n char *rk_strerror[2]\n \n # 0xFFFFFFFFUL\n unsigned long RK_MAX\n\n void rk_seed(unsigned long seed, rk_state *state)\n rk_error rk_randomseed(rk_state *state)\n unsigned long rk_random(rk_state *state)\n long rk_long(rk_state *state)\n unsigned long rk_ulong(rk_state *state)\n unsigned long rk_interval(unsigned long max, rk_state *state)\n double rk_double(rk_state *state)\n void rk_fill(void *buffer, size_t size, rk_state *state)\n rk_error rk_devfill(void *buffer, size_t size, int strong)\n rk_error rk_altfill(void *buffer, size_t size, int strong,\n rk_state *state)\n double rk_gauss(rk_state *state)\n\ncdef extern from \"distributions.h\":\n \n double rk_normal(rk_state *state, double loc, double scale)\n double rk_standard_exponential(rk_state *state)\n double rk_exponential(rk_state *state, double scale)\n double rk_uniform(rk_state *state, double loc, double scale)\n double rk_standard_gamma(rk_state *state, double shape)\n double rk_gamma(rk_state *state, double shape, double scale)\n double rk_beta(rk_state *state, double a, double b)\n double rk_chisquare(rk_state *state, double df)\n double rk_noncentral_chisquare(rk_state *state, double df, double nonc)\n double rk_f(rk_state *state, double dfnum, double dfden)\n double rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc)\n double rk_standard_cauchy(rk_state *state)\n double rk_standard_t(rk_state *state, double df)\n double rk_vonmises(rk_state *state, double mu, double kappa)\n double rk_pareto(rk_state *state, double a)\n double rk_weibull(rk_state *state, double a)\n double rk_power(rk_state *state, double a)\n long rk_binomial(rk_state *state, long n, double p)\n long rk_negative_binomial(rk_state *state, long n, double p)\n long rk_poisson(rk_state *state, double lam)\n\nctypedef double (* rk_cont0)(rk_state *state)\nctypedef double (* rk_cont1)(rk_state *state, double a)\nctypedef double (* rk_cont2)(rk_state *state, double a, double b)\nctypedef double (* rk_cont3)(rk_state *state, double a, double b, double c)\n\nctypedef long (* rk_disc0)(rk_state *state)\nctypedef long (* rk_discnp)(rk_state *state, long n, double p)\nctypedef long (* rk_discd)(rk_state *state, double a)\n\n\ncdef extern from \"initarray.h\":\n void init_by_array(rk_state *self, unsigned long *init_key, \n unsigned long key_length)\n\n# Initialize scipy\nimport_array()\n\nimport scipy\n\ncdef object cont0_array(rk_state *state, rk_cont0 func, object size):\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = scipy.empty(size, scipy.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object cont1_array(rk_state *state, rk_cont1 func, object size, double a):\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = scipy.empty(size, scipy.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef object cont2_array(rk_state *state, rk_cont2 func, object size, double a, \n double b):\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a, b)\n else:\n array = scipy.empty(size, scipy.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b)\n return array\n\ncdef object cont3_array(rk_state *state, rk_cont3 func, object size, double a, \n double b, double c):\n\n cdef double *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a, b, c)\n else:\n array = scipy.empty(size, scipy.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b, c)\n return array\n\ncdef object disc0_array(rk_state *state, rk_disc0 func, object size):\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = scipy.empty(size, scipy.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object discnp_array(rk_state *state, rk_discnp func, object size, long n, double p):\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, n, p)\n else:\n array = scipy.empty(size, scipy.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, p)\n return array\n\ncdef object discd_array(rk_state *state, rk_discd func, object size, double a):\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = scipy.empty(size, scipy.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef double kahan_sum(double *darr, long n):\n cdef double c, y, t, sum\n cdef long i\n sum = darr[0]\n c = 0.0\n for i from 1 <= i < n:\n y = darr[i] - c\n t = sum + y\n c = (t-sum) - y\n sum = t\n return sum\n\ncdef class RandomState:\n \"\"\"Container for the Mersenne Twister PRNG.\n\n Constructor\n -----------\n RandomState(seed=None): initializes the PRNG with the given seed. See the\n seed() method for details.\n\n Distribution Methods\n -----------------\n RandomState exposes a number of methods for generating random numbers drawn\n from a variety of probability distributions. In addition to the\n distribution-specific arguments, each method takes a keyword argument\n size=None. If size is None, then a single value is generated and returned.\n If size is an integer, then a 1-D scipy array filled with generated values\n is returned. If size is a tuple, then a scipy array with that shape is\n filled and returned.\n \"\"\"\n cdef rk_state *internal_state\n\n def __init__(self, seed=None):\n self.internal_state = PyMem_Malloc(sizeof(rk_state))\n\n self.seed(seed)\n\n def __dealloc__(self):\n if self.internal_state != NULL:\n PyMem_Free(self.internal_state)\n\n def seed(self, seed=None):\n \"\"\"Seed the generator.\n\n seed(seed=None)\n\n seed can be an integer, an array (or other sequence) of integers of any\n length, or None. If seed is None, then RandomState will try to read data\n from /dev/urandom (or the Windows analogue) if available or seed from\n the clock otherwise.\n \"\"\"\n cdef rk_error errcode\n cdef ArrayType obj\n if seed is None:\n errcode = rk_randomseed(self.internal_state)\n elif type(seed) is int:\n rk_seed(seed, self.internal_state)\n else:\n obj = PyArray_ContiguousFromObject(seed, PyArray_LONG, 1, 1)\n init_by_array(self.internal_state, (obj.data),\n obj.dimensions[0])\n\n def get_state(self):\n \"\"\"Return a tuple representing the internal state of the generator.\n\n get_state() -> ('MT19937', int key[624], int pos)\n \"\"\"\n cdef ArrayType state\n state = scipy.empty(624, scipy.Int)\n memcpy((state.data), self.internal_state.key, 624*sizeof(long))\n return ('MT19937', state, self.internal_state.pos)\n \n def set_state(self, state):\n \"\"\"Set the state from a tuple.\n \n state = ('MT19937', int key[624], int pos)\n \n set_state(state)\n \"\"\"\n cdef ArrayType obj\n cdef int pos\n algorithm_name = state[0]\n if algorithm_name != 'MT19937':\n raise ValueError(\"algorithm must be 'MT19937'\")\n key, pos = state[1:]\n obj = PyArray_ContiguousFromObject(key, PyArray_LONG, 1, 1)\n if obj.dimensions[0] != 624:\n raise ValueError(\"state must be 624 longs\")\n memcpy(self.internal_state.key, (obj.data), 624*sizeof(long))\n self.internal_state.pos = pos\n \n # Pickling support:\n def __getstate__(self):\n return self.get_state()\n\n def __setstate__(self, state):\n self.set_state(state)\n\n def __reduce__(self):\n return (scipy.stats.__RandomState_ctor, (), self.get_state())\n\n # Basic distributions:\n def random_sample(self, size=None):\n \"\"\"Return random floats in the half-open interval [0.0, 1.0).\n\n random_sample(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_double, size)\n\n def tomaxint(self, size=None):\n \"\"\"Returns random integers x such that 0 <= x <= sys.maxint.\n\n tomaxint(size=None) -> random values\n \"\"\"\n return disc0_array(self.internal_state, rk_long, size)\n\n def randint(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x < high.\n\n randint(low, high=None, size=None) -> random values\n\n If high is None, then 0 <= x < low.\n \"\"\"\n cdef long lo, hi, diff\n cdef long *array_data\n cdef ArrayType array\n cdef long length\n cdef long i\n\n if high is None:\n lo = 0\n hi = low\n else:\n lo = low\n hi = high\n\n diff = hi - lo - 1\n if diff < 0:\n raise ValueError(\"low >= high\")\n \n if size is None:\n return rk_interval(diff, self.internal_state)\n else:\n array = scipy.empty(size, scipy.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = lo + rk_interval(diff, self.internal_state)\n return array\n\n def bytes(self, unsigned int length):\n \"\"\"Return random bytes.\n\n bytes(length) -> str\n \"\"\"\n cdef void *bytes\n bytes = PyMem_Malloc(length)\n rk_fill(bytes, length, self.internal_state)\n bytestring = PyString_FromString(bytes)\n PyMem_Free(bytes)\n return bytestring\n\n def uniform(self, double low=0.0, double high=1.0, size=None):\n \"\"\"Uniform distribution over [low, high).\n\n uniform(low=0.0, high=1.0, size=None) -> random values\n \"\"\"\n return cont2_array(self.internal_state, rk_uniform, size, low, \n high-low)\n\n def rand(self, *args):\n \"\"\"Return an array of the given dimensions which is initialized to \n random numbers from a uniform distribution in the range [0,1).\n\n randn(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.random_sample()\n else:\n return self.random_sample(size=args)\n\n def randn(self, *args):\n \"\"\"Returns zero-mean, unit-variance Gaussian random numbers in an \n array of shape (d0, d1, ..., dn).\n\n randn(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.standard_normal()\n else:\n return self.standard_normal(args)\n\n def random_integers(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x <= high.\n\n random_integers(low, high=None, size=None) -> random values.\n\n If high is None, then 1 <= x <= low.\n \"\"\"\n if high is None:\n high = low\n low = 1\n return self.randint(low, high+1, size)\n\n # Complicated, continuous distributions:\n def standard_normal(self, size=None):\n \"\"\"Standard Normal distribution (mean=0, stdev=1).\n\n standard_normal(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_gauss, size)\n\n def normal(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Normal distribution (mean=loc, stdev=scale).\n\n normal(loc=0.0, scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_normal, size, loc, scale)\n\n def beta(self, double a, double b, size=None):\n \"\"\"Beta distribution over [0, 1].\n\n beta(a, b, size=None) -> random values\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n elif b <= 0:\n raise ValueError(\"b <= 0\")\n return cont2_array(self.internal_state, rk_beta, size, a, b)\n\n def exponential(self, double scale=1.0, size=None):\n \"\"\"Exponential distribution.\n\n exponential(scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont1_array(self.internal_state, rk_exponential, size, scale)\n\n def standard_exponential(self, size=None):\n \"\"\"Standard exponential distribution (scale=1).\n\n standard_exponential(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_exponential, size)\n\n def standard_gamma(self, double shape, size=None):\n \"\"\"Standard Gamma distribution.\n\n standard_gamma(shape, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n return cont1_array(self.internal_state, rk_standard_gamma, size, shape)\n\n def gamma(self, double shape, double scale=1.0, size=None):\n \"\"\"Gamma distribution.\n\n gamma(shape, scale=1.0, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n elif scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_gamma, size, shape, scale)\n\n def f(self, double dfnum, double dfden, size=None):\n \"\"\"F distribution.\n\n f(dfnum, dfden, size=None) -> random values\n \"\"\"\n if dfnum <= 0:\n raise ValueError(\"dfnum <= 0\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n return cont2_array(self.internal_state, rk_f, size, dfnum, dfden)\n\n def noncentral_f(self, double dfnum, double dfden, double nonc, size=None):\n \"\"\"Noncentral F distribution.\n\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\n \"\"\"\n if dfnum <= 1:\n raise ValueError(\"dfnum <= 1\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont3_array(self.internal_state, rk_noncentral_f, size, dfnum,\n dfden, nonc)\n\n def chisquare(self, double df, size=None):\n \"\"\"Chi^2 distribution.\n\n chisquare(df, size=None) -> random values\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_chisquare, size, df)\n\n def noncentral_chisquare(self, double df, double nonc, size=None):\n \"\"\"Noncentral Chi^2 distribution.\n\n noncentral_chisquare(df, nonc, size=None) -> random values\n \"\"\"\n if df <= 1:\n raise ValueError(\"df <= 1\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont2_array(self.internal_state, rk_noncentral_chisquare, size,\n df, nonc)\n \n def standard_cauchy(self, size=None):\n \"\"\"Standard Cauchy with mode=0.\n\n standard_cauchy(size=None)\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_cauchy, size)\n\n def standard_t(self, double df, size=None):\n \"\"\"Standard Student's t distribution with df degrees of freedom.\n\n standard_t(df, size=None)\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_standard_t, size, df)\n\n def vonmises(self, double mu, double kappa, size=None):\n \"\"\"von Mises circular distribution with mode mu and dispersion parameter\n kappa on [-pi, pi].\n\n vonmises(mu, kappa, size=None)\n \"\"\"\n if kappa < 0:\n raise ValueError(\"kappa < 0\")\n return cont2_array(self.internal_state, rk_vonmises, size, mu, kappa)\n\n def pareto(self, double a, size=None):\n \"\"\"Pareto distribution.\n\n pareto(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_pareto, size, a)\n\n def weibull(self, double a, size=None):\n \"\"\"Weibull distribution.\n\n weibull(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_weibull, size, a)\n\n def power(self, double a, size=None):\n \"\"\"Power distribution.\n\n power(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_power, size, a)\n\n # Complicated, discrete distributions:\n def binomial(self, long n, double p, size=None):\n \"\"\"Binomial distribution of n trials and p probability of success.\n\n binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_binomial, size, n, p)\n\n def negative_binomial(self, long n, double p, size=None):\n \"\"\"Negative Binomial distribution.\n\n negative_binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_negative_binomial, size, n,\n p)\n\n def poisson(self, double lam=1.0, size=None):\n \"\"\"Poisson distribution.\n\n poisson(lam=1.0, size=None) -> random values\n \"\"\"\n if lam <= 0:\n raise ValueError(\"lam <= 0\")\n return discd_array(self.internal_state, rk_poisson, size, lam)\n\n # Multivariate distributions:\n def multivariate_normal(self, mean, cov, size=None):\n \"\"\"Return an array containing multivariate normally distributed random numbers\n with specified mean and covariance.\n\n multivariate_normal(mean, cov) -> random values\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\n\n mean must be a 1 dimensional array. cov must be a square two dimensional\n array with the same number of rows and columns as mean has elements.\n\n The first form returns a single 1-D array containing a multivariate\n normal.\n\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\n normal.\n \"\"\"\n # Check preconditions on arguments\n mean = scipy.array(mean)\n cov = scipy.array(cov)\n if size is None:\n shape = []\n else:\n shape = size\n if len(mean.shape) != 1:\n raise ArgumentError(\"mean must be 1 dimensional\")\n if (len(cov.shape) != 2) or (cov.shape[0] != cov.shape[1]):\n raise ArgumentError(\"cov must be 2 dimensional and square\")\n if mean.shape[0] != cov.shape[0]:\n raise ArgumentError(\"mean and cov must have same length\")\n # Compute shape of output\n if isinstance(shape, int):\n shape = [shape]\n final_shape = list(shape[:])\n final_shape.append(mean.shape[0])\n # Create a matrix of independent standard normally distributed random\n # numbers. The matrix has rows with the same length as mean and as\n # many rows are necessary to form a matrix of shape final_shape.\n x = standard_normal(scipy.multiply.reduce(final_shape))\n x.shape = (scipy.multiply.reduce(final_shape[0:len(final_shape)-1]),\n mean.shape[0])\n # Transform matrix of standard normals into matrix where each row\n # contains multivariate normals with the desired covariance.\n # Compute A such that matrixmultiply(transpose(A),A) == cov.\n # Then the matrix products of the rows of x and A has the desired\n # covariance. Note that sqrt(s)*v where (u,s,v) is the singular value\n # decomposition of cov is such an A.\n (u,s,v) = scipy.linalg.singular_value_decomposition(cov)\n x = scipy.matrixmultiply(x*scipy.sqrt(s),v)\n # The rows of x now have the correct covariance but mean 0. Add\n # mean to each row. Then each row will have mean mean.\n scipy.add(mean,x,x)\n x.shape = tuple(final_shape)\n return x\n\n def multinomial(self, long n, object pvals, size=None):\n \"\"\"Multinomial distribution.\n \n multinomial(n, pvals, size=None) -> random values\n\n pvals is a sequence of probabilities that should sum to 1 (however, the\n last element is always assumed to account for the remaining probability\n as long as sum(pvals[:-1]) <= 1).\n \"\"\"\n cdef long d\n cdef ArrayType parr, mnarr\n cdef double *pix\n cdef long *mnix\n cdef long i, j, dn\n cdef double Sum, prob\n\n d = len(pvals)\n parr = PyArray_ContiguousFromObject(pvals, PyArray_DOUBLE, 1, 1)\n pix = parr.data\n\n if kahan_sum(pix, d-1) > 1.0:\n raise ValueError(\"sum(pvals) > 1.0\")\n\n if size is None:\n shape = (d,)\n elif type(size) is int:\n shape = (size, d)\n else:\n shape = size + (d,)\n\n multin = scipy.zeros(shape, scipy.Int)\n mnarr = multin\n mnix = mnarr.data\n i = 0\n while i < PyArray_SIZE(mnarr):\n Sum = 1.0\n dn = n\n for j from 0 <= j < d-1:\n mnix[i+j] = rk_binomial(self.internal_state, dn, pix[j]/Sum)\n dn = dn - mnix[i+j]\n if dn <= 0:\n break\n Sum = Sum - pix[j]\n if dn > 0:\n mnix[i+d-1] = dn\n\n i = i + d\n\n return multin\n\n # Shuffling and permutations:\n def shuffle(self, object x):\n \"\"\"Modify a sequence in-place by shuffling its contents.\n \n shuffle(x)\n \"\"\"\n cdef long i, j\n\n # adaptation of random.shuffle()\n i = len(x) - 1\n while i > 0:\n j = rk_interval(i, self.internal_state)\n x[i], x[j] = x[j], x[i]\n i = i - 1\n \n def permutation(self, object x):\n \"\"\"Given an integer, return a shuffled sequence of integers >= 0 and \n < x.\n\n permutation(x)\n \"\"\"\n arr = scipy.arange(x)\n self.shuffle(arr)\n return arr\n\n\n_rand = RandomState()\nget_state = _rand.get_state\nset_state = _rand.set_state\nrandom_sample = _rand.random_sample\nrandint = _rand.randint\nbytes = _rand.bytes\nuniform = _rand.uniform\nrand = _rand.rand\nrandn = _rand.randn\nrandom_integers = _rand.random_integers\nstandard_normal = _rand.standard_normal\nnormal = _rand.normal\nbeta = _rand.beta\nexponential = _rand.exponential\nstandard_exponential = _rand.standard_exponential\nstandard_gamma = _rand.standard_gamma\ngamma = _rand.gamma\nf = _rand.f\nnoncentral_f = _rand.noncentral_f\nchisquare = _rand.chisquare\nnoncentral_chisquare = _rand.noncentral_chisquare\nstandard_cauchy = _rand.standard_cauchy\nstandard_t = _rand.standard_t\nvonmises = _rand.vonmises\npareto = _rand.pareto\nweibull = _rand.weibull\npower = _rand.power\nbinomial = _rand.binomial\nnegative_binomial = _rand.negative_binomial\npoisson = _rand.poisson\nmultivariate_normal = _rand.multivariate_normal\nmultinomial = _rand.multinomial\nshuffle = _rand.shuffle\npermutation = _rand.permutation\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ " double rk_laplace(rk_state *state, double loc, double scale)", " double rk_gumbel(rk_state *state, double loc, double scale)", " double rk_logistic(rk_state *state, double loc, double scale)", " double rk_lognormal(rk_state *state, double mode, double sigma)", " double rk_rayleigh(rk_state *state, double mode)", " double rk_wald(rk_state *state, double mean, double scale)", " double rk_triangular(rk_state *state, double left, double mode, double right)", "", " long rk_zipf(rk_state *state, double a)", " long rk_geometric(rk_state *state, double p)", " long rk_hypergeometric(rk_state *state, long good, long bad, long sample)", "", "ctypedef long (* rk_discnmN)(rk_state *state, long n, long m, long N)", "import scipy as _sp", " array = _sp.empty(size, _sp.Float64)", " array = _sp.empty(size, _sp.Float64)", " array = _sp.empty(size, _sp.Float64)", " array = _sp.empty(size, _sp.Float64)", " array = _sp.empty(size, _sp.Int)", " array = _sp.empty(size, _sp.Int)", "cdef object discnmN_array(rk_state *state, rk_discnmN func, object size,", " long n, long m, long N):", " cdef long *array_data", " cdef ArrayType array", " cdef long length", " cdef long i", "", " if size is None:", " return func(state, n, m, N)", " else:", " array = _sp.empty(size, _sp.Int)", " length = PyArray_SIZE(array)", " array_data = array.data", " for i from 0 <= i < length:", " array_data[i] = func(state, n, m, N)", " return array", "", " array = _sp.empty(size, _sp.Int)", " state = _sp.empty(624, _sp.Int)", " return (_sp.stats.__RandomState_ctor, (), self.get_state())", " array = _sp.empty(size, _sp.Int)", " def laplace(self, double loc=0.0, double scale=1.0, size=None):", " \"\"\"Laplace distribution.", "", " laplace(loc=0.0, scale=1.0, size=None)", " \"\"\"", " if scale <= 0.0:", " raise ValueError(\"scale <= 0.0\")", " return cont2_array(self.internal_state, rk_laplace, size, loc, scale)", "", " def gumbel(self, double loc=0.0, double scale=1.0, size=None):", " \"\"\"Gumbel distribution.", "", " gumbel(loc=0.0, scale=1.0, size=None)", " \"\"\"", " if scale <= 0.0:", " raise ValueError(\"scale <= 0.0\")", " return cont2_array(self.internal_state, rk_gumbel, size, loc, scale)", "", " def logistic(self, double loc=0.0, double scale=1.0, size=None):", " \"\"\"Logistic distribution.", "", " logistic(loc=0.0, scale=1.0, size=None)", " \"\"\"", " if scale <= 0.0:", " raise ValueError(\"scale <= 0.0\")", " return cont2_array(self.internal_state, rk_logistic, size, loc, scale)", "", " def lognormal(self, double mean=0.0, double sigma=1.0, size=None):", " \"\"\"Log-normal distribution.", "", " Note that the mean parameter is not the mean of this distribution, but", " the underlying normal distribution.", "", " lognormal(mean, sigma) <=> exp(normal(mean, sigma))", "", " lognormal(mean=0.0, sigma=1.0, size=None)", " \"\"\"", " if sigma <= 0.0:", " raise ValueError(\"sigma <= 0.0\")", " return cont2_array(self.internal_state, rk_lognormal, size, mean, sigma)", "", " def rayleigh(self, double mode, size=None):", " \"\"\"Rayleigh distribution.", "", " rayleigh(mode, size=None)", " \"\"\"", " if mode <= 0.0:", " raise ValueError(\"mode <= 0.0\")", " return cont1_array(self.internal_state, rk_rayleigh, size, mode)", "", " def wald(self, double mean, double scale, size=None):", " \"\"\"Wald (inverse Gaussian) distribution.", "", " wald(mean, scale, size=None)", " \"\"\"", " if mean <= 0.0:", " raise ValueError(\"mean <= 0.0\")", " elif scale <= 0.0:", " raise ValueError(\"scale <= 0.0\")", " return cont2_array(self.internal_state, rk_wald, size, mean, scale)", "", " def triangular(self, double left, double mode, double right, size=None):", " \"\"\"Triangular distribution starting at left, peaking at mode, and", " ending at right (left <= mode <= right).", "", " triangular(left, mode, right, size=None)", " \"\"\"", " if left > mode:", " raise ValueError(\"left > mode\")", " elif mode > right:", " raise ValueError(\"mode > right\")", " elif left == right:", " raise ValueError(\"left == right\")", " return cont3_array(self.internal_state, rk_triangular, size, left,", " mode, right)", "", " def zipf(self, double a, size=None):", " \"\"\"Zipf distribution.", "", " zipf(a, size=None)", " \"\"\"", " if a <= 1.0:", " raise ValueError(\"a <= 1.0\")", " return discd_array(self.internal_state, rk_zipf, size, a)", "", " def geometric(self, double p, size=None):", " \"\"\"Geometric distribution with p being the probability of \"success\" on", " an individual trial.", "", " geometric(p, size=None)", " \"\"\"", " if p < 0.0:", " raise ValueError(\"p < 0.0\")", " elif p > 1.0:", " raise ValueError(\"p > 1.0\")", " return discd_array(self.internal_state, rk_geometric, size, p)", "", " def hypergeometric(self, long ngood, long nbad, long nsample, size=None):", " \"\"\"Hypergeometric distribution.", "", " Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one", " were to draw nsample balls from the urn without replacement, then", " the hypergeometric distribution describes the distribution of \"good\"", " balls in the sample.", "", " hypergeometric(ngood, nbad, nsample, size=None)", " \"\"\"", " if ngood < 1:", " raise ValueError(\"ngood < 1\")", " elif nbad < 1:", " raise ValueError(\"nbad < 1\")", " elif ngood + nbad < nsample:", " raise ValueError(\"ngood + nbad < nsample\")", " elif nsample < 1:", " raise ValueError(\"nsample < 1\")", " return discnmN_array(self.internal_state, rk_hypergeometric, size,", " ngood, nbad, nsample)", "", " mean = _sp.array(mean)", " cov = _sp.array(cov)", " x = standard_normal(_sp.multiply.reduce(final_shape))", " x.shape = (_sp.multiply.reduce(final_shape[0:len(final_shape)-1]),", "", " # XXX: we really should be doing this by Cholesky decomposition", " (u,s,v) = _sp.linalg.singular_value_decomposition(cov)", " x = _sp.matrixmultiply(x*_sp.sqrt(s),v)", " _sp.add(mean,x,x)", " multin = _sp.zeros(shape, _sp.Int)", " arr = _sp.arange(x)", "laplace = _rand.laplace", "gumbel = _rand.gumbel", "logistic = _rand.logistic", "lognormal = _rand.lognormal", "rayleigh = _rand.rayleigh", "wald = _rand.wald", "triangular = _rand.triangular", "", "zipf = _rand.zipf", "geometric = _rand.geometric", "hypergeometric = _rand.hypergeometric", "", "" ], "deleted": [ "", "import scipy", " array = scipy.empty(size, scipy.Float64)", " array = scipy.empty(size, scipy.Float64)", " array = scipy.empty(size, scipy.Float64)", " array = scipy.empty(size, scipy.Float64)", " array = scipy.empty(size, scipy.Int)", " array = scipy.empty(size, scipy.Int)", " array = scipy.empty(size, scipy.Int)", " state = scipy.empty(624, scipy.Int)", " return (scipy.stats.__RandomState_ctor, (), self.get_state())", " array = scipy.empty(size, scipy.Int)", " mean = scipy.array(mean)", " cov = scipy.array(cov)", " x = standard_normal(scipy.multiply.reduce(final_shape))", " x.shape = (scipy.multiply.reduce(final_shape[0:len(final_shape)-1]),", " (u,s,v) = scipy.linalg.singular_value_decomposition(cov)", " x = scipy.matrixmultiply(x*scipy.sqrt(s),v)", " scipy.add(mean,x,x)", " multin = scipy.zeros(shape, scipy.Int)", " arr = scipy.arange(x)" ] } }, { "old_path": "scipy/stats/__init__.py", "new_path": "scipy/stats/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -11,5 +11,3 @@ def __RandomState_ctor():\n This function exists solely to assist (un)pickling.\n \"\"\"\n return RandomState()\n-\n-del scipy\n", "added_lines": 0, "deleted_lines": 2, "source_code": "from scipy.lib.mtrand import *\n\n# Some aliases:\nranf = random_sample\nrandom = random_sample\nsample = random_sample\n\ndef __RandomState_ctor():\n \"\"\"Return a RandomState instance.\n \n This function exists solely to assist (un)pickling.\n \"\"\"\n return RandomState()\n", "source_code_before": "from scipy.lib.mtrand import *\n\n# Some aliases:\nranf = random_sample\nrandom = random_sample\nsample = random_sample\n\ndef __RandomState_ctor():\n \"\"\"Return a RandomState instance.\n \n This function exists solely to assist (un)pickling.\n \"\"\"\n return RandomState()\n\ndel scipy\n", "methods": [ { "name": "__RandomState_ctor", "long_name": "__RandomState_ctor( )", "filename": "__init__.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 8, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__RandomState_ctor", "long_name": "__RandomState_ctor( )", "filename": "__init__.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 8, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 6, "complexity": 1, "token_count": 27, "diff_parsed": { "added": [], "deleted": [ "", "del scipy" ] } } ] }, { "hash": "df3bc1b9d5c55964edfebe61452ca61124fad287", "msg": "Added helper.py from scipy.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-07T05:32:15+00:00", "author_timezone": 0, "committer_date": "2005-10-07T05:32:15+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "04a98ff28bceccd16622a99f2b7780cd86376470" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 0, "insertions": 83, "lines": 83, "files": 2, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy/fftpack/__init__.py", "new_path": "scipy/fftpack/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -37,3 +37,4 @@\n rfft2 = real_fft2d\n irfft2 = inverse_real_fft2d\n \n+from helper import *\n", "added_lines": 1, "deleted_lines": 0, "source_code": "\"\"\"\nDiscrete Fourier Transforms - FFT.py \n\nThe underlying code for these functions is an f2c translated and modified\nversion of the FFTPACK routines.\n\nfft(a, n=None, axis=-1) \ninverse_fft(a, n=None, axis=-1) \nreal_fft(a, n=None, axis=-1) \ninverse_real_fft(a, n=None, axis=-1)\nhermite_fft(a, n=None, axis=-1)\ninverse_hermite_fft(a, n=None, axis=-1)\nfftnd(a, s=None, axes=None)\ninverse_fftnd(a, s=None, axes=None)\nreal_fftnd(a, s=None, axes=None)\ninverse_real_fftnd(a, s=None, axes=None)\nfft2d(a, s=None, axes=(-2,-1)) \ninverse_fft2d(a, s=None, axes=(-2, -1))\nreal_fft2d(a, s=None, axes=(-2,-1)) \ninverse_real_fft2d(a, s=None, axes=(-2, -1))\n\"\"\"\nfrom fft_lite import *\n\nifft = inverse_fft\nrfft = real_fft\nirfft = inverse_real_fft\nhfft = hermite_fft\nihfft = inverse_hermite_fft\n\nfftn = fftnd\nifftn = inverse_fftnd\nrfftn = real_fftnd\nirfftn = inverse_real_fftnd\n\nfft2 = fft2d\nifft2 = inverse_fft2d\nrfft2 = real_fft2d\nirfft2 = inverse_real_fft2d\n\nfrom helper import *\n", "source_code_before": "\"\"\"\nDiscrete Fourier Transforms - FFT.py \n\nThe underlying code for these functions is an f2c translated and modified\nversion of the FFTPACK routines.\n\nfft(a, n=None, axis=-1) \ninverse_fft(a, n=None, axis=-1) \nreal_fft(a, n=None, axis=-1) \ninverse_real_fft(a, n=None, axis=-1)\nhermite_fft(a, n=None, axis=-1)\ninverse_hermite_fft(a, n=None, axis=-1)\nfftnd(a, s=None, axes=None)\ninverse_fftnd(a, s=None, axes=None)\nreal_fftnd(a, s=None, axes=None)\ninverse_real_fftnd(a, s=None, axes=None)\nfft2d(a, s=None, axes=(-2,-1)) \ninverse_fft2d(a, s=None, axes=(-2, -1))\nreal_fft2d(a, s=None, axes=(-2,-1)) \ninverse_real_fft2d(a, s=None, axes=(-2, -1))\n\"\"\"\nfrom fft_lite import *\n\nifft = inverse_fft\nrfft = real_fft\nirfft = inverse_real_fft\nhfft = hermite_fft\nihfft = inverse_hermite_fft\n\nfftn = fftnd\nifftn = inverse_fftnd\nrfftn = real_fftnd\nirfftn = inverse_real_fftnd\n\nfft2 = fft2d\nifft2 = inverse_fft2d\nrfft2 = real_fft2d\nirfft2 = inverse_real_fft2d\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 36, "complexity": 0, "token_count": 48, "diff_parsed": { "added": [ "from helper import *" ], "deleted": [] } }, { "old_path": null, "new_path": "scipy/fftpack/helper.py", "filename": "helper.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,82 @@\n+\"\"\"\n+Discrete Fourier Transforms - helper.py\n+\"\"\"\n+# Created by Pearu Peterson, September 2002\n+\n+__all__ = ['fftshift','ifftshift','fftfreq','rfftfreq']\n+\n+from scipy.base import asarray, concatenate, arange, take, \\\n+\t\tarray, integer\n+import types\n+\n+def fftshift(x,axes=None):\n+ \"\"\" fftshift(x, axes=None) -> y\n+\n+ Shift zero-frequency component to center of spectrum.\n+\n+ This function swaps half-spaces for all axes listed (defaults to all).\n+\n+ Notes:\n+ If len(x) is even then the Nyquist component is y[0].\n+ \"\"\"\n+ tmp = asarray(x)\n+ ndim = len(tmp.shape)\n+ if axes is None:\n+ axes = range(ndim)\n+ y = tmp\n+ for k in axes:\n+ n = tmp.shape[k]\n+ p2 = (n+1)/2\n+ mylist = concatenate((arange(p2,n),arange(p2)))\n+ y = take(y,mylist,k)\n+ return y\n+\n+\n+def ifftshift(x,axes=None):\n+ \"\"\" ifftshift(x,axes=None) - > y\n+\n+ Inverse of fftshift.\n+ \"\"\"\n+ tmp = asarray(x)\n+ ndim = len(tmp.shape)\n+ if axes is None:\n+ axes = range(ndim)\n+ y = tmp\n+ for k in axes:\n+ n = tmp.shape[k]\n+ p2 = n-(n+1)/2\n+ mylist = concatenate((arange(p2,n),arange(p2)))\n+ y = take(y,mylist,k)\n+ return y\n+\n+def fftfreq(n,d=1.0):\n+ \"\"\" fftfreq(n, d=1.0) -> f\n+\n+ DFT sample frequencies\n+\n+ The returned float array contains the frequency bins in\n+ cycles/unit (with zero at the start) given a window length n and a\n+ sample spacing d:\n+\n+ f = [0,1,...,n/2-1,-n/2,...,-1]/(d*n) if n is even\n+ f = [0,1,...,(n-1)/2,-(n-1)/2,...,-1]/(d*n) if n is odd\n+ \"\"\"\n+ assert isinstance(n,types.IntType)\n+ k = range(0,(n-1)/2+1)+range(-(n/2),0)\n+ return array(k,'d')/(n*d)\n+\n+def rfftfreq(n,d=1.0):\n+ \"\"\" rfftfreq(n, d=1.0) -> f\n+\n+ DFT sample frequencies (for usage with rfft,irfft).\n+\n+ The returned float array contains the frequency bins in\n+ cycles/unit (with zero at the start) given a window length n and a\n+ sample spacing d:\n+\n+ f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2]/(d*n) if n is even\n+ f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2,n/2]/(d*n) if n is odd\n+ \"\"\"\n+ assert isinstance(n,types.IntType) or isinstance(n,integer)\n+ return array(range(1,n+1),'i')/2/float(n*d)\n+\n", "added_lines": 82, "deleted_lines": 0, "source_code": "\"\"\"\nDiscrete Fourier Transforms - helper.py\n\"\"\"\n# Created by Pearu Peterson, September 2002\n\n__all__ = ['fftshift','ifftshift','fftfreq','rfftfreq']\n\nfrom scipy.base import asarray, concatenate, arange, take, \\\n\t\tarray, integer\nimport types\n\ndef fftshift(x,axes=None):\n \"\"\" fftshift(x, axes=None) -> y\n\n Shift zero-frequency component to center of spectrum.\n\n This function swaps half-spaces for all axes listed (defaults to all).\n\n Notes:\n If len(x) is even then the Nyquist component is y[0].\n \"\"\"\n tmp = asarray(x)\n ndim = len(tmp.shape)\n if axes is None:\n axes = range(ndim)\n y = tmp\n for k in axes:\n n = tmp.shape[k]\n p2 = (n+1)/2\n mylist = concatenate((arange(p2,n),arange(p2)))\n y = take(y,mylist,k)\n return y\n\n\ndef ifftshift(x,axes=None):\n \"\"\" ifftshift(x,axes=None) - > y\n\n Inverse of fftshift.\n \"\"\"\n tmp = asarray(x)\n ndim = len(tmp.shape)\n if axes is None:\n axes = range(ndim)\n y = tmp\n for k in axes:\n n = tmp.shape[k]\n p2 = n-(n+1)/2\n mylist = concatenate((arange(p2,n),arange(p2)))\n y = take(y,mylist,k)\n return y\n\ndef fftfreq(n,d=1.0):\n \"\"\" fftfreq(n, d=1.0) -> f\n\n DFT sample frequencies\n\n The returned float array contains the frequency bins in\n cycles/unit (with zero at the start) given a window length n and a\n sample spacing d:\n\n f = [0,1,...,n/2-1,-n/2,...,-1]/(d*n) if n is even\n f = [0,1,...,(n-1)/2,-(n-1)/2,...,-1]/(d*n) if n is odd\n \"\"\"\n assert isinstance(n,types.IntType)\n k = range(0,(n-1)/2+1)+range(-(n/2),0)\n return array(k,'d')/(n*d)\n\ndef rfftfreq(n,d=1.0):\n \"\"\" rfftfreq(n, d=1.0) -> f\n\n DFT sample frequencies (for usage with rfft,irfft).\n\n The returned float array contains the frequency bins in\n cycles/unit (with zero at the start) given a window length n and a\n sample spacing d:\n\n f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2]/(d*n) if n is even\n f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2,n/2]/(d*n) if n is odd\n \"\"\"\n assert isinstance(n,types.IntType) or isinstance(n,integer)\n return array(range(1,n+1),'i')/2/float(n*d)\n\n", "source_code_before": null, "methods": [ { "name": "fftshift", "long_name": "fftshift( x , axes = None )", "filename": "helper.py", "nloc": 12, "complexity": 3, "token_count": 90, "parameters": [ "x", "axes" ], "start_line": 12, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "ifftshift", "long_name": "ifftshift( x , axes = None )", "filename": "helper.py", "nloc": 12, "complexity": 3, "token_count": 92, "parameters": [ "x", "axes" ], "start_line": 35, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "fftfreq", "long_name": "fftfreq( n , d = 1 . 0 )", "filename": "helper.py", "nloc": 4, "complexity": 1, "token_count": 62, "parameters": [ "n", "d" ], "start_line": 52, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "rfftfreq", "long_name": "rfftfreq( n , d = 1 . 0 )", "filename": "helper.py", "nloc": 3, "complexity": 2, "token_count": 51, "parameters": [ "n", "d" ], "start_line": 68, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "rfftfreq", "long_name": "rfftfreq( n , d = 1 . 0 )", "filename": "helper.py", "nloc": 3, "complexity": 2, "token_count": 51, "parameters": [ "n", "d" ], "start_line": 68, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "fftshift", "long_name": "fftshift( x , axes = None )", "filename": "helper.py", "nloc": 12, "complexity": 3, "token_count": 90, "parameters": [ "x", "axes" ], "start_line": 12, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "fftfreq", "long_name": "fftfreq( n , d = 1 . 0 )", "filename": "helper.py", "nloc": 4, "complexity": 1, "token_count": 62, "parameters": [ "n", "d" ], "start_line": 52, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "ifftshift", "long_name": "ifftshift( x , axes = None )", "filename": "helper.py", "nloc": 12, "complexity": 3, "token_count": 92, "parameters": [ "x", "axes" ], "start_line": 35, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "nloc": 38, "complexity": 9, "token_count": 330, "diff_parsed": { "added": [ "\"\"\"", "Discrete Fourier Transforms - helper.py", "\"\"\"", "# Created by Pearu Peterson, September 2002", "", "__all__ = ['fftshift','ifftshift','fftfreq','rfftfreq']", "", "from scipy.base import asarray, concatenate, arange, take, \\", "\t\tarray, integer", "import types", "", "def fftshift(x,axes=None):", " \"\"\" fftshift(x, axes=None) -> y", "", " Shift zero-frequency component to center of spectrum.", "", " This function swaps half-spaces for all axes listed (defaults to all).", "", " Notes:", " If len(x) is even then the Nyquist component is y[0].", " \"\"\"", " tmp = asarray(x)", " ndim = len(tmp.shape)", " if axes is None:", " axes = range(ndim)", " y = tmp", " for k in axes:", " n = tmp.shape[k]", " p2 = (n+1)/2", " mylist = concatenate((arange(p2,n),arange(p2)))", " y = take(y,mylist,k)", " return y", "", "", "def ifftshift(x,axes=None):", " \"\"\" ifftshift(x,axes=None) - > y", "", " Inverse of fftshift.", " \"\"\"", " tmp = asarray(x)", " ndim = len(tmp.shape)", " if axes is None:", " axes = range(ndim)", " y = tmp", " for k in axes:", " n = tmp.shape[k]", " p2 = n-(n+1)/2", " mylist = concatenate((arange(p2,n),arange(p2)))", " y = take(y,mylist,k)", " return y", "", "def fftfreq(n,d=1.0):", " \"\"\" fftfreq(n, d=1.0) -> f", "", " DFT sample frequencies", "", " The returned float array contains the frequency bins in", " cycles/unit (with zero at the start) given a window length n and a", " sample spacing d:", "", " f = [0,1,...,n/2-1,-n/2,...,-1]/(d*n) if n is even", " f = [0,1,...,(n-1)/2,-(n-1)/2,...,-1]/(d*n) if n is odd", " \"\"\"", " assert isinstance(n,types.IntType)", " k = range(0,(n-1)/2+1)+range(-(n/2),0)", " return array(k,'d')/(n*d)", "", "def rfftfreq(n,d=1.0):", " \"\"\" rfftfreq(n, d=1.0) -> f", "", " DFT sample frequencies (for usage with rfft,irfft).", "", " The returned float array contains the frequency bins in", " cycles/unit (with zero at the start) given a window length n and a", " sample spacing d:", "", " f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2]/(d*n) if n is even", " f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2,n/2]/(d*n) if n is odd", " \"\"\"", " assert isinstance(n,types.IntType) or isinstance(n,integer)", " return array(range(1,n+1),'i')/2/float(n*d)", "" ], "deleted": [] } } ] }, { "hash": "2b5ac629732cf3438cd4f538d550b7bd059dc0db", "msg": "Fixed up fftpack a bit. Don't want to conflict with scipy's use of rfft.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-07T06:54:42+00:00", "author_timezone": 0, "committer_date": "2005-10-07T06:54:42+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "df3bc1b9d5c55964edfebe61452ca61124fad287" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 10, "insertions": 10, "lines": 20, "files": 2, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/base/shape_base.py", "new_path": "scipy/base/shape_base.py", "filename": "shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -99,7 +99,7 @@ def apply_over_axes(func, a, axes):\n return val\n \n def expand_dims(a, axis):\n- \"\"\"Expand the shape of a by including NewAxis before given axis.\n+ \"\"\"Expand the shape of a by including newaxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n@@ -152,7 +152,7 @@ def atleast_2d(*arys):\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n- result = ary[NewAxis,:]\n+ result = ary[newaxis,:]\n else: \n result = ary\n res.append(result)\n@@ -182,9 +182,9 @@ def atleast_3d(*arys):\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n- result = ary[NewAxis,:,NewAxis]\n+ result = ary[newaxis,:,newaxis]\n elif len(ary.shape) == 2:\n- result = ary[:,:,NewAxis]\n+ result = ary[:,:,newaxis]\n else: \n result = ary\n res.append(result)\n", "added_lines": 4, "deleted_lines": 4, "source_code": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i.tolist())] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n outarr[tuple(i.tolist())] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including newaxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[newaxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[newaxis,:,newaxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,newaxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "source_code_before": "import numeric as _nx\nfrom numeric import *\n\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n arr = asarray(arr)\n nd = arr.ndim\n if axis < 0:\n axis += nd\n if (axis >= nd):\n raise ValueError(\"axis must be less than arr.ndim; axis=%d, rank=%d.\" \n % (axis,nd))\n ind = [0]*(nd-1)\n dims = arr.shape\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = asarray(arr.shape).take(indlist)\n i.put(indlist, ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).dtypechar)\n outarr[tuple(i.tolist())] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n i.put(indlist,ind)\n res = func1d(arr[tuple(i.tolist())],*args)\n outarr[tuple(i.tolist())] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function repeatedly over multiple axes, keeping the same shape\n for the resulting array.\n\n func is called as res = func(a, axis). The result is assumed\n to be either the same shape as a or have one less dimension.\n This call is repeated for each axis in the axes sequence.\n \"\"\"\n val = asarray(a)\n N = a.ndim\n if array(axes).ndim == 0:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n res = func(*args)\n if res.ndim == val.ndim:\n val = res\n else:\n res = expand_dims(res,axis)\n if res.ndim == val.ndim:\n val = res\n else:\n raise ValueError, \"function is not returning\"\\\n \" an array of correct shape\"\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n return a.reshape(shape[:axis] + (1,) + shape[axis:])\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n return asarray(a).squeeze()\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = ary.reshape(1)\n res.append(ary)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1)\n elif len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n result = ary.reshape(1,1,1)\n elif len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return _nx.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.column_stack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(_nx.transpose,map(atleast_2d,tup))\n return _nx.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return _nx.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(_nx.shape(sub_arys[i])) == 0:\n sub_arys[i] = _nx.array([])\n elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]),0)):\n sub_arys[i] = _nx.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = _nx.array(section_sizes).cumsum()\n\n sub_arys = []\n sary = _nx.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(_nx.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(_nx.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 424, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "methods_before": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 54, "complexity": 10, "token_count": 424, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 11, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 19, "complexity": 6, "token_count": 110, "parameters": [ "func", "a", "axes" ], "start_line": 74, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 11, "complexity": 4, "token_count": 63, "parameters": [ "arys" ], "start_line": 114, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 197, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 228, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 255, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 278, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 187, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 315, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 379, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 422, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 464, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 506, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 88, "parameters": [ "arys" ], "start_line": 137, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 112, "parameters": [ "arys" ], "start_line": 164, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "nloc": 196, "complexity": 57, "token_count": 1466, "diff_parsed": { "added": [ " \"\"\"Expand the shape of a by including newaxis before given axis.", " result = ary[newaxis,:]", " result = ary[newaxis,:,newaxis]", " result = ary[:,:,newaxis]" ], "deleted": [ " \"\"\"Expand the shape of a by including NewAxis before given axis.", " result = ary[NewAxis,:]", " result = ary[NewAxis,:,NewAxis]", " result = ary[:,:,NewAxis]" ] } }, { "old_path": "scipy/fftpack/__init__.py", "new_path": "scipy/fftpack/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -22,19 +22,19 @@\n from fft_lite import *\n \n ifft = inverse_fft\n-rfft = real_fft\n-irfft = inverse_real_fft\n+refft = real_fft\n+irefft = inverse_real_fft\n hfft = hermite_fft\n ihfft = inverse_hermite_fft\n \n fftn = fftnd\n ifftn = inverse_fftnd\n-rfftn = real_fftnd\n-irfftn = inverse_real_fftnd\n+refftn = real_fftnd\n+irefftn = inverse_real_fftnd\n \n fft2 = fft2d\n ifft2 = inverse_fft2d\n-rfft2 = real_fft2d\n-irfft2 = inverse_real_fft2d\n+refft2 = real_fft2d\n+irefft2 = inverse_real_fft2d\n \n from helper import *\n", "added_lines": 6, "deleted_lines": 6, "source_code": "\"\"\"\nDiscrete Fourier Transforms - FFT.py \n\nThe underlying code for these functions is an f2c translated and modified\nversion of the FFTPACK routines.\n\nfft(a, n=None, axis=-1) \ninverse_fft(a, n=None, axis=-1) \nreal_fft(a, n=None, axis=-1) \ninverse_real_fft(a, n=None, axis=-1)\nhermite_fft(a, n=None, axis=-1)\ninverse_hermite_fft(a, n=None, axis=-1)\nfftnd(a, s=None, axes=None)\ninverse_fftnd(a, s=None, axes=None)\nreal_fftnd(a, s=None, axes=None)\ninverse_real_fftnd(a, s=None, axes=None)\nfft2d(a, s=None, axes=(-2,-1)) \ninverse_fft2d(a, s=None, axes=(-2, -1))\nreal_fft2d(a, s=None, axes=(-2,-1)) \ninverse_real_fft2d(a, s=None, axes=(-2, -1))\n\"\"\"\nfrom fft_lite import *\n\nifft = inverse_fft\nrefft = real_fft\nirefft = inverse_real_fft\nhfft = hermite_fft\nihfft = inverse_hermite_fft\n\nfftn = fftnd\nifftn = inverse_fftnd\nrefftn = real_fftnd\nirefftn = inverse_real_fftnd\n\nfft2 = fft2d\nifft2 = inverse_fft2d\nrefft2 = real_fft2d\nirefft2 = inverse_real_fft2d\n\nfrom helper import *\n", "source_code_before": "\"\"\"\nDiscrete Fourier Transforms - FFT.py \n\nThe underlying code for these functions is an f2c translated and modified\nversion of the FFTPACK routines.\n\nfft(a, n=None, axis=-1) \ninverse_fft(a, n=None, axis=-1) \nreal_fft(a, n=None, axis=-1) \ninverse_real_fft(a, n=None, axis=-1)\nhermite_fft(a, n=None, axis=-1)\ninverse_hermite_fft(a, n=None, axis=-1)\nfftnd(a, s=None, axes=None)\ninverse_fftnd(a, s=None, axes=None)\nreal_fftnd(a, s=None, axes=None)\ninverse_real_fftnd(a, s=None, axes=None)\nfft2d(a, s=None, axes=(-2,-1)) \ninverse_fft2d(a, s=None, axes=(-2, -1))\nreal_fft2d(a, s=None, axes=(-2,-1)) \ninverse_real_fft2d(a, s=None, axes=(-2, -1))\n\"\"\"\nfrom fft_lite import *\n\nifft = inverse_fft\nrfft = real_fft\nirfft = inverse_real_fft\nhfft = hermite_fft\nihfft = inverse_hermite_fft\n\nfftn = fftnd\nifftn = inverse_fftnd\nrfftn = real_fftnd\nirfftn = inverse_real_fftnd\n\nfft2 = fft2d\nifft2 = inverse_fft2d\nrfft2 = real_fft2d\nirfft2 = inverse_real_fft2d\n\nfrom helper import *\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 36, "complexity": 0, "token_count": 48, "diff_parsed": { "added": [ "refft = real_fft", "irefft = inverse_real_fft", "refftn = real_fftnd", "irefftn = inverse_real_fftnd", "refft2 = real_fft2d", "irefft2 = inverse_real_fft2d" ], "deleted": [ "rfft = real_fft", "irfft = inverse_real_fft", "rfftn = real_fftnd", "irfftn = inverse_real_fftnd", "rfft2 = real_fft2d", "irfft2 = inverse_real_fft2d" ] } } ] }, { "hash": "061e5e4477a21844b84321776938e002dfbe8748", "msg": "Fixed up add_library for a bit.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2005-10-07T07:19:13+00:00", "author_timezone": 0, "committer_date": "2005-10-07T07:19:13+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "2b5ac629732cf3438cd4f538d550b7bd059dc0db" ], "project_name": "repo_copy", "project_path": "/tmp/tmp3hw3eti3/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy/distutils/misc_util.py", "new_path": "scipy/distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -597,7 +597,7 @@ def add_library(self,name,sources,**build_info):\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n- name = name + '__OF__' + self.name\n+ name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n \n for k in build_info.keys():\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport types\nimport glob\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" Return path of the module.\n\n Returned path is relative to parent_path when given,\n otherwise it is absolute path.\n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n __import__(mod_name)\n mod = sys.modules[mod_name]\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d or '.'\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if type(item) is not types.StringType:\n return False\n return True\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob.glob(os.path.join(dir,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if type(directory) is not type(''):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef _gsf_visit_func(filenames,dirname,names):\n if os.path.basename(dirname) in ['CVS','.svn','build']:\n names[:] = []\n return\n for name in names:\n if name[-1] in \"~#\":\n continue\n fullname = os.path.join(dirname,name)\n ext = os.path.splitext(fullname)[1]\n if ext and ext in ['.pyc','.o']:\n continue\n if os.path.isfile(fullname):\n filenames.append(fullname)\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(lambda s:type(s) is types.StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(lambda s:type(s) is types.StringType,scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(lambda s:type(s) is types.StringType,sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = build_info.get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if type(data) is types.StringType:\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n s = s()\n if s is None:\n continue\n if is_local_src_dir(s):\n os.path.walk(s,_gsf_visit_func,filenames)\n elif type(s) is type('') and os.path.isfile(s):\n filenames.append(s)\n else:\n raise TypeError,`s`\n return filenames\n\ndef dot_join(*args):\n return '.'.join(filter(None,args))\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration:\n\n _list_keys = ['packages','ext_modules','data_files','include_dirs',\n 'libraries','headers','scripts']\n _dict_keys = ['package_dir']\n\n scipy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(1)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n \n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(os.path.join(self.local_path,package_path)):\n package_path = os.path.join(self.local_path,package_path)\n self.top_path = top_path\n\n self.list_keys = copy.copy(self._list_keys)\n self.dict_keys = copy.copy(self._dict_keys)\n\n for n in self.list_keys:\n setattr(self,n,copy.copy(attrs.get(n,[])))\n\n for n in self.dict_keys:\n setattr(self,n,copy.copy(attrs.get(n,{})))\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if type(a) is types.ListType:\n self.list_keys.append(n)\n elif type(a) is types.DictType:\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(os.path.join(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path \n return\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def __dict__(self):\n return self.todict()\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution \n return dist\n\n def get_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Return subpackage configuration.\n \"\"\"\n if subpackage_name is None:\n assert subpackage_path is not None\n subpackage_name = os.path.basename(subpackage_path)\n assert '.' not in subpackage_name,`subpackage_name`\n if subpackage_path is None:\n subpackage_path = os.path.join(self.local_path,subpackage_name)\n else:\n subpackage_path = self._fix_paths([subpackage_path])[0]\n\n setup_py = os.path.join(subpackage_path,'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n setup_py = os.path.join(subpackage_path,'setup.py')\n if not os.path.isfile(setup_py):\n print 'Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py),subpackage_name)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n info = (open(setup_py),setup_py,('.py','U',1))\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),*info)\n\n if not hasattr(setup_module,'configuration'):\n print 'Assuming default configuration '\\\n '(%s does not define configuration())' % (setup_module)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n args = (self.name,)\n if setup_module.configuration.func_code.co_argcount>1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n\n finally:\n del sys.path[0]\n\n return config\n\n def add_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n config = self.get_subpackage(subpackage_name,subpackage_path)\n\n if not config:\n print 'No configuration returned, assuming unavailable.'\n else:\n\n if isinstance(config,Configuration):\n print 'Appending %s configuration to %s' % (config.name,self.name)\n self.dict_append(**config.todict())\n else:\n print 'Appending %s configuration to %s' % (config.get('name'),self.name)\n self.dict_append(**config)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a subpackage', subpackage_name\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Add files under data_path to data_files list.\n \"\"\"\n for path in self.paths(data_path):\n filenames = []\n os.path.walk(path, _gsf_visit_func,filenames)\n if not os.path.isabs(path):\n self.add_data_files((path,filenames))\n else:\n self.add_data_files(*filenames)\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir suffix defaults\n to package dir.\n If path is not absolute then it's datadir suffix is\n package dir + dirname of the path.\n \"\"\"\n data_dict = {}\n for p in files:\n if type(p) is type(''):\n d = os.path.join(*(self.name.split('.')))\n file_list = self.paths(p)\n if not os.path.isabs(p):\n d = appendpath(d,os.path.dirname(p))\n elif type(p) is type(()):\n assert len(p)==2,`p`\n d = p[0]\n if type(p[1]) is type(''):\n file_list = self.paths(p[1])\n else:\n file_list = self.paths(*p[1])\n else:\n # function\n d = os.path.join(*(self.name.split('.')))\n file_list = [p]\n if not data_dict.has_key(d):\n data_dict[d] = file_list[:]\n else:\n data_dict[d].extend(file_list)\n\n dist = self.get_distribution()\n if dist is not None:\n dist.data_files.extend(data_dict.items())\n else:\n self.data_files.extend(data_dict.items())\n\n return \n \n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self._fix_paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if type(path) is type(''):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n assert type(path) in [type(()),type([])] and len(path)==2,`path`\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def _fix_paths(self,paths):\n new_paths = []\n for n in paths:\n if isinstance(n,str):\n if '*' in n or '?' in n:\n p = glob.glob(n)\n p2 = glob.glob(os.path.join(self.local_path,n))\n if p2:\n new_paths.extend(p2)\n elif p:\n new_paths.extend(p)\n else:\n new_paths.append(n)\n else:\n n2 = os.path.join(self.local_path,n)\n if os.path.exists(n2):\n new_paths.append(n2)\n else:\n new_paths.append(n)\n else:\n new_paths.append(n)\n return new_paths\n\n def paths(self,*paths):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n return self._fix_paths(paths)\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if type(extra_info) is type({}):\n extra_info = [extra_info]\n for info in extra_info:\n assert type(info) is type({}),`info`\n dict_append(ext_args,**info)\n\n for k in ext_args.keys():\n v = ext_args[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(os.path.join(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from scipy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add an extension', name\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n \n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n for k in build_info.keys():\n v = build_info[k]\n if k in ['sources','depends']:\n new_v = self._fix_paths(v)\n build_info[k] = new_v\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a library', name\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self._fix_paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n print 'Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?'))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %r\\n' % (k,a)\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if type(extlib) is type(()):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from scipy.distutils.core import Extension\n assert isinstance(extlib,Extension),`extlib`\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = os.path.join(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = os.path.join(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n print msg\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = os.path.join(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n print 'Creating %s (version=%r)' % (target,version)\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n \n import atexit\n def rm_file(f=target):\n try: os.remove(f); print 'removed',f\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(generate_svn_version_py)\n return\n\ndef get_cmd(cmdname,_cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError,\\\n 'setup distribution instance not initialized'\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_scipy_include_dirs():\n include_dirs = Configuration.scipy_include_dirs[:]\n if not include_dirs:\n import scipy.base as base\n include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))\n #from distutils.sysconfig import get_python_inc\n #prefix = []\n #for name in scipy.__file__.split(os.sep):\n # if name=='lib':\n # break\n # prefix.append(name)\n #include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n return include_dirs\n\n#########################\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n if os.path.join(absprefix[:len(d)],absprefix[len(d):])!=absprefix \\\n or os.path.join(path[:len(d)],path[len(d):])!=path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(os.path.join(prefix, subpath))\n\ndef generate_config_py(extension, build_dir):\n \"\"\" Generate /config.py file containing system_info\n information used during building the package.\n\n Usage:\\\n ext = Extension(dot_join(config['name'],'config'),\n sources=[generate_config_py])\n config['ext_modules'].append(ext)\n \"\"\"\n from scipy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n target = os.path.join(*([build_dir]+extension.name.split('.'))) + '.py'\n mkpath(os.path.dirname(target))\n f = open(target,'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k,i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k,i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n\ndef generate_svn_version_py(extension, build_dir):\n \"\"\" Generate __svn_version__.py file containing SVN\n revision number of a module.\n \n To use, add the following codelet to setup\n configuration(..) function\n\n ext = Extension(dot_join(config['name'],'__svn_version__'),\n sources=[generate_svn_version_py])\n ext.local_path = local_path\n config['ext_modules'].append(ext)\n\n \"\"\"\n from distutils import dep_util\n local_path = extension.local_path\n target = os.path.join(build_dir, '__svn_version__.py')\n entries = os.path.join(local_path,'.svn','entries')\n if os.path.isfile(entries):\n if not dep_util.newer(entries, target):\n return target\n elif os.path.isfile(target):\n return target\n\n revision = get_svn_revision(local_path)\n f = open(target,'w')\n f.write('revision=%s\\n' % (revision))\n f.close()\n return target\n", "source_code_before": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport types\nimport glob\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" Return path of the module.\n\n Returned path is relative to parent_path when given,\n otherwise it is absolute path.\n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n __import__(mod_name)\n mod = sys.modules[mod_name]\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d or '.'\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if sys.platform=='cygwin' and not os.environ.has_key('USE_COLOR'):\n # Avoid importing curses that causes illegal operation\n # with a message:\n # PYTHON2 caused an invalid page fault in\n # module CYGNURSES7.DLL as 015f:18bbfc28\n # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]\n # ssh to Win32 machine from debian\n # curses.version is 2.2\n # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))\n return 0\n if hasattr(sys.stdout,'isatty') and sys.stdout.isatty(): \n try:\n import curses\n curses.setupterm()\n if (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if type(item) is not types.StringType:\n return False\n return True\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source) \n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob.glob(os.path.join(dir,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if type(directory) is not type(''):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef _gsf_visit_func(filenames,dirname,names):\n if os.path.basename(dirname) in ['CVS','.svn','build']:\n names[:] = []\n return\n for name in names:\n if name[-1] in \"~#\":\n continue\n fullname = os.path.join(dirname,name)\n ext = os.path.splitext(fullname)[1]\n if ext and ext in ['.pyc','.o']:\n continue\n if os.path.isfile(fullname):\n filenames.append(fullname)\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(lambda s:type(s) is types.StringType,ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(lambda s:type(s) is types.StringType,scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(lambda s:type(s) is types.StringType,sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = build_info.get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n os.path.walk(d,_gsf_visit_func,filenames)\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if type(data) is types.StringType:\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n s = s()\n if s is None:\n continue\n if is_local_src_dir(s):\n os.path.walk(s,_gsf_visit_func,filenames)\n elif type(s) is type('') and os.path.isfile(s):\n filenames.append(s)\n else:\n raise TypeError,`s`\n return filenames\n\ndef dot_join(*args):\n return '.'.join(filter(None,args))\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration:\n\n _list_keys = ['packages','ext_modules','data_files','include_dirs',\n 'libraries','headers','scripts']\n _dict_keys = ['package_dir']\n\n scipy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(1)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n \n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(os.path.join(self.local_path,package_path)):\n package_path = os.path.join(self.local_path,package_path)\n self.top_path = top_path\n\n self.list_keys = copy.copy(self._list_keys)\n self.dict_keys = copy.copy(self._dict_keys)\n\n for n in self.list_keys:\n setattr(self,n,copy.copy(attrs.get(n,[])))\n\n for n in self.dict_keys:\n setattr(self,n,copy.copy(attrs.get(n,{})))\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if type(a) is types.ListType:\n self.list_keys.append(n)\n elif type(a) is types.DictType:\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(os.path.join(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path \n return\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def __dict__(self):\n return self.todict()\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution \n return dist\n\n def get_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Return subpackage configuration.\n \"\"\"\n if subpackage_name is None:\n assert subpackage_path is not None\n subpackage_name = os.path.basename(subpackage_path)\n assert '.' not in subpackage_name,`subpackage_name`\n if subpackage_path is None:\n subpackage_path = os.path.join(self.local_path,subpackage_name)\n else:\n subpackage_path = self._fix_paths([subpackage_path])[0]\n\n setup_py = os.path.join(subpackage_path,'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n setup_py = os.path.join(subpackage_path,'setup.py')\n if not os.path.isfile(setup_py):\n print 'Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py),subpackage_name)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n info = (open(setup_py),setup_py,('.py','U',1))\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),*info)\n\n if not hasattr(setup_module,'configuration'):\n print 'Assuming default configuration '\\\n '(%s does not define configuration())' % (setup_module)\n config = Configuration(subpackage_name,self.name,\n self.top_path,subpackage_path)\n else:\n args = (self.name,)\n if setup_module.configuration.func_code.co_argcount>1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n\n finally:\n del sys.path[0]\n\n return config\n\n def add_subpackage(self,subpackage_name,subpackage_path=None):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n config = self.get_subpackage(subpackage_name,subpackage_path)\n\n if not config:\n print 'No configuration returned, assuming unavailable.'\n else:\n\n if isinstance(config,Configuration):\n print 'Appending %s configuration to %s' % (config.name,self.name)\n self.dict_append(**config.todict())\n else:\n print 'Appending %s configuration to %s' % (config.get('name'),self.name)\n self.dict_append(**config)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a subpackage', subpackage_name\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Add files under data_path to data_files list.\n \"\"\"\n for path in self.paths(data_path):\n filenames = []\n os.path.walk(path, _gsf_visit_func,filenames)\n if not os.path.isabs(path):\n self.add_data_files((path,filenames))\n else:\n self.add_data_files(*filenames)\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir suffix defaults\n to package dir.\n If path is not absolute then it's datadir suffix is\n package dir + dirname of the path.\n \"\"\"\n data_dict = {}\n for p in files:\n if type(p) is type(''):\n d = os.path.join(*(self.name.split('.')))\n file_list = self.paths(p)\n if not os.path.isabs(p):\n d = appendpath(d,os.path.dirname(p))\n elif type(p) is type(()):\n assert len(p)==2,`p`\n d = p[0]\n if type(p[1]) is type(''):\n file_list = self.paths(p[1])\n else:\n file_list = self.paths(*p[1])\n else:\n # function\n d = os.path.join(*(self.name.split('.')))\n file_list = [p]\n if not data_dict.has_key(d):\n data_dict[d] = file_list[:]\n else:\n data_dict[d].extend(file_list)\n\n dist = self.get_distribution()\n if dist is not None:\n dist.data_files.extend(data_dict.items())\n else:\n self.data_files.extend(data_dict.items())\n\n return \n \n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self._fix_paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if type(path) is type(''):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n assert type(path) in [type(()),type([])] and len(path)==2,`path`\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def _fix_paths(self,paths):\n new_paths = []\n for n in paths:\n if isinstance(n,str):\n if '*' in n or '?' in n:\n p = glob.glob(n)\n p2 = glob.glob(os.path.join(self.local_path,n))\n if p2:\n new_paths.extend(p2)\n elif p:\n new_paths.extend(p)\n else:\n new_paths.append(n)\n else:\n n2 = os.path.join(self.local_path,n)\n if os.path.exists(n2):\n new_paths.append(n2)\n else:\n new_paths.append(n)\n else:\n new_paths.append(n)\n return new_paths\n\n def paths(self,*paths):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n return self._fix_paths(paths)\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if type(extra_info) is type({}):\n extra_info = [extra_info]\n for info in extra_info:\n assert type(info) is type({}),`info`\n dict_append(ext_args,**info)\n\n for k in ext_args.keys():\n v = ext_args[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self._fix_paths(v)\n ext_args[k] = new_v\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(os.path.join(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from scipy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add an extension', name\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n \n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name + '__OF__' + self.name\n build_info['sources'] = sources\n\n for k in build_info.keys():\n v = build_info[k]\n if k in ['sources','depends']:\n new_v = self._fix_paths(v)\n build_info[k] = new_v\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n print 'distutils distribution has been initialized, it may be too late to add a library', name\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self._fix_paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n print 'Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?'))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %r\\n' % (k,a)\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if type(extlib) is type(()):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from scipy.distutils.core import Extension\n assert isinstance(extlib,Extension),`extlib`\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = os.path.join(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = os.path.join(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n print msg\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = os.path.join(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n print 'Creating %s (version=%r)' % (target,version)\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n \n import atexit\n def rm_file(f=target):\n try: os.remove(f); print 'removed',f\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(generate_svn_version_py)\n return\n\ndef get_cmd(cmdname,_cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError,\\\n 'setup distribution instance not initialized'\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_scipy_include_dirs():\n include_dirs = Configuration.scipy_include_dirs[:]\n if not include_dirs:\n import scipy.base as base\n include_dirs.append(os.path.join(os.path.dirname(base.__file__),'include'))\n #from distutils.sysconfig import get_python_inc\n #prefix = []\n #for name in scipy.__file__.split(os.sep):\n # if name=='lib':\n # break\n # prefix.append(name)\n #include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n return include_dirs\n\n#########################\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n if os.path.join(absprefix[:len(d)],absprefix[len(d):])!=absprefix \\\n or os.path.join(path[:len(d)],path[len(d):])!=path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(os.path.join(prefix, subpath))\n\ndef generate_config_py(extension, build_dir):\n \"\"\" Generate /config.py file containing system_info\n information used during building the package.\n\n Usage:\\\n ext = Extension(dot_join(config['name'],'config'),\n sources=[generate_config_py])\n config['ext_modules'].append(ext)\n \"\"\"\n from scipy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n target = os.path.join(*([build_dir]+extension.name.split('.'))) + '.py'\n mkpath(os.path.dirname(target))\n f = open(target,'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k,i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k,i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n\ndef generate_svn_version_py(extension, build_dir):\n \"\"\" Generate __svn_version__.py file containing SVN\n revision number of a module.\n \n To use, add the following codelet to setup\n configuration(..) function\n\n ext = Extension(dot_join(config['name'],'__svn_version__'),\n sources=[generate_svn_version_py])\n ext.local_path = local_path\n config['ext_modules'].append(ext)\n\n \"\"\"\n from distutils import dep_util\n local_path = extension.local_path\n target = os.path.join(build_dir, '__svn_version__.py')\n entries = os.path.join(local_path,'.svn','entries')\n if os.path.isfile(entries):\n if not dep_util.newer(entries, target):\n return target\n elif os.path.isfile(target):\n return target\n\n revision = get_svn_revision(local_path)\n f = open(target,'w')\n f.write('revision=%s\\n' % (revision))\n f.close()\n return target\n", "methods": [ { "name": "allpath", "long_name": "allpath( name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "name" ], "start_line": 9, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 129, "parameters": [ "mod_name", "parent_path" ], "start_line": 14, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 38, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "cyg2win32", "long_name": "cyg2win32( path )", "filename": "misc_util.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "path" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_get_f90_modules", "long_name": "_get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "all_strings", "long_name": "all_strings( lst )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [ "lst" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 117, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 124, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 131, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_get_headers", "long_name": "_get_headers( directory_list )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "directory_list" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_get_directories", "long_name": "_get_directories( list_of_sources )", "filename": "misc_util.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 162, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_dependencies", "long_name": "get_dependencies( sources )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "sources" ], "start_line": 171, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "misc_util.py", "nloc": 12, "complexity": 6, "token_count": 112, "parameters": [ "directory" ], "start_line": 175, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "_gsf_visit_func", "long_name": "_gsf_visit_func( filenames , dirname , names )", "filename": "misc_util.py", "nloc": 13, "complexity": 7, "token_count": 103, "parameters": [ "filenames", "dirname", "names" ], "start_line": 190, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_ext_source_files", "long_name": "get_ext_source_files( ext )", "filename": "misc_util.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "ext" ], "start_line": 204, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "get_script_files", "long_name": "get_script_files( scripts )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "scripts" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_lib_source_files", "long_name": "get_lib_source_files( lib )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 108, "parameters": [ "lib" ], "start_line": 221, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_data_files", "long_name": "get_data_files( data )", "filename": "misc_util.py", "nloc": 17, "complexity": 8, "token_count": 105, "parameters": [ "data" ], "start_line": 235, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "args" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 256, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , ** attrs )", "filename": "misc_util.py", "nloc": 40, "complexity": 11, "token_count": 335, "parameters": [ "self", "package_name", "parent_name", "top_path", "package_path", "attrs" ], "start_line": 275, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 1 }, { "name": "todict", "long_name": "todict( self )", "filename": "misc_util.py", "nloc": 9, "complexity": 4, "token_count": 57, "parameters": [ "self" ], "start_line": 325, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__dict__", "long_name": "__dict__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_distribution", "long_name": "get_distribution( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 341, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_subpackage", "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 38, "complexity": 8, "token_count": 333, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 346, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "add_subpackage", "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 392, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "add_data_dir", "long_name": "add_data_dir( self , data_path )", "filename": "misc_util.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "data_path" ], "start_line": 413, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "add_data_files", "long_name": "add_data_files( self , * files )", "filename": "misc_util.py", "nloc": 28, "complexity": 8, "token_count": 247, "parameters": [ "self", "files" ], "start_line": 425, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "add_include_dirs", "long_name": "add_include_dirs( self , * paths )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "paths" ], "start_line": 465, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "add_headers", "long_name": "add_headers( self , * files )", "filename": "misc_util.py", "nloc": 14, "complexity": 7, "token_count": 143, "parameters": [ "self", "files" ], "start_line": 476, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_fix_paths", "long_name": "_fix_paths( self , paths )", "filename": "misc_util.py", "nloc": 22, "complexity": 8, "token_count": 136, "parameters": [ "self", "paths" ], "start_line": 497, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "paths", "long_name": "paths( self , * paths )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "paths" ], "start_line": 520, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 45, "complexity": 14, "token_count": 365, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , name , sources , ** build_info )", "filename": "misc_util.py", "nloc": 14, "complexity": 4, "token_count": 98, "parameters": [ "self", "name", "sources", "build_info" ], "start_line": 589, "end_line": 613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "add_scripts", "long_name": "add_scripts( self , * files )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "files" ], "start_line": 615, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "dict_append", "long_name": "dict_append( self , ** dict )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 138, "parameters": [ "self", "dict" ], "start_line": 626, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 642, "end_line": 651, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_config_cmd", "long_name": "get_config_cmd( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 2, "token_count": 63, "parameters": [ "self" ], "start_line": 653, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_build_temp_dir", "long_name": "get_build_temp_dir( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 664, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "have_f77c", "long_name": "have_f77c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 669, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "have_f90c", "long_name": "have_f90c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 682, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "append_to", "long_name": "append_to( self , extlib )", "filename": "misc_util.py", "nloc": 12, "complexity": 2, "token_count": 83, "parameters": [ "self", "extlib" ], "start_line": 695, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_get_svn_revision", "long_name": "_get_svn_revision( self , path )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 77, "parameters": [ "self", "path" ], "start_line": 710, "end_line": 721, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "misc_util.py", "nloc": 38, "complexity": 11, "token_count": 257, "parameters": [ "self" ], "start_line": 723, "end_line": 769, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target )", "filename": "misc_util.py", "nloc": 3, "complexity": 2, "token_count": 24, "parameters": [ "f" ], "start_line": 793, "end_line": 795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 3 }, { "name": "make_svn_version_py.generate_svn_version_py", "long_name": "make_svn_version_py.generate_svn_version_py( )", "filename": "misc_util.py", "nloc": 13, "complexity": 2, "token_count": 81, "parameters": [], "start_line": 782, "end_line": 798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 2 }, { "name": "make_svn_version_py", "long_name": "make_svn_version_py( self )", "filename": "misc_util.py", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 771, "end_line": 801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_cmd", "long_name": "get_cmd( cmdname , _cache = { } )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 65, "parameters": [ "cmdname", "_cache" ], "start_line": 803, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "get_scipy_include_dirs", "long_name": "get_scipy_include_dirs( )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [], "start_line": 815, "end_line": 827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 831, "end_line": 836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "misc_util.py", "nloc": 13, "complexity": 5, "token_count": 157, "parameters": [ "prefix", "path" ], "start_line": 838, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "generate_config_py", "long_name": "generate_config_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 28, "complexity": 2, "token_count": 145, "parameters": [ "extension", "build_dir" ], "start_line": 853, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "generate_svn_version_py", "long_name": "generate_svn_version_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 109, "parameters": [ "extension", "build_dir" ], "start_line": 891, "end_line": 918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "methods_before": [ { "name": "allpath", "long_name": "allpath( name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "name" ], "start_line": 9, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 129, "parameters": [ "mod_name", "parent_path" ], "start_line": 14, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 18, "complexity": 13, "token_count": 137, "parameters": [], "start_line": 38, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "cyg2win32", "long_name": "cyg2win32( path )", "filename": "misc_util.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "path" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "_get_f90_modules", "long_name": "_get_f90_modules( source )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 77, "parameters": [ "source" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "all_strings", "long_name": "all_strings( lst )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [ "lst" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_f_sources", "long_name": "has_f_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 117, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( sources )", "filename": "misc_util.py", "nloc": 5, "complexity": 3, "token_count": 21, "parameters": [ "sources" ], "start_line": 124, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "filter_sources", "long_name": "filter_sources( sources )", "filename": "misc_util.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [ "sources" ], "start_line": 131, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "_get_headers", "long_name": "_get_headers( directory_list )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "directory_list" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "_get_directories", "long_name": "_get_directories( list_of_sources )", "filename": "misc_util.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 162, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_dependencies", "long_name": "get_dependencies( sources )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "sources" ], "start_line": 171, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "is_local_src_dir", "long_name": "is_local_src_dir( directory )", "filename": "misc_util.py", "nloc": 12, "complexity": 6, "token_count": 112, "parameters": [ "directory" ], "start_line": 175, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "_gsf_visit_func", "long_name": "_gsf_visit_func( filenames , dirname , names )", "filename": "misc_util.py", "nloc": 13, "complexity": 7, "token_count": 103, "parameters": [ "filenames", "dirname", "names" ], "start_line": 190, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_ext_source_files", "long_name": "get_ext_source_files( ext )", "filename": "misc_util.py", "nloc": 11, "complexity": 4, "token_count": 87, "parameters": [ "ext" ], "start_line": 204, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "get_script_files", "long_name": "get_script_files( scripts )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "scripts" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_lib_source_files", "long_name": "get_lib_source_files( lib )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 108, "parameters": [ "lib" ], "start_line": 221, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "get_data_files", "long_name": "get_data_files( data )", "filename": "misc_util.py", "nloc": 17, "complexity": 8, "token_count": 105, "parameters": [ "data" ], "start_line": 235, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "args" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 256, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , ** attrs )", "filename": "misc_util.py", "nloc": 40, "complexity": 11, "token_count": 335, "parameters": [ "self", "package_name", "parent_name", "top_path", "package_path", "attrs" ], "start_line": 275, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 1 }, { "name": "todict", "long_name": "todict( self )", "filename": "misc_util.py", "nloc": 9, "complexity": 4, "token_count": 57, "parameters": [ "self" ], "start_line": 325, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__dict__", "long_name": "__dict__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_distribution", "long_name": "get_distribution( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 341, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_subpackage", "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 38, "complexity": 8, "token_count": 333, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 346, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "add_subpackage", "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 103, "parameters": [ "self", "subpackage_name", "subpackage_path" ], "start_line": 392, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "add_data_dir", "long_name": "add_data_dir( self , data_path )", "filename": "misc_util.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "data_path" ], "start_line": 413, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "add_data_files", "long_name": "add_data_files( self , * files )", "filename": "misc_util.py", "nloc": 28, "complexity": 8, "token_count": 247, "parameters": [ "self", "files" ], "start_line": 425, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "add_include_dirs", "long_name": "add_include_dirs( self , * paths )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "paths" ], "start_line": 465, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "add_headers", "long_name": "add_headers( self , * files )", "filename": "misc_util.py", "nloc": 14, "complexity": 7, "token_count": 143, "parameters": [ "self", "files" ], "start_line": 476, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_fix_paths", "long_name": "_fix_paths( self , paths )", "filename": "misc_util.py", "nloc": 22, "complexity": 8, "token_count": 136, "parameters": [ "self", "paths" ], "start_line": 497, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "paths", "long_name": "paths( self , * paths )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "paths" ], "start_line": 520, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "add_extension", "long_name": "add_extension( self , name , sources , ** kw )", "filename": "misc_util.py", "nloc": 45, "complexity": 14, "token_count": 365, "parameters": [ "self", "name", "sources", "kw" ], "start_line": 525, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , name , sources , ** build_info )", "filename": "misc_util.py", "nloc": 14, "complexity": 4, "token_count": 104, "parameters": [ "self", "name", "sources", "build_info" ], "start_line": 589, "end_line": 613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "add_scripts", "long_name": "add_scripts( self , * files )", "filename": "misc_util.py", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "self", "files" ], "start_line": 615, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "dict_append", "long_name": "dict_append( self , ** dict )", "filename": "misc_util.py", "nloc": 15, "complexity": 6, "token_count": 138, "parameters": [ "self", "dict" ], "start_line": 626, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 642, "end_line": 651, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_config_cmd", "long_name": "get_config_cmd( self )", "filename": "misc_util.py", "nloc": 10, "complexity": 2, "token_count": 63, "parameters": [ "self" ], "start_line": 653, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_build_temp_dir", "long_name": "get_build_temp_dir( self )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 664, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "have_f77c", "long_name": "have_f77c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 669, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "have_f90c", "long_name": "have_f90c( self )", "filename": "misc_util.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 682, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "append_to", "long_name": "append_to( self , extlib )", "filename": "misc_util.py", "nloc": 12, "complexity": 2, "token_count": 83, "parameters": [ "self", "extlib" ], "start_line": 695, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_get_svn_revision", "long_name": "_get_svn_revision( self , path )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 77, "parameters": [ "self", "path" ], "start_line": 710, "end_line": 721, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "misc_util.py", "nloc": 38, "complexity": 11, "token_count": 257, "parameters": [ "self" ], "start_line": 723, "end_line": 769, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target )", "filename": "misc_util.py", "nloc": 3, "complexity": 2, "token_count": 24, "parameters": [ "f" ], "start_line": 793, "end_line": 795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 3 }, { "name": "make_svn_version_py.generate_svn_version_py", "long_name": "make_svn_version_py.generate_svn_version_py( )", "filename": "misc_util.py", "nloc": 13, "complexity": 2, "token_count": 81, "parameters": [], "start_line": 782, "end_line": 798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 2 }, { "name": "make_svn_version_py", "long_name": "make_svn_version_py( self )", "filename": "misc_util.py", "nloc": 7, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 771, "end_line": 801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_cmd", "long_name": "get_cmd( cmdname , _cache = { } )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 65, "parameters": [ "cmdname", "_cache" ], "start_line": 803, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "get_scipy_include_dirs", "long_name": "get_scipy_include_dirs( )", "filename": "misc_util.py", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [], "start_line": 815, "end_line": 827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 831, "end_line": 836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "misc_util.py", "nloc": 13, "complexity": 5, "token_count": 157, "parameters": [ "prefix", "path" ], "start_line": 838, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "generate_config_py", "long_name": "generate_config_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 28, "complexity": 2, "token_count": 145, "parameters": [ "extension", "build_dir" ], "start_line": 853, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "generate_svn_version_py", "long_name": "generate_svn_version_py( extension , build_dir )", "filename": "misc_util.py", "nloc": 15, "complexity": 4, "token_count": 109, "parameters": [ "extension", "build_dir" ], "start_line": 891, "end_line": 918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "add_library", "long_name": "add_library( self , name , sources , ** build_info )", "filename": "misc_util.py", "nloc": 14, "complexity": 4, "token_count": 98, "parameters": [ "self", "name", "sources", "build_info" ], "start_line": 589, "end_line": 613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "nloc": 681, "complexity": 215, "token_count": 5029, "diff_parsed": { "added": [ " name = name #+ '__OF__' + self.name" ], "deleted": [ " name = name + '__OF__' + self.name" ] } } ] } ]