![]() ![]() | ![]() |
File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Polynomials / generic_polynomial_systems.adb (download)
Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:26 2000 UTC (23 years, 10 months ago) by maekawa
Import the second public release of PHCpack. OKed by Jan Verschelde. |
with unchecked_deallocation; package body Generic_Polynomial_Systems is -- COPYING : procedure Copy ( p : in Poly_Sys; q : in out Poly_Sys ) is begin for i in p'range loop Copy(p(i),q(i)); end loop; end Copy; -- ARITHMETIC OPERATIONS : function "+" ( p,q : Poly_Sys ) return Poly_Sys is res : Poly_Sys(p'range); begin for i in p'range loop res(i) := p(i)+q(i); end loop; return res; end "+"; function "-" ( p,q : Poly_Sys ) return Poly_Sys is res : Poly_Sys(p'range); begin for i in p'range loop res(i) := p(i)-q(i); end loop; return res; end "-"; function "-" ( p : Poly_Sys ) return Poly_Sys is res : Poly_Sys(p'range); begin for i in p'range loop res(i) := -p(i); end loop; return res; end "-"; function "*" ( a : number; p : Poly_Sys ) return Poly_Sys is res : Poly_Sys(p'range); begin for k in p'range loop res(k) := a*p(k); end loop; return res; end "*"; function "*" ( p : Poly_Sys; a : number ) return Poly_Sys is begin return a*p; end "*"; procedure Add ( p : in out Poly_Sys; q : in Poly_Sys ) is begin for i in p'range loop Add(p(i),q(i)); end loop; end Add; procedure Sub ( p : in out Poly_Sys; q : in Poly_Sys ) is begin for i in p'range loop Sub(p(i),q(i)); end loop; end Sub; procedure Min ( p : in out Poly_Sys ) is begin for i in p'range loop Min(p(i)); end loop; end Min; procedure Mul ( p : in out Poly_Sys; a : in number ) is begin for k in p'range loop Mul(p(k),a); end loop; end Mul; function Diff ( p : Poly_Sys; i : natural ) return Poly_Sys is res : Poly_Sys(p'range); begin for j in p'range loop res(j) := Diff(p(j),i); end loop; return res; end Diff; procedure Diff ( p : in out Poly_Sys; i : in natural ) is begin for j in p'range loop Diff(p(j),i); end loop; end Diff; -- DESTRUCTORS : procedure Clear ( p : in out Poly_Sys ) is begin for i in p'range loop Clear(p(i)); end loop; end Clear; procedure Clear ( p : in out Link_to_Poly_Sys ) is procedure free is new unchecked_deallocation(Poly_Sys,Link_to_Poly_Sys); begin if p /= null then Clear(p.all); end if; free(p); end Clear; end Generic_Polynomial_Systems;