• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sympy.Basic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sympy.Basic的典型用法代码示例。如果您正苦于以下问题:Python Basic类的具体用法?Python Basic怎么用?Python Basic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: my_compare

def my_compare(a, b):
   main_var = s
   p1, p2, p3 = Wild("p1"), Wild("p2"), Wild("p3")
   r_a = a.match(p1 * s**p3)
   r_b = b.match(p1 * s**p3)
   if r_a is not None and r_b is not None:
       c = Basic.compare(r_a[p3], r_b[p3])
       if c!=0:
           return c

   return Basic._compare_pretty(a,b)
开发者ID:ryanGT,项目名称:research,代码行数:11,代码来源:two_dof_utils.py


示例2: __new__

 def __new__(cls, i, j):
     i, j = map(sympify, (i, j))
     r = cls.canonize(i, j)
     if isinstance(r, Basic):
         return r
     obj = Basic.__new__(cls, i, j, commutative=True)
     return obj
开发者ID:jcockayne,项目名称:sympy-rkern,代码行数:7,代码来源:secondquant.py


示例3: __new__

 def __new__(cls, dimension):
     dimension = sympify(dimension)
     r = cls.eval(dimension)
     if isinstance(r, Basic):
         return r
     obj = Basic.__new__(cls, dimension, **{'commutative': False})
     return obj
开发者ID:ArchKaine,项目名称:sympy,代码行数:7,代码来源:hilbert.py


示例4: __new__

    def __new__ (cls, arg, **options):
#        print "Inverse(", arg, ")"
#        print INVERTIBLE
        if isinstance(arg, Inverse):
            return arg.args[0]
        if arg.is_Number:
            return 1 / arg

        arg_rank = expr_rank(arg)
        if arg_rank == 1:
            raise NotInvertibleError

        if is_one(arg):
            return arg
        if is_zero(arg):
            raise NotInvertibleError

        # FIXME: Funky case trying to catch lower triangular or diagonal
        #        muls like T(P_0)*A*P_0
        if arg in INVERTIBLE:
            pass
        elif isinstance(arg, TensorExpr) and not arg.has_inverse:
            raise NotInvertibleError
        elif isinstance(arg, Mul):
            if arg.args[0] == S(-1):
                return - Inverse(reduce(operator.mul, arg.args[1:]))
        if not expr_invertible(arg):
            raise NotInvertibleError
        options['commutative'] = arg.is_commutative
        return Basic.__new__(cls, arg, **options)
开发者ID:VictorEijkhout,项目名称:ignition,代码行数:30,代码来源:basic_operators.py


示例5: __new__

 def __new__(cls, sym, dist):
     sym = sympify(sym)
     if isinstance(dist, SingleContinuousDistribution):
         return SingleContinuousPSpace(sym, dist)
     if isinstance(dist, SingleDiscreteDistribution):
         return SingleDiscretePSpace(sym, dist)
     return Basic.__new__(cls, sym, dist)
开发者ID:normalhuman,项目名称:sympy,代码行数:7,代码来源:joint_rv.py


示例6: _new

 def _new(cls, *args, **kwargs):
     if len(args)==1 and isinstance(args[0], ImmutableMatrix):
         return args[0]
     rows, cols, mat = MatrixBase._handle_creation_inputs(*args, **kwargs)
     shape = Tuple(rows, cols)
     mat = Tuple(*mat)
     return Basic.__new__(cls, shape, mat)
开发者ID:ENuge,项目名称:sympy,代码行数:7,代码来源:immutable_matrix.py


示例7: __new__

    def __new__(cls, iterable=None, shape=None, **kwargs):
        from sympy.utilities.iterables import flatten

        shape, flat_list = cls._handle_ndarray_creation_inputs(iterable, shape, **kwargs)
        shape = Tuple(*map(_sympify, shape))
        loop_size = functools.reduce(lambda x,y: x*y, shape) if shape else 0

        # Sparse array:
        if isinstance(flat_list, (dict, Dict)):
            sparse_array = Dict(flat_list)
        else:
            sparse_array = {}
            for i, el in enumerate(flatten(flat_list)):
                if el != 0:
                    sparse_array[i] = _sympify(el)

        sparse_array = Dict(sparse_array)

        self = Basic.__new__(cls, sparse_array, shape, **kwargs)
        self._shape = shape
        self._rank = len(shape)
        self._loop_size = loop_size
        self._sparse_array = sparse_array

        return self
开发者ID:jarthurgross,项目名称:sympy,代码行数:25,代码来源:sparse_ndim_array.py


示例8: sample2d

def sample2d(f, x_args):
    """
    Samples a 2d function f over specified intervals and returns two
    arrays (X, Y) suitable for plotting with matlab (matplotlib)
    syntax. See examples\mplot2d.py.

    f is a function of one variable, such as x**2.
    x_args is an interval given in the form (var, min, max, n)
    """
    try:
        f = Basic.sympify(f)
    except:
        raise ValueError("f could not be interpretted as a SymPy function")
    try:
        x, x_min, x_max, x_n = x_args
    except:
        raise ValueError("x_args must be a tuple of the form (var, min, max, n)")

    x_l = float(x_max - x_min)
    x_d = x_l/float(x_n)
    X = arange(float(x_min), float(x_max)+x_d, x_d)

    Y = empty(len(X))
    for i in range(len(X)):
        try:
            Y[i] = float(f.subs(x, X[i]))
        except:
            Y[i] = None
    return X, Y
开发者ID:certik,项目名称:sympy-oldcore,代码行数:29,代码来源:sample.py


示例9: __new__

 def __new__(cls, dimension):
     dimension = sympify(dimension)
     r = cls.eval(dimension)
     if isinstance(r, Basic):
         return r
     obj = Basic.__new__(cls, dimension)
     return obj
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:7,代码来源:hilbert.py


示例10: __new__

 def __new__(cls, M):
     if not isinstance(M, Matrix):
         M = Matrix(M)
     data = Tuple(*M._mat)
     shape = Tuple(*sympify(M.shape))
     obj = Basic.__new__(cls, data, shape)
     obj._mat = M
     return obj
开发者ID:aeberspaecher,项目名称:sympy,代码行数:8,代码来源:blockmatrix.py


示例11: __new__

    def __new__(cls, mat):
        if not mat.is_Matrix:
            raise TypeError("input to Trace, %s, is not a matrix" % str(mat))

        if not mat.is_square:
            raise ShapeError("Trace of a non-square matrix")

        return Basic.__new__(cls, mat)
开发者ID:mattpap,项目名称:sympy,代码行数:8,代码来源:trace.py


示例12: _new

 def _new(cls, *args, **kwargs):
     if len(args) == 1 and isinstance(args[0], ImmutableMatrix):
         return args[0]
     rows, cols, flat_list = MatrixBase._handle_creation_inputs(*args, **kwargs)
     rows = Integer(rows)
     cols = Integer(cols)
     mat = Tuple(*flat_list)
     return Basic.__new__(cls, rows, cols, mat)
开发者ID:hastebrot,项目名称:sympy,代码行数:8,代码来源:immutable.py


示例13: __new__

    def __new__(cls, *args):
        # args should be a tuple - a variable length argument list
        obj = Basic.__new__(cls, *args)
        obj._circuit = Mul(*args)
        obj._rules = generate_gate_rules(args)
        obj._eq_ids = generate_equivalent_ids(args)

        return obj
开发者ID:Acebulf,项目名称:sympy,代码行数:8,代码来源:identitysearch.py


示例14: __new__

 def __new__(cls, mat):
     if not isinstance(mat, Matrix):
         mat = Matrix(mat)
     data = Tuple(*mat.mat)
     shape = Tuple(*sympify(mat.shape))
     obj = Basic.__new__(cls, data, shape)
     obj.mat = mat
     return obj
开发者ID:BDGLunde,项目名称:sympy,代码行数:8,代码来源:blockmatrix.py


示例15: set_v_max

 def set_v_max(self, v_max):
     if v_max is None:
         self._v_max = None
         return
     try:
         self._v_max = Basic.sympify(v_max)
         float(self._v_max.evalf())
     except:
         raise ValueError("v_max could not be interpreted as a number.")
开发者ID:certik,项目名称:sympy-oldcore,代码行数:9,代码来源:plot_interval.py


示例16: test_expr_fns

def test_expr_fns():
    from sympy.strategies.rl import rebuild
    from sympy import Add
    x, y = map(Symbol, 'xy')
    expr = x + y**3
    e = bottom_up(lambda x: x + 1, expr_fns)(expr)
    b = bottom_up(lambda x: Basic.__new__(Add, x, 1), basic_fns)(expr)

    assert rebuild(b) == e
开发者ID:AALEKH,项目名称:sympy,代码行数:9,代码来源:test_traverse.py


示例17: __new__

 def __new__(cls, pspace, symbol=None):
     if symbol is None:
         # Allow single arg, representing pspace == PSpace()
         pspace, symbol = PSpace(), pspace
     if not isinstance(symbol, Symbol):
         raise TypeError("symbol should be of type Symbol")
     if not isinstance(pspace, PSpace):
         raise TypeError("pspace variable should be of type PSpace")
     return Basic.__new__(cls, pspace, symbol)
开发者ID:BiosPsucheZoe,项目名称:sympy,代码行数:9,代码来源:rv.py


示例18: set_v_min

 def set_v_min(self, v_min):
     if v_min is None:
         self._v_min = None
         return
     try:
         self._v_min = Basic.sympify(v_min)
         float(self._v_min.evalf())
     except:
         raise ValueError("v_min could not be interpreted as a number.")
开发者ID:certik,项目名称:sympy-oldcore,代码行数:9,代码来源:plot_interval.py


示例19: __new__

	def __new__(cls, num, denom=None):
		obj = Basic.__new__(cls)
		if denom is None:
			if isinstance(num, str):
				obj.p, obj.q = parse_rational(num)
		else:
			obj.p = num
			obj.q = denom
		return obj
开发者ID:kwangkim,项目名称:fourU,代码行数:9,代码来源:utils.py


示例20: __new__

 def __new__(cls, sym, dist):
     if isinstance(dist, SingleContinuousDistribution):
         return SingleContinuousPSpace(sym, dist)
     if isinstance(dist, SingleDiscreteDistribution):
         return SingleDiscretePSpace(sym, dist)
     if isinstance(sym, string_types):
         sym = Symbol(sym)
     if not isinstance(sym, Symbol):
         raise TypeError("s should have been string or Symbol")
     return Basic.__new__(cls, sym, dist)
开发者ID:asmeurer,项目名称:sympy,代码行数:10,代码来源:joint_rv.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sympy.C类代码示例发布时间:2022-05-27
下一篇:
Python sympy.Add类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap