本文整理汇总了Python中scipy.sparse.linalg.LinearOperator.__call__方法的典型用法代码示例。如果您正苦于以下问题:Python LinearOperator.__call__方法的具体用法?Python LinearOperator.__call__怎么用?Python LinearOperator.__call__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.sparse.linalg.LinearOperator
的用法示例。
在下文中一共展示了LinearOperator.__call__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeOperator
# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __call__ [as 别名]
def makeOperator( operatorInput, expectedShape ):
"""Internal. Takes a dense numpy array or a sparse matrix or
a function and makes an operator performing matrix * blockvector
products.
Example
-------
>>> A = makeOperator( arrayA, (n, n) )
>>> vectorB = A( vectorX )
"""
if operatorInput is None:
def ident(x):
return x
operator = LinearOperator(expectedShape, ident, matmat=ident)
else:
operator = aslinearoperator(operatorInput)
if operator.shape != expectedShape:
raise ValueError('operator has invalid shape')
operator.__call__ = operator.matmat
return operator
示例2: makeOperator
# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __call__ [as 别名]
def makeOperator( operatorInput, expectedShape ):
"""Internal. Takes a dense numpy array or a sparse matrix or
a function and makes an operator performing matrix * blockvector
products.
Examples
--------
>>> A = makeOperator( arrayA, (n, n) )
>>> vectorB = A( vectorX )
"""
if operatorInput is None:
def ident(x):
return x
operator = LinearOperator(expectedShape, ident, matmat=ident)
else:
operator = aslinearoperator(operatorInput)
if operator.shape != expectedShape:
raise ValueError('operator has invalid shape')
if sys.version_info[0] >= 3:
# special methods are looked up on the class -- so make a new one
operator.__class__ = CallableLinearOperator
else:
operator.__call__ = operator.matmat
return operator
示例3: Operator
# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __call__ [as 别名]
def Operator(f, size=None):
"""Create a stacked version of the function f, casted as a LinearOperator.
size is the dimension of the operator f."""
if size == None: size = f.Size
operator = LinearOperator((size,size), matvec = StackFunction(f), dtype=float64)
operator.__call__ = lambda x: operator * x
return operator