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

Function dot_generalized

numpy/linalg/tests/test_linalg.py:434–450  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

432
433
434def dot_generalized(a, b):
435 a = asarray(a)
436 if a.ndim >= 3:
437 if a.ndim == b.ndim:
438 # matrix x matrix
439 new_shape = a.shape[:-1] + b.shape[-1:]
440 elif a.ndim == b.ndim + 1:
441 # matrix x vector
442 new_shape = a.shape[:-1]
443 else:
444 raise ValueError("Not implemented...")
445 r = np.empty(new_shape, dtype=np.common_type(a, b))
446 for c in itertools.product(*map(range, a.shape[:-2])):
447 r[c] = dot(a[c], b[c])
448 return r
449 else:
450 return dot(a, b)
451
452
453def identity_like_generalized(a):

Callers 6

doMethod · 0.85
doMethod · 0.85
doMethod · 0.85
doMethod · 0.85
doMethod · 0.85
doMethod · 0.85

Calls 2

asarrayFunction · 0.90
dotFunction · 0.90

Tested by

no test coverage detected