@@ -674,8 +674,8 @@ cblas_matrixproduct(int typenum, PyArrayObject *ap1, PyArrayObject *ap2,
674674 *
675675 * This is for use by PyArray_InnerProduct. It is assumed on entry that the
676676 * arrays ap1 and ap2 have a common data type given by typenum that is
677- * float, double, cfloat, or cdouble and have dimension <= 2, and have the
678- * contiguous flag set. The * __numpy_ufunc__ nonsense is also assumed to
677+ * float, double, cfloat, or cdouble and have dimension <= 2.
678+ * The * __numpy_ufunc__ nonsense is also assumed to
679679 * have been taken care of.
680680 */
681681
@@ -689,6 +689,24 @@ cblas_innerproduct(int typenum, PyArrayObject *ap1, PyArrayObject *ap2)
689689 npy_intp dimensions [NPY_MAXDIMS ];
690690 PyTypeObject * subtype ;
691691
692+ /* assure contiguous arrays */
693+ if (!PyArray_IS_C_CONTIGUOUS (ap1 )) {
694+ PyObject * op1 = PyArray_NewCopy (ap1 , NPY_CORDER );
695+ Py_DECREF (ap1 );
696+ ap1 = (PyArrayObject * )op1 ;
697+ if (ap1 == NULL ) {
698+ goto fail ;
699+ }
700+ }
701+ if (!PyArray_IS_C_CONTIGUOUS (ap2 )) {
702+ PyObject * op2 = PyArray_NewCopy (ap2 , NPY_CORDER );
703+ Py_DECREF (ap2 );
704+ ap2 = (PyArrayObject * )op2 ;
705+ if (ap2 == NULL ) {
706+ goto fail ;
707+ }
708+ }
709+
692710 if (PyArray_NDIM (ap1 ) == 0 || PyArray_NDIM (ap2 ) == 0 ) {
693711 /* One of ap1 or ap2 is a scalar */
694712 if (PyArray_NDIM (ap1 ) == 0 ) {
0 commit comments