![]() ![]() | ![]() |
File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Polynomials / matrix_indeterminates.adb (download)
Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:27 2000 UTC (23 years, 10 months ago) by maekawa
Import the second public release of PHCpack. OKed by Jan Verschelde. |
with Characters_and_Numbers; use Characters_and_Numbers; with Standard_Complex_Numbers; use Standard_Complex_Numbers; with Standard_Natural_Vectors; package body Matrix_Indeterminates is procedure Initialize_Symbols ( n,d : in natural ) is begin Symbol_Table.Init(n*d); for i in 1..n loop for j in 1..d loop declare s : Symbol := X_ij(i,j); begin Symbol_Table.Add(s); end; end loop; end loop; end Initialize_Symbols; function X_ij ( i,j : natural ) return Symbol is res : Symbol; begin res(1) := 'x'; res(2) := Convert_Hexadecimal(i); res(3) := Convert_Hexadecimal(j); for i in 4..res'last loop res(i) := ' '; end loop; return res; end X_ij; function Monomial ( n,d,i,j : natural ) return Poly is res : Poly; t : Term; begin t.cf := Create(1.0); t.dg := new Standard_Natural_Vectors.Vector'(1..n*d => 0); t.dg((i-1)*d+j) := 1; res := Create(t); Clear(t.dg); return res; end Monomial; procedure Reduce_Symbols ( locmap : in Matrix ) is d : constant natural := locmap'length(2); begin for i in reverse locmap'range(1) loop for j in reverse locmap'range(2) loop if locmap(i,j) /= 2 then Symbol_Table.Remove(X_ij(i,j)); end if; end loop; end loop; end Reduce_Symbols; procedure Clear_Symbols is begin Symbol_Table.Clear; end Clear_Symbols; end Matrix_Indeterminates;