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

Annotation of OpenXM_contrib/PHC/Ada/Schubert/bracket_polynomials_io.adb, Revision 1.1.1.1

1.1       maekawa     1: with integer_io;                         use integer_io;
                      2: with Standard_Floating_Numbers;          use Standard_Floating_Numbers;
                      3: with Standard_Floating_Numbers_io;       use Standard_Floating_Numbers_io;
                      4: with Standard_Complex_Numbers;           use Standard_Complex_Numbers;
                      5: with Bracket_Monomials_io;               use Bracket_Monomials_io;
                      6:
                      7: package body Bracket_Polynomials_io is
                      8:
                      9:   procedure Write_Number ( file : in file_type; c : in Complex_Number;
                     10:                            ic : out integer ) is
                     11:
                     12:   -- DESCRIPTION :
                     13:   --   Writes the complex coefficient in a concise way.
                     14:
                     15:     f : double_float;
                     16:     i : integer := 0;
                     17:
                     18:   begin
                     19:     if IMAG_PART(c) /= 0.0
                     20:      then put(file,"(");
                     21:           put(file,REAL_PART(c)); put(file," + ");
                     22:           put(file,IMAG_PART(c));
                     23:           put(file,")");
                     24:      else f := REAL_PART(c);
                     25:           i := integer(f);
                     26:           if (f - double_float(i)) /= 0.0
                     27:            then put(file,f);
                     28:            else if i > 0
                     29:                  then put(file,"+");
                     30:                       if i /= 1
                     31:                        then put(file,i,1);
                     32:                       end if;
                     33:                  elsif i = -1
                     34:                      then put(file,"-");
                     35:                      else put(file,i,1);
                     36:                 end if;
                     37:           end if;
                     38:     end if;
                     39:     ic := i;
                     40:   end Write_Number;
                     41:
                     42:   procedure put ( t : in Bracket_Term ) is
                     43:   begin
                     44:     put(Standard_Output,t);
                     45:   end put;
                     46:
                     47:   procedure put ( file : in file_type; t : in Bracket_Term ) is
                     48:
                     49:     ic : integer;
                     50:
                     51:   begin
                     52:     Write_Number(file,t.coeff,ic);
                     53:     if ic /= 1 and ic /= -1
                     54:      then put(file,"*");
                     55:     end if;
                     56:     put(file,t.monom);
                     57:   end put;
                     58:
                     59:   procedure put ( p : in Bracket_Polynomial ) is
                     60:   begin
                     61:     put(Standard_Output,p);
                     62:   end put;
                     63:
                     64:   procedure put ( file : in file_type; p : in Bracket_Polynomial ) is
                     65:
                     66:     cnt : natural := 0;
                     67:
                     68:     procedure Write_Term ( t : in Bracket_Term; continue : out boolean ) is
                     69:     begin
                     70:       cnt := cnt + 1;
                     71:       if cnt > 4
                     72:        then cnt := 1;
                     73:             new_line(file);
                     74:       end if;
                     75:       put(file,t);
                     76:       continue := true;
                     77:     end Write_Term;
                     78:
                     79:     procedure Write_Terms is new Enumerate_Terms(Write_Term);
                     80:
                     81:   begin
                     82:     Write_Terms(p);
                     83:     put_line(file,";");
                     84:   end put;
                     85:
                     86: end Bracket_Polynomials_io;

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