[BACK]Return to generic_laurent_polynomials.ads CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Polynomials

Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Polynomials/generic_laurent_polynomials.ads, Revision 1.1.1.1

1.1       maekawa     1: with Abstract_Ring;
                      2: with Standard_Integer_Vectors;
                      3:
                      4: generic
                      5:
                      6:   with package Ring is new Abstract_Ring(<>);
                      7:
                      8: package Generic_Laurent_Polynomials is
                      9:
                     10: -- DESCRIPTION :
                     11: --   This package represents Laurent polynomials in several variables with
                     12: --   coefficients over any ring, to be specified by instantiation.
                     13: --   The exponents can be negative.
                     14:
                     15:   use Ring;
                     16:
                     17: -- DATA STRUCTURES :
                     18:
                     19:   type Degrees is new Standard_Integer_Vectors.Link_to_Vector;
                     20:
                     21:   type Term is record
                     22:     cf : number;     -- coefficient of the term
                     23:     dg : Degrees;    -- the degrees of the term
                     24:   end record;
                     25:
                     26:   type Poly is private;
                     27:
                     28:   Null_Poly : constant Poly;    -- represents zero in the polynomial ring
                     29:   One_Poly : constant Poly;     -- represents one in the polynomial ring
                     30:
                     31: -- CONSTRUCTORS :
                     32:
                     33:   function Create ( n : natural ) return Poly;
                     34:   function Create ( n : number ) return Poly;
                     35:
                     36:   function Create ( t : Term ) return Poly;
                     37:
                     38:   procedure Copy ( t1 : in Term; t2 : in out Term );    -- makes a deep copy
                     39:   procedure Copy ( p: in Poly; q : in out Poly );
                     40:
                     41: -- SELECTORS :
                     42:
                     43:   function Equal ( t1,t2 : Term )  return boolean;
                     44:   function Equal ( p,q : Poly )  return boolean;
                     45:
                     46:   function Number_of_Unknowns ( p : Poly ) return natural;
                     47:   function Number_of_Terms    ( p : Poly ) return natural;
                     48:
                     49:   function Degree ( p : Poly ) return integer;              -- return deg(p);
                     50:
                     51:   function Maximal_Degree ( p : Poly; i : natural ) return integer;
                     52:              -- returns maximal degree of xi in p;
                     53:   function Maximal_Degrees ( p : Poly ) return Degrees;
                     54:              -- Maximal_Degrees(p)(i) = Maximal_Degree(p,i)
                     55:   function Minimal_Degree ( p : Poly; i : natural ) return integer;
                     56:              -- returns minimal degree of xi in p;
                     57:   function Minimal_Degrees ( p : Poly ) return Degrees;
                     58:              -- Minimal_Degrees(p)(i) = Minimal_Degree(p,i)
                     59:
                     60:   function "<" ( d1,d2 : Degrees ) return boolean;          -- return d1 < d2
                     61:   function ">" ( d1,d2 : Degrees ) return boolean;          -- return d1 > d2
                     62:
                     63:   function Coeff ( p : Poly; d : Degrees ) return number;
                     64:    -- Ex.: Coeff(c1*x^2+c2*x*y^3,(1 2))=c2;  Coeff(c1*x^2+c2,(1 0))=zero;
                     65:
                     66: -- ARITHMETICAL OPERATIONS :
                     67:
                     68:   function "+" ( p : Poly; t : Term ) return Poly;      -- return p+t;
                     69:   function "+" ( t : Term; p : Poly ) return Poly;      -- return t+p;
                     70:   function "+" ( p : Poly ) return Poly;                -- returns copy of p;
                     71:   function "+" ( p,q : Poly ) return Poly;              -- return p+q;
                     72:   function "-" ( p : Poly; t : Term ) return Poly;      -- return p-t;
                     73:   function "-" ( t : Term; p : Poly ) return Poly;      -- return t-p;
                     74:   function "-" ( p : Poly ) return Poly;                -- return -p;
                     75:   function "-" ( p,q : Poly ) return Poly;              -- return p-q;
                     76:   function "*" ( p : Poly; a : number ) return Poly;    -- return a*p;
                     77:   function "*" ( a : number; p : Poly ) return Poly;    -- return p*a;
                     78:   function "*" ( p : Poly; t : Term ) return Poly;      -- return p*t;
                     79:   function "*" ( t : Term; p : Poly ) return Poly;      -- return t*p;
                     80:   function "*" ( p,q : Poly ) return Poly;              -- return p*q;
                     81:
                     82:   procedure Add ( p : in out Poly; t : in Term );       -- p := p + t;
                     83:   procedure Add ( p : in out Poly; q : in Poly );       -- p := p + q;
                     84:   procedure Sub ( p : in out Poly; t : in Term );       -- p := p - t;
                     85:   procedure Min ( p : in out Poly );                    -- p := -p;
                     86:   procedure Sub ( p : in out Poly; q : in Poly );       -- p := p - q;
                     87:   procedure Mul ( p : in out Poly; a : in number );     -- p := p * a;
                     88:   procedure Mul ( p : in out Poly; t : in Term );       -- p := p * t;
                     89:   procedure Mul ( p : in out Poly; q : in Poly );       -- p := p * q;
                     90:
                     91:   function  Diff ( p : Poly; i : integer ) return Poly;
                     92:   procedure Diff ( p : in out Poly; i : in integer );
                     93:     -- symbolic differentiation w.r.t. the i-th unknown of p
                     94:
                     95: -- ITERATORS : run through all terms of p and apply the generic procedure.
                     96:
                     97:   generic
                     98:     with procedure process ( t : in out Term; continue : out boolean );
                     99:   procedure Changing_Iterator ( p : in out Poly );  -- t can be changed
                    100:   generic
                    101:     with procedure process ( t : in Term; continue : out boolean );
                    102:   procedure Visiting_Iterator ( p : in Poly );      -- t can only be read
                    103:
                    104: -- DESTRUCTORS : deallocate memory.
                    105:
                    106:   procedure Clear ( t : in out Term );
                    107:   procedure Clear ( p : in out Poly );
                    108:
                    109: private
                    110:
                    111:   type Poly_Rep;
                    112:   type Poly is access Poly_Rep;
                    113:
                    114:   Null_Poly : constant Poly := null;
                    115:
                    116:   One_Term : constant Term := (one,null);
                    117:   One_Poly : constant Poly := Create(One_Term);
                    118:
                    119: end Generic_Laurent_Polynomials;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>