{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "reference:c-api:ufunc",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "ufunc API"
        }
      ],
      "level": 0,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "UFUNC_{THING}_{ERR}"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Deprecated, use "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "NPY_{THING}_{ERR}"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " instead"
                }
              ]
            }
          ]
        },
        {
          "__type": "DefList",
          "__tag": 4033,
          "children": [
            {
              "__type": "DefListItem",
              "__tag": 4037,
              "dt": {
                "__type": "Paragraph",
                "__tag": 4045,
                "children": [
                  {
                    "__type": "InlineCode",
                    "__tag": 4051,
                    "value": "PyUFunc_{VALUE}"
                  }
                ]
              },
              "dd": []
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Constants"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Macros"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Types"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Create a new broadcasting universal function from required variables.     Each ufunc builds around the notion of an element-by-element     operation. Each ufunc object contains pointers to 1-d loops     implementing the basic functionality for each supported type."
                }
              ]
            },
            {
              "__type": "Admonition",
              "__tag": 4056,
              "kind": "note",
              "base_type": "note",
              "children": [
                {
                  "__type": "AdmonitionTitle",
                  "__tag": 4055,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "note "
                    }
                  ]
                },
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "The "
                          },
                          {
                            "__type": "Emphasis",
                            "__tag": 4047,
                            "children": [
                              {
                                "__type": "Text",
                                "__tag": 4046,
                                "value": "func"
                              }
                            ]
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": ", "
                          },
                          {
                            "__type": "Emphasis",
                            "__tag": 4047,
                            "children": [
                              {
                                "__type": "Text",
                                "__tag": 4046,
                                "value": "data"
                              }
                            ]
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": ", "
                          },
                          {
                            "__type": "Emphasis",
                            "__tag": 4047,
                            "children": [
                              {
                                "__type": "Text",
                                "__tag": 4046,
                                "value": "types"
                              }
                            ]
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": ", "
                          },
                          {
                            "__type": "Emphasis",
                            "__tag": 4047,
                            "children": [
                              {
                                "__type": "Text",
                                "__tag": 4046,
                                "value": "name"
                              }
                            ]
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": ", and "
                          },
                          {
                            "__type": "Emphasis",
                            "__tag": 4047,
                            "children": [
                              {
                                "__type": "Text",
                                "__tag": 4046,
                                "value": "doc"
                              }
                            ]
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": " arguments are not"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "copied by "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "PyUFunc_FromFuncAndData"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ". The caller must ensure     that the memory used by these arrays is not freed as long as the     ufunc object is alive."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "FieldList",
              "__tag": 4035,
              "children": [
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramfunc"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Must point to an array containing "
                        },
                        {
                          "__type": "Emphasis",
                          "__tag": 4047,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "ntypes"
                            }
                          ]
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "         "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFuncGenericFunction"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " elements."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramdata"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Should be "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NULL"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " or a pointer to an array of size "
                        },
                        {
                          "__type": "Emphasis",
                          "__tag": 4047,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "ntypes"
                            }
                          ]
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ".         This array may contain arbitrary extra-data to be passed to         the corresponding loop function in the func array, including         "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NULL"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramtypes"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Length "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "(nin + nout) * ntypes"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " array of "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "char"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " encoding the        "
                        },
                        {
                          "__type": "InlineRole",
                          "__tag": 4003,
                          "value": "numpy.dtype.num",
                          "domain": null,
                          "role": null,
                          "inventory": null
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " (built-in only) that the corresponding        function in the "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "func"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " array accepts. For instance, for a comparison        ufunc with three "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "ntypes"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", two "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "nin"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " and one "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "nout"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", where the        first function accepts "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.int32",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy:int32"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " and the second        "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.int64",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy:int64"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", with both returning "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.bool_",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy:bool"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "types"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " would        be "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "(char[]) {5, 5, 0, 7, 7, 0}"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " since "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NPY_INT32"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " is 5,        "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NPY_INT64"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " is 7, and "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NPY_BOOL"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " is 0."
                        }
                      ]
                    },
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "The bit-width names can also be used (e.g. "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NPY_INT32"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ",        "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NPY_COMPLEX128"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " ) if desired."
                        }
                      ]
                    },
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "ufuncs.casting",
                          "reference": {
                            "__type": "LocalRef",
                            "__tag": 4022,
                            "kind": "docs",
                            "path": "user:basics.ufuncs"
                          },
                          "kind": "exists"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " will be used at runtime to find the first        "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "func"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " callable by the input/output provided."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramntypes"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "How many different data-type-specific functions the ufunc has implemented."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramnin"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "The number of inputs to this operation."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramnout"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "The number of outputs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramidentity"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Either "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFunc_One"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFunc_Zero"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ",         "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFunc_MinusOne"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", or "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFunc_None"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ".         This specifies what should be returned when         an empty array is passed to the reduce method of the ufunc.         The special value "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFunc_IdentityValue"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " may only be used with         the "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFunc_FromFuncAndDataAndSignatureAndIdentity"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " method, to         allow an arbitrary python object to be used as the identity."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramname"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "The name for the ufunc as a "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NULL"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " terminated string.  Specifying         a name of 'add' or 'multiply' enables a special behavior for         integer-typed reductions when no dtype is given. If the input type is an         integer (or boolean) data type smaller than the size of the "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.int_",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy:int64"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "         data type, it will be internally upcast to the "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.int_",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy:int64"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " (or         "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.uint",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy:uint64"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ") data type."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramdoc"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Allows passing in a documentation string to be stored with the         ufunc.  The documentation string should not contain the name         of the function or the calling signature as that will be         dynamically determined from the object and available when         accessing the "
                        },
                        {
                          "__type": "Strong",
                          "__tag": 4048,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "__doc__"
                            }
                          ]
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " attribute of the ufunc."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramunused"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Unused and present for backwards compatibility of the C-API."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This function is very similar to PyUFunc_FromFuncAndData above, but has    an extra "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "signature"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " argument, to define a    "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "generalized universal functions",
                  "reference": {
                    "__type": "LocalRef",
                    "__tag": 4022,
                    "kind": "docs",
                    "path": "reference:c-api:generalized-ufuncs"
                  },
                  "kind": "exists"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ".    Similarly to how ufuncs are built around an element-by-element operation,    gufuncs are around subarray-by-subarray operations, the    "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "signature",
                  "reference": {
                    "__type": "LocalRef",
                    "__tag": 4022,
                    "kind": "docs",
                    "path": "reference:c-api:generalized-ufuncs"
                  },
                  "kind": "exists"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " defining the subarrays to operate on."
                }
              ]
            },
            {
              "__type": "FieldList",
              "__tag": 4035,
              "children": [
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramsignature"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "The signature for the new gufunc. Setting it to NULL is equivalent         to calling PyUFunc_FromFuncAndData. A copy of the string is made,         so the passed in buffer can be freed."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This function is very similar to "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "PyUFunc_FromFuncAndDataAndSignature"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " above,    but has an extra "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "identity_value"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " argument, to define an arbitrary identity    for the ufunc when "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "identity"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is passed as "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "PyUFunc_IdentityValue"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            },
            {
              "__type": "FieldList",
              "__tag": 4035,
              "children": [
                {
                  "__type": "FieldListItem",
                  "__tag": 4036,
                  "name": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "paramidentity_value"
                    }
                  ],
                  "body": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "The identity for the new gufunc. Must be passed as "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "NULL"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " unless the         "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "identity"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " argument is "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "PyUFunc_IdentityValue"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ". Setting it to NULL         is equivalent to calling PyUFunc_FromFuncAndDataAndSignature."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This function allows the user to register a 1-d loop with an     already- created ufunc to be used whenever the ufunc is called     with any of its input arguments as the user-defined     data-type. This is needed in order to make ufuncs work with     built-in data-types. The data-type must have been previously     registered with the numpy system. The loop is passed in as     "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "function"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". This loop can take arbitrary data which should be     passed in as "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "data"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". The data-types the loop requires are passed     in as "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "arg_types"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " which must be a pointer to memory at least as     large as ufunc->nargs."
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This function behaves like PyUFunc_RegisterLoopForType above, except    that it allows the user to register a 1-d loop using PyArray_Descr    objects instead of dtype type num values. This allows a 1-d loop to be    registered for structured array data-dtypes and custom data-types    instead of scalar data-types."
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Replace a 1-d loop matching the given "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "signature"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " in the     already-created "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "ufunc"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " with the new 1-d loop newfunc. Return the     old 1-d loop function in "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "oldfunc"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". Return 0 on success and -1 on     failure. This function works only with built-in types (use     "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "PyUFunc_RegisterLoopForType"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for user-defined types). A     signature is an array of data-type numbers indicating the inputs     followed by the outputs assumed by the 1-d loop."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Functions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "At the core of every ufunc is a collection of type-specific functions that defines the basic functionality for each of the supported types. These functions must evaluate the underlying function "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "N\\geq1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " times. Extra-data may be passed in that may be used during the calculation. This feature allows some general functions to be used as these basic looping functions. The general function has all the code needed to point variables to the right place and set up a function call. The general function assumes that the actual function to call is passed in as the extra data and calls it with the correct values. All of these functions are suitable for placing directly in the array of functions stored in the functions member of the PyUFuncObject structure."
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Type specific, core 1-d functions for ufuncs where each     calculation is obtained by calling a function taking one input     argument and returning one output. This function is passed in     "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "func"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". The letters correspond to dtypechar's of the supported     data types ( "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "e"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " - half, "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "f"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " - float, "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "d"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " - double,     "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "g"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " - long double, "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "F"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " - cfloat, "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "D"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " - cdouble,     "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "G"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " - clongdouble). The argument "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "func"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " must support the same     signature. The _As_X_X variants assume ndarray's of one data type     but cast the values to use an underlying function that takes a     different data type. Thus, "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "PyUFunc_f_f_As_d_d"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " uses     ndarrays of data type "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "NPY_FLOAT"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " but calls out to a     C-function that takes double and returns double."
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Type specific, core 1-d functions for ufuncs where each     calculation is obtained by calling a function taking two input     arguments and returning one output. The underlying function to     call is passed in as "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "func"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". The letters correspond to     dtypechar's of the specific data type supported by the     general-purpose function. The argument "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "func"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " must support the     corresponding signature. The "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "_As_XX_X"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " variants assume ndarrays     of one data type but cast the values at each iteration of the loop     to use the underlying function that takes a different data type."
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "One-input, one-output, and two-input, one-output core 1-d functions     for the "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "NPY_OBJECT"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " data type. These functions handle reference     count issues and return early on error. The actual function to call is     "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "func"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " and it must accept calls with the signature "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "(PyObject*)     (PyObject*)"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "PyUFunc_O_O"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " or "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "(PyObject*)(PyObject *,     PyObject *)"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "PyUFunc_OO_O"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This general purpose 1-d core function assumes that "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "func"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is a string     representing a method of the input object. For each     iteration of the loop, the Python object is extracted from the array     and its "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "func"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " method is called returning the result to the output array."
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This general purpose 1-d core function assumes that "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "func"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is a     string representing a method of the input object that takes one     argument. The first argument in "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "args"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is the method whose function is     called, the second argument in "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "args"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is the argument passed to the     function. The output of the function is stored in the third entry     of "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "args"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This is the 1-d core function used by the dynamic ufuncs created     by umath.frompyfunc(function, nin, nout). In this case "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "func"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is a     pointer to a "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "PyUFunc_PyFuncData"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " structure which has definition"
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "At each iteration of the loop, the "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "nin"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " input objects are extracted     from their object arrays and placed into an argument tuple, the Python     "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "callable"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is called with the input arguments, and the nout     outputs are placed into their object arrays."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Generic functions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Importing the API"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}