[BACK]Return to tableau_formats.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Main

Annotation of OpenXM_contrib/PHC/Ada/Main/tableau_formats.adb, Revision 1.1

1.1     ! maekawa     1: with integer_io;                         use integer_io;
        !             2: with Communications_with_User;           use Communications_with_User;
        !             3: with Standard_Floating_Numbers;          use Standard_Floating_Numbers;
        !             4: with Standard_Floating_Numbers_io;       use Standard_Floating_Numbers_io;
        !             5: with Standard_Complex_Numbers;           use Standard_Complex_Numbers;
        !             6: with Standard_Complex_Numbers_io;        use Standard_Complex_Numbers_io;
        !             7: with Standard_Natural_Vectors;
        !             8: with Standard_Integer_Vectors;
        !             9: with Standard_Complex_Vectors;
        !            10: with Standard_Complex_VecVecs;           use Standard_Complex_VecVecs;
        !            11: with Lists_of_Integer_Vectors;           use Lists_of_Integer_Vectors;
        !            12: with Lists_of_Integer_Vectors_io;        use Lists_of_Integer_Vectors_io;
        !            13: with Arrays_of_Integer_Vector_Lists;     use Arrays_of_Integer_Vector_Lists;
        !            14: with Arrays_of_Integer_Vector_Lists_io;  use Arrays_of_Integer_Vector_Lists_io;
        !            15: with Symbol_Table,Symbol_Table_io;       use Symbol_Table;
        !            16: with Standard_Complex_Polynomials;       use Standard_Complex_Polynomials;
        !            17: with Standard_Complex_Poly_Systems_io;   use Standard_Complex_Poly_Systems_io;
        !            18: with Power_Lists;                        use Power_Lists;
        !            19:
        !            20: package body Tableau_Formats is
        !            21:
        !            22: -- AUXILIARIES :
        !            23:
        !            24:   procedure Read_Symbols ( file : in file_type; n : in natural ) is
        !            25:
        !            26:   -- DESCRIPTION :
        !            27:   --   Reads n symbols from file.
        !            28:
        !            29:   begin
        !            30:     Symbol_Table.Init(n);
        !            31:     for i in 1..n loop
        !            32:       declare
        !            33:         s : Symbol;
        !            34:       begin
        !            35:         Symbol_Table_io.get(file,s);
        !            36:         Symbol_Table.Add(s);
        !            37:       end;
        !            38:     end loop;
        !            39:   end Read_Symbols;
        !            40:
        !            41:   procedure Write_Symbols ( file : in file_type ) is
        !            42:
        !            43:   -- DESCRIPTION :
        !            44:   --   Writes the content of the symbol table on file.
        !            45:
        !            46:     n : constant natural := Symbol_Table.Number;
        !            47:
        !            48:   begin
        !            49:     put(file,n,1); new_line(file);
        !            50:     for i in 1..n loop
        !            51:       declare
        !            52:         s : Symbol := Symbol_Table.Get(i);
        !            53:       begin
        !            54:         put(file," ");
        !            55:         Symbol_Table_io.put(file,s);
        !            56:       end;
        !            57:     end loop;
        !            58:     new_line(file);
        !            59:   end Write_Symbols;
        !            60:
        !            61:   procedure Read_Exponents ( file : in file_type;
        !            62:                              exp : in out Array_of_Lists ) is
        !            63:
        !            64:   -- DESCRIPTION :
        !            65:   --   Reads exponent vectors from file.
        !            66:   --   Each list of exponent vectors should be preceded by the number
        !            67:   --   of elements in the list.
        !            68:
        !            69:     n : constant natural := exp'length;
        !            70:     m : natural;
        !            71:
        !            72:   begin
        !            73:     for i in exp'range loop
        !            74:       get(file,m);
        !            75:       get(file,n,m,exp(i));
        !            76:     end loop;
        !            77:   end Read_Exponents;
        !            78:
        !            79:   procedure Write_Exponents ( file : in file_type; p : in Poly_Sys ) is
        !            80:
        !            81:   -- DESCRIPTION :
        !            82:   --   Writes the supports of p on file.
        !            83:
        !            84:     exp : Array_of_Lists(p'range) := Create(p);
        !            85:
        !            86:   begin
        !            87:     for i in exp'range loop
        !            88:       put(file,Length_Of(exp(i)),1); new_line(file);
        !            89:       put(file,exp(i));
        !            90:     end loop;
        !            91:     Deep_Clear(exp);
        !            92:   end Write_Exponents;
        !            93:
        !            94:   procedure Read_Coefficients
        !            95:                ( file : in file_type;
        !            96:                  exp : in Array_of_Lists; flt : in boolean;
        !            97:                  cff : in out VecVec ) is
        !            98:
        !            99:   -- DESCRIPTION :
        !           100:   --   Reads the coefficient from file, given the supports.
        !           101:
        !           102:     f : double_float;
        !           103:
        !           104:   begin
        !           105:     for i in cff'range loop
        !           106:       cff(i) := new Standard_Complex_Vectors.Vector(1..Length_Of(exp(i)));
        !           107:       for j in cff(i)'range loop
        !           108:         if flt
        !           109:          then get(file,f);         cff(i)(j) := Create(f);
        !           110:          else get(file,cff(i)(j));
        !           111:         end if;
        !           112:       end loop;
        !           113:     end loop;
        !           114:   end Read_Coefficients;
        !           115:
        !           116:   procedure Write_Coefficients ( file : in file_type; flt : in boolean;
        !           117:                                  p : in Poly ) is
        !           118:
        !           119:   -- DESCRIPTION :
        !           120:   --   Writes the coefficients of the polynomial on file.
        !           121:   --   If flt, then the imaginary parts will be omitted.
        !           122:
        !           123:     procedure Write_Coefficient_of_Term ( t : in Term; cont : out boolean ) is
        !           124:     begin
        !           125:       if flt
        !           126:        then put(file,REAL_PART(t.cf));
        !           127:        else put(file,t.cf);
        !           128:       end if;
        !           129:       new_line(file);
        !           130:       cont := true;
        !           131:     end Write_Coefficient_of_Term;
        !           132:
        !           133:     procedure Write_Coefficients_of_Terms is
        !           134:       new Visiting_Iterator(Write_Coefficient_of_Term);
        !           135:
        !           136:   begin
        !           137:     Write_Coefficients_of_Terms(p);
        !           138:   end Write_Coefficients;
        !           139:
        !           140:   procedure Write_Coefficients ( file : in file_type; flt : in boolean;
        !           141:                                  p : in Poly_Sys ) is
        !           142:
        !           143:   -- DESCRIPTION :
        !           144:   --   Writes the coefficients of the polynomial system on file.
        !           145:   --   If flt, then the imaginary parts will be omitted.
        !           146:
        !           147:   begin
        !           148:     for i in p'range loop
        !           149:       Write_Coefficients(file,flt,p(i));
        !           150:     end loop;
        !           151:   end Write_Coefficients;
        !           152:
        !           153:   function Create ( exp : Standard_Integer_Vectors.Vector;
        !           154:                     cff : Complex_Number ) return Term is
        !           155:
        !           156:   -- DESCRIPTION :
        !           157:   --   Creates a term from exponent vector and coefficient.
        !           158:
        !           159:     res : Term;
        !           160:
        !           161:   begin
        !           162:     res.cf := cff;
        !           163:     res.dg := new Standard_Natural_Vectors.Vector(exp'range);
        !           164:     for i in exp'range loop
        !           165:       res.dg(i) := exp(i);
        !           166:     end loop;
        !           167:     return res;
        !           168:   end Create;
        !           169:
        !           170:   function Create ( exp : List; cff : Standard_Complex_Vectors.Vector )
        !           171:                   return Poly is
        !           172:
        !           173:   -- DESCRIPTION :
        !           174:   --   Creates a polynomial from the exponents and the coefficients.
        !           175:
        !           176:     res : Poly;
        !           177:     tmp : List := exp;
        !           178:     lpt : Standard_Integer_Vectors.Link_to_Vector;
        !           179:
        !           180:   begin
        !           181:     for i in cff'range loop
        !           182:       lpt := Head_Of(tmp);
        !           183:       declare
        !           184:         t : Term := Create(lpt.all,cff(i));
        !           185:       begin
        !           186:         Add(res,t);
        !           187:       end;
        !           188:       tmp := Tail_Of(tmp);
        !           189:     end loop;
        !           190:     return res;
        !           191:   end Create;
        !           192:
        !           193:   function Create ( exp : Array_of_Lists; cff : VecVec ) return Poly_Sys is
        !           194:
        !           195:   -- DESCRIPTION :
        !           196:   --   Creates the polynomial system from the supports and coefficients.
        !           197:
        !           198:     res : Poly_Sys(exp'range);
        !           199:
        !           200:   begin
        !           201:     for i in res'range loop
        !           202:       res(i) := Create(exp(i),cff(i).all);
        !           203:     end loop;
        !           204:     return res;
        !           205:   end Create;
        !           206:
        !           207: -- TARGET ROUTINES :
        !           208:
        !           209:   procedure get ( file : in file_type; realcoeff : in boolean;
        !           210:                   p : out Link_to_Poly_Sys ) is
        !           211:
        !           212:     n : natural;
        !           213:
        !           214:   begin
        !           215:     get(file,n);
        !           216:     new_line;
        !           217:     put("Dimension : "); put(n,1); new_line;
        !           218:     Read_Symbols(file,n);
        !           219:     put("Symbols :");
        !           220:     for i in 1..n loop
        !           221:       put(" "); put(Symbol_Table.get(i));
        !           222:     end loop;
        !           223:     new_line;
        !           224:     declare
        !           225:       exp : Array_of_Lists(1..n);
        !           226:       cff : VecVec(1..n);
        !           227:       sys : Poly_Sys(1..n);
        !           228:     begin
        !           229:       Read_Exponents(file,exp);
        !           230:       put_line("The exponents : ");
        !           231:       put(exp);
        !           232:       Read_Coefficients(file,exp,realcoeff,cff);
        !           233:       put_line("The coefficients : ");
        !           234:       for i in cff'range loop
        !           235:         for j in cff(i)'range loop
        !           236:           put(cff(i)(j)); new_line;
        !           237:         end loop;
        !           238:         new_line;
        !           239:       end loop;
        !           240:       sys := Create(exp,cff);
        !           241:       put_line("The polynomial system : "); put(sys);
        !           242:       p := new Poly_Sys'(sys);
        !           243:     end;
        !           244:   end get;
        !           245:
        !           246:   procedure put ( file : in file_type; realcoeff : in boolean;
        !           247:                   p : in Poly_Sys ) is
        !           248:
        !           249:   begin
        !           250:     if not Symbol_Table.Empty
        !           251:      then Write_Symbols(file);
        !           252:     end if;
        !           253:     Write_Exponents(file,p);
        !           254:     Write_Coefficients(file,realcoeff,p);
        !           255:   end put;
        !           256:
        !           257: end Tableau_Formats;

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