提交 c05e3ab5 authored 作者: Jeremiah Lowin's avatar Jeremiah Lowin

dot as function; _dot as instance

上级 65400e78
...@@ -7100,12 +7100,11 @@ class Dot(Op): ...@@ -7100,12 +7100,11 @@ class Dot(Op):
def __str__(self): def __str__(self):
return "dot" return "dot"
dot = Dot() _dot = Dot()
pprint.assign(dot, printing.OperatorPrinter(printing.special['middle_dot'], pprint.assign(_dot, printing.OperatorPrinter(printing.special['middle_dot'],
-1, 'left')) -1, 'left'))
#TODO replace dot with dotfunc? def dot(a, b):
def dotfunc(a, b):
""" """
Computes the dot product of two variables. For two matrices, this is Computes the dot product of two variables. For two matrices, this is
equivalent to matrix multiplication. For two vectors, this is the inner equivalent to matrix multiplication. For two vectors, this is the inner
...@@ -7139,7 +7138,7 @@ def dotfunc(a, b): ...@@ -7139,7 +7138,7 @@ def dotfunc(a, b):
elif a.ndim > 2 or b.ndim > 2: elif a.ndim > 2 or b.ndim > 2:
return tensordot(a, b, [[a.ndim - 1], [numpy.maximum(0, b.ndim - 2)]]) return tensordot(a, b, [[a.ndim - 1], [numpy.maximum(0, b.ndim - 2)]])
else: else:
return dot(a, b) return _dot(a, b)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论