X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/997e3c68590b274c372a6785cda5a69887683891..7fff25bf40e4db570565586fb49165d1675002c2:/doc/linexpr.rst diff --git a/doc/linexpr.rst b/doc/linexpr.rst index 2aab652..eb2f704 100644 --- a/doc/linexpr.rst +++ b/doc/linexpr.rst @@ -1,11 +1,14 @@ Linear Expression Module ======================== -This class implements linear expressions. +This class implements linear expressions. A linear expression is…. .. py:class:: Expression - - + + .. py:method:: __new__(cls, coefficients=None, constant=0) + + Create and return a new linear expression from a string or a list of coefficients and a constant. + .. py:method:: coefficient(self, symbol) Return the coefficient value of the given symbol. @@ -14,25 +17,79 @@ This class implements linear expressions. Return a list of the coefficients of an expression - .. py:method:: constant(self) + .. attribute:: constant Return the constant value of an expression. - .. py:method:: symbols(self) + .. attribute:: symbols Return a list of symbols in an expression. - .. py:method:: dimension(self) + .. attribute:: dimension + + Return the number of variables in an expression. + + .. py:method:: isconstant(self) + + Return ``True`` if an expression is a constant. + + .. py:method:: issymbol(self) + + Return ``True`` if an expression is a symbol. + + + .. py:method:: values(self) + + Return the coefficient and constant values of an expression. + + .. py:method:: __add__(self, other) - Return the number of vriables in an expression. + Return the sum of *self* and *other*. .. py:method:: __sub__(self, other) - Return the difference between two expressions. - + Return the difference between *self* and *other*. + + .. py:method:: __mul__(self, other) + + Return the product of *self* and *other* if *other* is a rational number. + + .. py:method:: __eq__(self, other) + + Test whether two expressions are equal. + + .. py:method:: __le__(self, other) + self <= other + + Create a new polyhedra from an expression with a single constraint as *self* less than or equal to *other*. + + .. py:method:: __lt__(self, other) + self < other + + Create a new polyhedra from an expression with a single constraint as *self* less than *other*. + + .. py:method:: __ge__(self, other) + self >= other + + Create a new polyhedra from an expression with a single constraint as *self* greater than or equal to *other*. + + .. py:method:: __gt__(self, other) + self > other + + Create a new polyhedra from an expression with a single constraint as *self* greater than *other*. + + .. py:method:: scaleint(self) + + Multiply an expression by a scalar to make all coefficients integer values. + .. py:method:: subs(self, symbol, expression=None) Subsitute the given value into an expression and return the resulting expression. + + + .. py:method:: fromstring(self) + + Create an expression from a string. .. py:method:: fromsympy(self) @@ -43,8 +100,41 @@ This class implements linear expressions. Return an expression as a sympy object. .. py:class:: Symbol(Expression) + + .. py:method:: __new__(cls, name) + + Create and return a symbol from a string. + + .. py:method:: symbols(names) + + This function returns a sequence of symbols with names taken from names argument, which can be a comma or whitespace delimited string, or a sequence of strings. + + .. py:method:: asdummy(self) + Return a symbol as a :class:`Dummy` Symbol. .. py:class:: Dummy(Symbol) -This class returns a dummy symbol to ensure that each no variables are repeated in an expression + This class returns a dummy symbol to ensure that no variables are repeated in an expression. This is useful when the user needs to have a unique symbol, for example as a temporary one in some calculation, which is going to be substituted for something else at the end anyway. + + .. py:method:: __new__(cls, name=None) + + Create and return a new dummy symbol. + + +.. py:class:: Rational(Expression, Fraction) + + This class represents integers and rational numbers of any size. + + .. attribute:: constant + + Return rational as a constant. + + .. py:method:: isconstant(self) + + Test whether a value is a constant. + + .. py:method:: fromsympy(cls, expr) + + Create a rational object from a sympy expression +