obj::calc::Product Class Reference

Has Exponented factors & an exponent. More...

Inheritance diagram for obj::calc::Product:
obj::calc::Operation obj::calc::Exponented obj::calc::Calculable obj::Printable obj::calc::Expandable obj::calc::Monomial obj::calc::BinomialIdentity

List of all members.

Public Member Functions

def __init__
 Constructor.
def is_null
 True if any of the factors is null.
def set_exponent
 Sets the exponent of the Product.
def get_elements
 Allow the subclasses to access to their elements.
def get_info
 Allow the subclasses to access this field.
def operator
 Defines the performed Operation as a Product.
def __cmp__
 Compares two Products Returns 0 if all factors are the same in the same order and if the exponents are also the same /!\ a × b will be different from b × a It's not a mathematical comparison, but a "displayable"'s one.
def is_equivalent_to_a_single_1
 True if the Product contains only single 1s.
def is_equivalent_to_a_single_minus_1
 True if the Product can be displayed as a single -1 For instance, the Product 1×1×(-1)×1.
def is_equivalent_to_a_single_0
 True if the object can be displayed as a single 0 For instance, the Product 0×0×0×0 (but not 0×1).
def is_reducible
 True if the Product is reducible This is based on the result of the get_factors_list method.
def multiply_symbol_is_required
 True if the usual writing rules require a × between two factors.
def requires_brackets
 True if (one)self requires brackets inside of a Product.
def requires_inner_brackets
 True if the argument requires inner brackets The reason for requiring them is having an exponent different from 1 and several terms or factors (in the case of Products & Sums).
def get_factors_list_except
 Returns the factors' list of the Product except the given one.
def get_first_factor
 Returns the first Sum/Item factor of the Product.
def get_minus_signs_nb
 Returns the number of - signs (negative factors) in the Product.
def get_factors_list
 Returns the factors' list of a given kind (numeric, literal.
def set_factor
def calculate_next_step
 Returns the next calculated step of a numeric Product.
def order
 Returns the Product once put in order.
def reduce_
 Return a reduced Product (if possible) For instance, giving this Product : 2x × (-4x²) × (x + 3)³ × 5 × (x²)³ × (-1)² × (2×3)², reduce_() would return : -1440 * x^9 * (x + 3)³.
def expand_and_reduce_next_step
 Returns the next step of reduction of the Product It won't check if it is expandable.
def make_string
 Creates a string of the given object in the given ML.

Detailed Description

Has Exponented factors & an exponent.

Iterable. Two display modes.

Definition at line 2786 of file __init__.py.


Member Function Documentation

def obj::calc::Product::__cmp__ (   self,
  objct 
)

Compares two Products Returns 0 if all factors are the same in the same order and if the exponents are also the same /!\ a × b will be different from b × a It's not a mathematical comparison, but a "displayable"'s one.

Returns:
0 if all factors are the same in the same order & the exponent

Definition at line 2966 of file __init__.py.

def obj::calc::Product::__init__ (   self,
  arg 
)

Constructor.

Warning:
Might raise an UncompatibleType exception.
Parameters:
arg None|Product|Number|Exponented|[Numbers|Exponenteds] In the case of the list, the Products having an exponant equal to 1 won't be treated so that their factors are inserted in the current Product instead of inserting a factor as a Product. If it would, then the compact and non compact display properties might be lost. (For instance, multiplying two Monomials and setting the compact display field of the resulting Product to False would result in displaying all the Monomials Items which isn't always wished) If the argument isn't of the kinds listed above, an exception will be raised. Giving None or an empty list is equivalent to giving 1.
Returns:
An instance of Product

Definition at line 2808 of file __init__.py.

def obj::calc::Product::calculate_next_step (   self,
  options 
)

Returns the next calculated step of a numeric Product.

Todo:

This method is only very partially implemented (see source code)

The way the exponents are handled is still to be decided

the inner '-' signs (±(-2)) are not handled by this method so far

Reimplemented from obj::calc::Exponented.

Definition at line 3583 of file __init__.py.

def obj::calc::Product::expand_and_reduce_next_step (   self,
  options 
)

Returns the next step of reduction of the Product It won't check if it is expandable.

Either it IS and the object is not just a Product but an Expandable or it isn't.

Returns:
Exponented

Reimplemented from obj::calc::Exponented.

Reimplemented in obj::calc::Expandable, and obj::calc::BinomialIdentity.

Definition at line 3872 of file __init__.py.

def obj::calc::Product::get_factors_list (   self,
  given_kind 
)

Returns the factors' list of a given kind (numeric, literal.

..) For instance, for the product : 2x × (-4x²) × (x + 3)³ × 5 × (x²)³ × (-1)² × (2×3)², this method would return :

  • in the case of simple numeric items : [2, -4, 5, (-1)², 2², 3²]
  • in the case of simple literal items : [x, x², x**6]
  • in the "others" list : [(x+3)³] This method helps to reduce a Product. It doesn't calculate anything and doesn't manage exotic cases (imbricated Products...) which are too complex to foresee. As far as I could... (later note : but I'm not sure it doesn't manage them now, I might have done that later than this comment). It will still be convenient to reorder the factors of a Monomials Product.
    Parameters:
    given_kind : __.NUMERIC | __.LITERALS | __.OTHERS
    Returns:
    a list containing the factors
    Todo:
    The - signs of the literals should be treated as -1 in the numeric list (and shouldn't remain in the literals' list)

Definition at line 3456 of file __init__.py.

def obj::calc::Product::get_first_factor (   self  ) 

Returns the first Sum/Item factor of the Product.

Warning:
Maybe not functionnal because of the 1's... For instance, if <factor1,factor2> is a Product & [term1,term2] a Sum: <<2,3>,x> would return 2 <[2,3],x>² would return (2+3)² <<2x>²,4> would return 2²
Todo:
check the intricate case of <<[<0, 1>]>, 4>

Definition at line 3395 of file __init__.py.

def obj::calc::Product::is_equivalent_to_a_single_1 (   self  ) 

True if the Product contains only single 1s.

For instance, 1×1×1

Reimplemented from obj::calc::Calculable.

Definition at line 2989 of file __init__.py.

def obj::calc::Product::is_reducible (   self  ) 

True if the Product is reducible This is based on the result of the get_factors_list method.

Returns:
True|False
Todo:
check the comment in the code Fix the problem bound to the get_factors list not giving - signs of literals as -1 in the list of numerics.

Definition at line 3057 of file __init__.py.

def obj::calc::Product::make_string (   self,
  markup,
  options 
)

Creates a string of the given object in the given ML.

Parameters:
markup The markup dictionary to use
options Any options
Returns:
The formated string

Reimplemented from obj::Printable.

Reimplemented in obj::calc::BinomialIdentity.

Definition at line 3981 of file __init__.py.

def obj::calc::Product::multiply_symbol_is_required (   self,
  objct,
  position 
)

True if the usual writing rules require a × between two factors.

Parameters:
objct The other one
position The position (integer) of self in the Product
Todo:
check Why in source code
Returns:
True if the writing rules require × between self & obj

Reimplemented from obj::calc::Exponented.

Definition at line 3238 of file __init__.py.

def obj::calc::Product::requires_brackets (   self,
  position 
)

True if (one)self requires brackets inside of a Product.

For instance, a Sum with several terms or a negative Item would.

Parameters:
position The position of the object in the Product
Returns:
True if the object requires brackets in a Product

Reimplemented from obj::calc::Exponented.

Definition at line 3275 of file __init__.py.

def obj::calc::Product::requires_inner_brackets (   self  ) 

True if the argument requires inner brackets The reason for requiring them is having an exponent different from 1 and several terms or factors (in the case of Products & Sums).

Returns:
True if the object requires inner brackets

Reimplemented from obj::calc::Exponented.

Definition at line 3314 of file __init__.py.

def obj::calc::Product::set_factor (   self,
  n,
  arg 
)
Parameters:
n : number of the factor to set
arg : the object to put as n-th factor

Definition at line 3571 of file __init__.py.


The documentation for this class was generated from the following file:
Generated on Fri Dec 30 19:26:37 2011 for mathmaker by  doxygen 1.6.3