diff options
author | mattip <matti.picus@gmail.com> | 2018-12-03 09:43:37 -0800 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2018-12-03 09:43:37 -0800 |
commit | 18476f5285bdd3f1405086e37240a9bd2640ff16 (patch) | |
tree | aac6f6a3d6d1b2e304b3ac27004da49299df833c /numpy | |
parent | 72f2abf34a43cf3642acf6a6ff951148051404ae (diff) | |
download | numpy-18476f5285bdd3f1405086e37240a9bd2640ff16.tar.gz |
DOC: add a comment detailing the output ufunc flag choices
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 5dc1db226..ea0007a9d 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -328,6 +328,18 @@ set_matmul_flags(PyObject *d) if (matmul == NULL) { return -1; } + /* + * The default output flag NPY_ITER_OVERLAP_ASSUME_ELEMENTWISE allows + * perfectly overlapping input and output (in-place operations). While + * correct for the common mathematical operations, this assumption is + * incorrect in the general case and specifically in the case of matmul. + * + * NPY_ITER_UPDATEIFCOPY is added by default in + * PyUFunc_GeneralizedFunction, which is the variant called for gufuncs + * with a signature + * + * Enabling NPY_ITER_WRITEONLY can prevent a copy in some cases. + */ ((PyUFuncObject *)matmul)->op_flags[2] = (NPY_ITER_WRITEONLY | NPY_ITER_UPDATEIFCOPY | NPY_UFUNC_DEFAULT_OUTPUT_FLAGS) & |