diff options
author | CJ Carey <perimosocordiae@gmail.com> | 2016-05-13 16:04:01 -0500 |
---|---|---|
committer | CJ Carey <perimosocordiae@gmail.com> | 2016-05-14 20:37:54 -0400 |
commit | 49f70f7c3a447c8e0bc9ba0d1be7e4df34f04f58 (patch) | |
tree | 096422c572321b94ce9a56fc4b17288e362333d8 | |
parent | 2555e44986b6d1ffb34ea3aed511b5812d4e3923 (diff) | |
download | numpy-49f70f7c3a447c8e0bc9ba0d1be7e4df34f04f58.tar.gz |
MAINT: linalg: fix comment, simplify math
The comment was a simple copy-paste error.
I find the math easier to look at in this form,
with the common terms factored out.
-rw-r--r-- | numpy/linalg/linalg.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index f4acd0ef3..1f3ba7c54 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -2346,12 +2346,12 @@ def _multi_dot_three(A, B, C): than `_multi_dot_matrix_chain_order` """ - # cost1 = cost((AB)C) - cost1 = (A.shape[0] * A.shape[1] * B.shape[1] + # (AB) - A.shape[0] * B.shape[1] * C.shape[1]) # (--)C - # cost2 = cost((AB)C) - cost2 = (B.shape[0] * B.shape[1] * C.shape[1] + # (BC) - A.shape[0] * A.shape[1] * C.shape[1]) # A(--) + a0, a1b0 = A.shape + b1c0, c1 = C.shape + # cost1 = cost((AB)C) = a0*a1b0*b1c0 + a0*b1c0*c1 + cost1 = a0 * b1c0 * (a1b0 + c1) + # cost2 = cost(A(BC)) = a1b0*b1c0*c1 + a0*a1b0*c1 + cost2 = a1b0 * c1 * (a0 + b1c0) if cost1 < cost2: return dot(dot(A, B), C) |