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

Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Polynomials/matrix_indeterminates.adb, Revision 1.1.1.1

1.1       maekawa     1: with Characters_and_Numbers;             use Characters_and_Numbers;
                      2: with Standard_Complex_Numbers;           use Standard_Complex_Numbers;
                      3: with Standard_Natural_Vectors;
                      4:
                      5: package body Matrix_Indeterminates is
                      6:
                      7:   procedure Initialize_Symbols ( n,d : in natural ) is
                      8:   begin
                      9:     Symbol_Table.Init(n*d);
                     10:     for i in 1..n loop
                     11:       for j in 1..d loop
                     12:         declare
                     13:           s : Symbol := X_ij(i,j);
                     14:         begin
                     15:           Symbol_Table.Add(s);
                     16:         end;
                     17:       end loop;
                     18:     end loop;
                     19:   end Initialize_Symbols;
                     20:
                     21:   function X_ij ( i,j : natural ) return Symbol is
                     22:
                     23:     res : Symbol;
                     24:
                     25:   begin
                     26:     res(1) := 'x';
                     27:     res(2) := Convert_Hexadecimal(i);
                     28:     res(3) := Convert_Hexadecimal(j);
                     29:     for i in 4..res'last loop
                     30:       res(i) := ' ';
                     31:     end loop;
                     32:     return res;
                     33:   end X_ij;
                     34:
                     35:   function Monomial ( n,d,i,j : natural ) return Poly is
                     36:
                     37:     res : Poly;
                     38:     t : Term;
                     39:
                     40:   begin
                     41:     t.cf := Create(1.0);
                     42:     t.dg := new Standard_Natural_Vectors.Vector'(1..n*d => 0);
                     43:     t.dg((i-1)*d+j) := 1;
                     44:     res := Create(t);
                     45:     Clear(t.dg);
                     46:     return res;
                     47:   end Monomial;
                     48:
                     49:   procedure Reduce_Symbols ( locmap : in Matrix ) is
                     50:
                     51:     d : constant natural := locmap'length(2);
                     52:
                     53:   begin
                     54:     for i in reverse locmap'range(1) loop
                     55:       for j in reverse locmap'range(2) loop
                     56:         if locmap(i,j) /= 2
                     57:          then Symbol_Table.Remove(X_ij(i,j));
                     58:         end if;
                     59:       end loop;
                     60:     end loop;
                     61:   end Reduce_Symbols;
                     62:
                     63:   procedure Clear_Symbols is
                     64:   begin
                     65:     Symbol_Table.Clear;
                     66:   end Clear_Symbols;
                     67:
                     68: end Matrix_Indeterminates;

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