当前位置: 首页>>代码示例>>Python>>正文


Python LinearOperator.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __init__ [as 别名]
 def __init__(self, n, c):
     """n is dimension, c is a constant to be multiplied by the identity matrix."""
     self.c = c
     if LINOP_SUBCLASSING:
         LinearOperator.__init__(self, dtype = float, shape = (n, n))
     else:
         LinearOperator.__init__(self, dtype = float, shape = (n, n), matvec = lambda x : type(self)._matvec(self, x))
开发者ID:jeremander,项目名称:AttrVN,代码行数:9,代码来源:linop.py

示例2: __init__

# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __init__ [as 别名]
 def __init__(self, F, Delta, u):
     n = F.shape[0]
     assert (F.shape[1] == n) and (u.shape == (n,))
     self.F, self.Delta, self.u = F, Delta, u
     self.u_prime = self.Delta - self.u
     self.ones = np.ones(n, dtype=float)
     LinearOperator.__init__(self, dtype=float, shape=self.F.shape)
开发者ID:jeremander,项目名称:Gplus,代码行数:9,代码来源:linop.py

示例3: __init__

# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __init__ [as 别名]
    def __init__(self,
            A,
            coarsening=pyamgcl_ext.coarsening.smoothed_aggregation,
            relaxation=pyamgcl_ext.relaxation.spai0,
            prm={}
            ):
        """
        Class constructor.

        Creates algebraic multigrid hierarchy.

        Parameters
        ----------
        A : the system matrix in scipy.sparse format
        coarsening : {ruge_stuben, aggregation, *smoothed_aggregation*, smoothed_aggr_emin}
            The coarsening type to use for construction of the multigrid
            hierarchy.
        relaxation : {damped_jacobi, gauss_seidel, chebyshev, *spai0*, ilu0}
            The relaxation scheme to use for multigrid cycles.
        prm : dictionary with amgcl parameters
        """
        Acsr = A.tocsr()

        self.P = pyamgcl_ext.make_preconditioner(
                coarsening, relaxation, prm,
                Acsr.indptr.astype(numpy.int32),
                Acsr.indices.astype(numpy.int32),
                Acsr.data.astype(numpy.float64)
                )

        LinearOperator.__init__(self, A.shape, self.P)
开发者ID:hkaiser,项目名称:amgcl,代码行数:33,代码来源:__init__.py

示例4: __init__

# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __init__ [as 别名]
    def __init__(self, shape, matvec):

        self._shape = shape
        self._action = matvec

        LinearOperator.__init__(self,
                                shape=self._shape,
                                matvec=self.parallelDot,
                                dtype=np.complex128)
开发者ID:mark-glass,项目名称:comsyl,代码行数:11,代码来源:ParallelLinearOperator.py

示例5: __init__

# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __init__ [as 别名]
 def __init__(self, K, quad, **kwargs):
     assert len(K.shape) == 1
     shape = (K.shape[0]-4, K.shape[0]-4)
     N = shape[0]
     LinearOperator.__init__(self, shape, None, **kwargs)
     ck = ones(K.shape)
     if quad == "GC": ck[N-1] = 2
     self.dd = -4*pi*(K[:N]+1)/(K[:N]+3)*(K[:N]+2)**2
     self.ud = [2*pi*(K[:N-2]+1)*(K[:N-2]+2)]        
     self.ld = [2*pi*(K[2:N]-1)*(K[2:N]+2)]
开发者ID:skyopener,项目名称:spectralDNS,代码行数:12,代码来源:OrrSommerfeld_eig.py

示例6: __init__

# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __init__ [as 别名]
    def __init__(self, mat, r=10, leaf_side=16):
        LinearOperator.__init__(self, dtype=mat.dtype, shape=mat.shape,
                                matvec=self._matvec,
                                rmatvec=self._rmatvec)
        self.mat = BlackBox(mat)
        self.r = r
        self.leaf_side = leaf_side
        self.leaf_size = leaf_side**2

        N = int(np.sqrt(self.mat.shape[0]))

        self.pattern = distance_matrix(N, format='coo')
        perm = hilbert_traverse(N)
        conjugate_sparse(self.pattern, perm)
        self.pattern = self.pattern.tocsr()
        self.mat.permutate(perm)
        self.root = hmat_node(self, tuple(zip((0, 0), self.mat.shape)))
        return
开发者ID:Nehoroshiy,项目名称:hmat,代码行数:20,代码来源:hmat.py

示例7: __init__

# 需要导入模块: from scipy.sparse.linalg import LinearOperator [as 别名]
# 或者: from scipy.sparse.linalg.LinearOperator import __init__ [as 别名]
    def __init__(self, A, pmask, prm={}):
        """
        Class constructor.

        Parameters
        ----------
        A : the system matrix in scipy.sparse format
        prm : dictionary with amgcl parameters
        """
        Acsr = A.tocsr()

        self.P = pyamgcl_ext.make_simple(
                prm,
                Acsr.indptr.astype(numpy.int32),
                Acsr.indices.astype(numpy.int32),
                Acsr.data.astype(numpy.float64),
                pmask.astype(numpy.int32)
                )

        if [int(v) for v in scipy.__version__.split('.')] < [0, 16, 0]:
            LinearOperator.__init__(self, A.shape, self.P)
        else:
            LinearOperator.__init__(self, dtype=numpy.float64, shape=A.shape)
开发者ID:intbots,项目名称:amgcl,代码行数:25,代码来源:__init__.py


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