Dot product of many aligned chunks >>> x = np.array([[1, 2], [1, 2]]) >>> y = np.array([[10, 20], [10, 20]]) >>> dotmany([x, x, x], [y, y, y]) array([[ 90, 180], [ 90, 180]]) Optionally pass in functions to apply to the left and right chunks >>> dotmany([x, x, x
(A, B, leftfunc=None, rightfunc=None, **kwargs)
| 353 | |
| 354 | |
| 355 | def dotmany(A, B, leftfunc=None, rightfunc=None, **kwargs): |
| 356 | """Dot product of many aligned chunks |
| 357 | |
| 358 | >>> x = np.array([[1, 2], [1, 2]]) |
| 359 | >>> y = np.array([[10, 20], [10, 20]]) |
| 360 | >>> dotmany([x, x, x], [y, y, y]) |
| 361 | array([[ 90, 180], |
| 362 | [ 90, 180]]) |
| 363 | |
| 364 | Optionally pass in functions to apply to the left and right chunks |
| 365 | |
| 366 | >>> dotmany([x, x, x], [y, y, y], rightfunc=np.transpose) |
| 367 | array([[150, 150], |
| 368 | [150, 150]]) |
| 369 | """ |
| 370 | if leftfunc: |
| 371 | A = map(leftfunc, A) |
| 372 | if rightfunc: |
| 373 | B = map(rightfunc, B) |
| 374 | return sum(map(partial(np.dot, **kwargs), A, B)) |
| 375 | |
| 376 | |
| 377 | def _concatenate2(arrays, axes=None): |
nothing calls this directly
no test coverage detected
searching dependent graphs…