X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/25ce908cffca380f930182a77c1e5a4491042a1c..454a26a54cc7ff563ab278567f3bbad9c6ff42bb:/doc/linexpr.rst?ds=inline diff --git a/doc/linexpr.rst b/doc/linexpr.rst index 3771d5f..eb2f704 100644 --- a/doc/linexpr.rst +++ b/doc/linexpr.rst @@ -1,9 +1,14 @@ Linear Expression Module ======================== +This class implements linear expressions. A linear expression is…. -This class implements linear expressions. - +.. 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. @@ -12,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. - Return the number of vriables in an expression. + + .. py:method:: values(self) + + Return the coefficient and constant values of an expression. + + .. py:method:: __add__(self, other) + + 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) @@ -39,7 +98,43 @@ This class implements linear expressions. .. py:method:: tosympy(self) 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 +