MCPcopy Create free account
hub / github.com/numpy/numpy / cblas_matrixproduct

Function cblas_matrixproduct

numpy/core/src/common/cblasfuncs.c:222–702  ·  view source on GitHub ↗

* dot(a,b) * Returns the dot product of a and b for arrays of floating point types. * Like the generic numpy equivalent the product sum is over * the last dimension of a and the second-to-last dimension of b. * NB: The first argument is not conjugated.; * * This is for use by PyArray_MatrixProduct2. It is assumed on entry that * the arrays ap1 and ap2 have a common data type given by typenu

Source from the content-addressed store, hash-verified

220 * __array_ufunc__ nonsense is also assumed to have been taken care of.
221 */
222NPY_NO_EXPORT PyObject *
223cblas_matrixproduct(int typenum, PyArrayObject *ap1, PyArrayObject *ap2,
224 PyArrayObject *out)
225{
226 PyArrayObject *result = NULL, *out_buf = NULL;
227 npy_intp j, lda, ldb;
228 npy_intp l;
229 int nd;
230 npy_intp ap1stride = 0;
231 npy_intp dimensions[NPY_MAXDIMS];
232 npy_intp numbytes;
233 MatrixShape ap1shape, ap2shape;
234
235 if (_bad_strides(ap1)) {
236 PyObject *op1 = PyArray_NewCopy(ap1, NPY_ANYORDER);
237
238 Py_DECREF(ap1);
239 ap1 = (PyArrayObject *)op1;
240 if (ap1 == NULL) {
241 goto fail;
242 }
243 }
244 if (_bad_strides(ap2)) {
245 PyObject *op2 = PyArray_NewCopy(ap2, NPY_ANYORDER);
246
247 Py_DECREF(ap2);
248 ap2 = (PyArrayObject *)op2;
249 if (ap2 == NULL) {
250 goto fail;
251 }
252 }
253 ap1shape = _select_matrix_shape(ap1);
254 ap2shape = _select_matrix_shape(ap2);
255
256 if (ap1shape == _scalar || ap2shape == _scalar) {
257 PyArrayObject *oap1, *oap2;
258 oap1 = ap1; oap2 = ap2;
259 /* One of ap1 or ap2 is a scalar */
260 if (ap1shape == _scalar) {
261 /* Make ap2 the scalar */
262 PyArrayObject *t = ap1;
263 ap1 = ap2;
264 ap2 = t;
265 ap1shape = ap2shape;
266 ap2shape = _scalar;
267 }
268
269 if (ap1shape == _row) {
270 ap1stride = PyArray_STRIDE(ap1, 1);
271 }
272 else if (PyArray_NDIM(ap1) > 0) {
273 ap1stride = PyArray_STRIDE(ap1, 0);
274 }
275
276 if (PyArray_NDIM(ap1) == 0 || PyArray_NDIM(ap2) == 0) {
277 npy_intp *thisdims;
278 if (PyArray_NDIM(ap1) == 0) {
279 nd = PyArray_NDIM(ap2);

Callers 1

PyArray_MatrixProduct2Function · 0.85

Calls 15

_bad_stridesFunction · 0.85
PyArray_NewCopyFunction · 0.85
_select_matrix_shapeFunction · 0.85
PyArray_STRIDEFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_DIMSFunction · 0.85
PyArray_DIMFunction · 0.85
dot_alignment_errorFunction · 0.85
new_array_for_sumFunction · 0.85
PyArray_DATAFunction · 0.85
PyArray_ReturnFunction · 0.85
PyArray_DESCRFunction · 0.85

Tested by

no test coverage detected