python的matmul_Python ast.MatMult方法代码示例

本文整理汇总了Python中ast.MatMult方法的典型用法代码示例。如果您正苦于以下问题:Python ast.MatMult方法的具体用法?Python ast.MatMult怎么用?Python ast.MatMult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块ast的用法示例。

在下文中一共展示了ast.MatMult方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: term_rewrite

# 需要导入模块: import ast [as 别名]

# 或者: from ast import MatMult [as 别名]

def term_rewrite(head, tail):

if tail:

for op, each in tail:

head = ast.BinOp(

head,

{

'*': ast.Mult,

'@': ast.MatMult,

'%': ast.Mod,

'//': ast.FloorDiv,

'/': ast.Div

}[op.value](),

each,

**loc @ op,

)

return head

开发者ID:Xython,项目名称:YAPyPy,代码行数:18,

示例2: augassign_rewrite

# 需要导入模块: import ast [as 别名]

# 或者: from ast import MatMult [as 别名]

def augassign_rewrite(it: Tokenizer):

return {

'+=': ast.Add,

'-=': ast.Sub,

'*=': ast.Mult,

'/=': ast.Div,

'//=': ast.FloorDiv,

'@=': ast.MatMult,

'%=': ast.Mod,

'&=': ast.BitAnd,

'|=': ast.BitOr,

'^=': ast.BitXor,

'<<=': ast.LShift,

'>>=': ast.RShift,

'**=': ast.Pow,

}[it.value]

开发者ID:Xython,项目名称:YAPyPy,代码行数:18,

示例3: visit_AugAssign

# 需要导入模块: import ast [as 别名]

# 或者: from ast import MatMult [as 别名]

def visit_AugAssign( s, node ):

"""Return the behavioral RTLIR of a non-blocking assignment

If the given AugAssign is not @= or <<=, throw PyMTLSyntaxError

"""

if isinstance( node.op, (ast.LShift, ast.MatMult) ):

value = s.visit( node.value )

targets = [ s.visit( node.target ) ]

blocking = False if isinstance(node.op, ast.LShift) else True

ret = bir.Assign( targets, value, blocking )

ret.ast = node

return ret

raise PyMTLSyntaxError( s.blk, node,

'invalid operation: augmented assignment is not @= or <<= assignment!' )

开发者ID:pymtl,项目名称:pymtl3,代码行数:16,

示例4: visit_BinOp

# 需要导入模块: import ast [as 别名]

# 或者: from ast import MatMult [as 别名]

def visit_BinOp(self, node: ast.BinOp) -> Any:

"""Recursively visit the left and right operand, respectively, and apply the operation on the results."""

# pylint: disable=too-many-branches

left = self.visit(node=node.left)

right = self.visit(node=node.right)

if isinstance(node.op, ast.Add):

result = left + right

elif isinstance(node.op, ast.Sub):

result = left - right

elif isinstance(node.op, ast.Mult):

result = left * right

elif isinstance(node.op, ast.Div):

result = left / right

elif isinstance(node.op, ast.FloorDiv):

result = left // right

elif isinstance(node.op, ast.Mod):

result = left % right

elif isinstance(node.op, ast.Pow):

result = left**right

elif isinstance(node.op, ast.LShift):

result = left << right

elif isinstance(node.op, ast.RShift):

result = left >> right

elif isinstance(node.op, ast.BitOr):

result = left | right

elif isinstance(node.op, ast.BitXor):

result = left ^ right

elif isinstance(node.op, ast.BitAnd):

result = left & right

elif isinstance(node.op, ast.MatMult):

result = left @ right

else:

raise NotImplementedError("Unhandled op of {}: {}".format(node, node.op))

self.recomputed_values[node] = result

return result

开发者ID:Parquery,项目名称:icontract,代码行数:39,

示例5: visit_BinOp

# 需要导入模块: import ast [as 别名]

# 或者: from ast import MatMult [as 别名]

def visit_BinOp (self, node):

if type (node.op) == ast.FloorDiv:

if self.allowOperatorOverloading:

self.emit ('__floordiv__ (')

self.visitSubExpr (node, node.left)

self.emit (', ')

self.visitSubExpr (node, node.right)

self.emit (')')

else:

self.emit ('Math.floor (')

self.visitSubExpr (node, node.left)

self.emit (' / ')

self.visitSubExpr (node, node.right)

self.emit (')')

elif (

type (node.op) in (ast.Pow, ast.MatMult) or

(type (node.op) == ast.Mod and (self.allowOperatorOverloading or not self.allowJavaScriptMod)) or

(type (node.op) in (

ast.Mult, ast.Div, ast.Add, ast.Sub,

ast.LShift, ast.RShift, ast.BitOr, ast.BitXor, ast.BitAnd

) and self.allowOperatorOverloading)

):

self.emit ('{} ('.format (self.filterId (

# Non-overloaded

('__floordiv__' if self.allowOperatorOverloading else 'Math.floor') if type (node.op) == ast.FloorDiv else

('__pow__' if self.allowOperatorOverloading else 'Math.pow') if type (node.op) == ast.Pow else

'__matmul__' if type (node.op) == ast.MatMult else

('__jsmod__' if self.allowJavaScriptMod else '__mod__') if type (node.op) == ast.Mod else

# Overloaded arithmetic

'__mul__' if type (node.op) == ast.Mult else

'__truediv__' if type (node.op) == ast.Div else

'__add__' if type (node.op) == ast.Add else

'__sub__' if type (node.op) == ast.Sub else

# Overloaded bitwise

'__lshift__' if type (node.op) == ast.LShift else

'__rshift__' if type (node.op) == ast.RShift else

'__or__' if type (node.op) == ast.BitOr else

'__xor__' if type (node.op) == ast.BitXor else

'__and__' if type (node.op) == ast.BitAnd else

'Never here'

)))

self.visit (node.left)

self.emit (', ')

self.visit (node.right)

self.emit (')')

else:

self.visitSubExpr (node, node.left)

self.emit (' {} '.format (self.operators [type (node.op)][0]))

self.visitSubExpr (node, node.right)

开发者ID:QQuick,项目名称:Transcrypt,代码行数:54,

注:本文中的ast.MatMult方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值