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

Function array_vdot

numpy/core/src/multiarray/multiarraymodule.c:2625–2745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2623
2624
2625static PyObject *
2626array_vdot(PyObject *NPY_UNUSED(dummy), PyObject *const *args, Py_ssize_t len_args)
2627{
2628 int typenum;
2629 char *ip1, *ip2, *op;
2630 npy_intp n, stride1, stride2;
2631 PyObject *op1, *op2;
2632 npy_intp newdimptr[1] = {-1};
2633 PyArray_Dims newdims = {newdimptr, 1};
2634 PyArrayObject *ap1 = NULL, *ap2 = NULL, *ret = NULL;
2635 PyArray_Descr *type;
2636 PyArray_DotFunc *vdot;
2637 NPY_BEGIN_THREADS_DEF;
2638
2639 NPY_PREPARE_ARGPARSER;
2640 if (npy_parse_arguments("vdot", args, len_args, NULL,
2641 "", NULL, &op1,
2642 "", NULL, &op2,
2643 NULL, NULL, NULL) < 0) {
2644 return NULL;
2645 }
2646
2647 /*
2648 * Conjugating dot product using the BLAS for vectors.
2649 * Flattens both op1 and op2 before dotting.
2650 */
2651 typenum = PyArray_ObjectType(op1, NPY_NOTYPE);
2652 if (typenum == NPY_NOTYPE) {
2653 return NULL;
2654 }
2655 typenum = PyArray_ObjectType(op2, typenum);
2656 if (typenum == NPY_NOTYPE) {
2657 return NULL;
2658 }
2659
2660 type = PyArray_DescrFromType(typenum);
2661 Py_INCREF(type);
2662 ap1 = (PyArrayObject *)PyArray_FromAny(op1, type, 0, 0, 0, NULL);
2663 if (ap1 == NULL) {
2664 Py_DECREF(type);
2665 goto fail;
2666 }
2667
2668 op1 = PyArray_Newshape(ap1, &newdims, NPY_CORDER);
2669 if (op1 == NULL) {
2670 Py_DECREF(type);
2671 goto fail;
2672 }
2673 Py_DECREF(ap1);
2674 ap1 = (PyArrayObject *)op1;
2675
2676 ap2 = (PyArrayObject *)PyArray_FromAny(op2, type, 0, 0, 0, NULL);
2677 if (ap2 == NULL) {
2678 goto fail;
2679 }
2680 op2 = PyArray_Newshape(ap2, &newdims, NPY_CORDER);
2681 if (op2 == NULL) {
2682 goto fail;

Callers

nothing calls this directly

Calls 9

PyArray_ObjectTypeFunction · 0.85
PyArray_FromAnyFunction · 0.85
PyArray_NewshapeFunction · 0.85
PyArray_DIMFunction · 0.85
new_array_for_sumFunction · 0.85
PyArray_STRIDEFunction · 0.85
PyArray_DATAFunction · 0.85
vdotFunction · 0.85
PyArray_ReturnFunction · 0.85

Tested by

no test coverage detected