Implemented crisscross algorithm for solving LP problems.
[sympycore.git] / sympycore / ring / interface.py
bloba9a90289427cec53afdeee14591f326f5b618812
2 __all__ = ['RingInterface']
4 from ..core import init_module
6 @init_module
7 def _init(m):
8 from ..core import heads
9 for n,h in heads.iterNameValue(): setattr(m, n, h)
11 class RingInterface:
13 zero = 0
14 one = 1
16 @classmethod
17 def Add(cls, *seq):
18 """ Construct a symbolic expression with addition operands
19 list representation.
20 """
21 return ADD.reevaluate(cls, seq)
23 @classmethod
24 def Sub(cls, *seq):
25 return SUB.reevaluate(cls, seq)
27 @classmethod
28 def Mul(cls, *seq):
29 """ Construct a symbolic expression with multiplication
30 operands list representation.
31 """
32 return MUL.reevaluate(cls, seq)
34 @classmethod
35 def Div(cls, *seq):
36 return DIV.reevaluate(cls, seq)
38 @classmethod
39 def Pow(cls, base, exp):
40 return POW.new(cls, (base, exp))
42 @classmethod
43 def Terms(cls, *seq):
44 """ Construct a symbolic expression with term-coefficient
45 representation.
46 """
47 return TERM_COEFF_DICT.reevaluate(cls, dict(seq))
49 @classmethod
50 def Factors(cls, *seq):
51 """ Construct a symbolic expression with base-exponent
52 representation.
53 """
54 return BASE_EXP_DICT.reevaluate(cls, dict(seq))
56 @classmethod
57 def Polynom(cls, *seq, **kws):
58 """ Construct a symbolic expression with exponent-coefficient
59 representation:
61 Polynom(x,y) -> Algebra(EXP_COEFF_DICT, Pair((x,y), {(1,0):1, (0,1):1}))
62 Polynom(x,y, variables=(x,y,z)) -> Algebra(EXP_COEFF_DICT, Pair((x,y,z), {(1,0,0):1, (0,1,0):1}))
63 """
64 r = cls.Add(*seq)
65 return r.head.to_EXP_COEFF_DICT(cls, r.data, r, kws.get('variables'))