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

Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Polynomials/standard_complex_poly_systems_io.adb, Revision 1.1

1.1     ! maekawa     1: with integer_io,Numbers_io;             use integer_io,Numbers_io;
        !             2: with Communications_with_User;          use Communications_with_User;
        !             3: with Symbol_Table,Symbol_Table_io;
        !             4: with Standard_Complex_Polynomials;      use Standard_Complex_Polynomials;
        !             5:
        !             6: package body Standard_Complex_Poly_Systems_io is
        !             7:
        !             8: -- SCANNING THE LINE FOR A NATURAL NUMBER :
        !             9:
        !            10:   function Scan_Line ( file : in file_type ) return natural is
        !            11:
        !            12:     m : natural := 0;
        !            13:     ch : character;
        !            14:
        !            15:   begin
        !            16:     while not END_OF_LINE(file) loop
        !            17:       get(file,ch);
        !            18:       case ch is
        !            19:         when '0' => m := 10*m;
        !            20:         when '1' => m := 10*m + 1;
        !            21:         when '2' => m := 10*m + 2;
        !            22:         when '3' => m := 10*m + 3;
        !            23:         when '4' => m := 10*m + 4;
        !            24:         when '5' => m := 10*m + 5;
        !            25:         when '6' => m := 10*m + 6;
        !            26:         when '7' => m := 10*m + 7;
        !            27:         when '8' => m := 10*m + 8;
        !            28:         when '9' => m := 10*m + 9;
        !            29:         when others => null;
        !            30:       end case;
        !            31:     end loop;
        !            32:     return m;
        !            33:   end Scan_Line;
        !            34:
        !            35: -- EXCEPTION HANDLERS :
        !            36:
        !            37:   procedure Write_Symbol_Table is
        !            38:
        !            39:   -- DESCRIPTION :
        !            40:   --   Writes the current list of symbols on one line on standard output.
        !            41:
        !            42:   begin
        !            43:     put("Current symbols : ");
        !            44:     for i in 1..Symbol_Table.Number loop
        !            45:       Symbol_Table_io.put(Symbol_Table.Get(i)); put(" ");
        !            46:     end loop;
        !            47:     new_line;
        !            48:   end Write_Symbol_Table;
        !            49:
        !            50:   procedure Handler ( k : in natural ) is
        !            51:   begin
        !            52:     put(" raised while reading polynomial "); put(k,1);
        !            53:     put_line(".");
        !            54:   end Handler;
        !            55:
        !            56: -- THE INPUT OPERATIONS :
        !            57:
        !            58:   procedure get ( n : in out natural; s : in out Poly_Sys ) is
        !            59:   begin
        !            60:     get(Standard_Input,n,s);
        !            61:   end get;
        !            62:
        !            63:   procedure get ( n,m : in out natural; s : in out Poly_Sys ) is
        !            64:   begin
        !            65:     get(Standard_Input,n,m,s);
        !            66:   end get;
        !            67:
        !            68:   procedure get ( file : in file_type;
        !            69:                   n : in out natural; s : in out Poly_Sys ) is
        !            70:
        !            71:     i : integer := s'first;
        !            72:
        !            73:   begin
        !            74:     get(file,n);
        !            75:     while i <= s'first+n-1 loop
        !            76:       get(file,s(i));
        !            77:       i := i+1;
        !            78:     end loop;
        !            79:   exception
        !            80:     when ILLEGAL_CHARACTER    => put("ILLEGAL_CHARACTER");    Handler(i); raise;
        !            81:     when ILLEGAL_SYMBOL       => put("ILLEGAL_SYMBOL");       Handler(i); raise;
        !            82:     when ILLEGAL_OPERATION    => put("ILLEGAL_OPERATION");    Handler(i); raise;
        !            83:     when INFINITE_NUMBER      => put("INFINITE_NUMBER");      Handler(i); raise;
        !            84:     when OVERFLOW_OF_UNKNOWNS => put("OVERFLOW_OF_UNKNOWNS"); Handler(i);
        !            85:                                  Write_Symbol_Table; raise;
        !            86:     when BAD_BRACKET          => put("BAD_BRACKET");          Handler(i); raise;
        !            87:   end get;
        !            88:
        !            89:   procedure get ( file : in file_type;
        !            90:                   n,m : in out natural; s : in out Poly_Sys ) is
        !            91:
        !            92:     i : integer := s'first;
        !            93:
        !            94:   begin
        !            95:     get(file,n);
        !            96:     m := Scan_Line(file);
        !            97:     while i <= s'first+n-1 loop
        !            98:       get(file,s(i));
        !            99:       i := i+1;
        !           100:     end loop;
        !           101:   exception
        !           102:     when ILLEGAL_CHARACTER    => put("ILLEGAL_CHARACTER");    Handler(i); raise;
        !           103:     when ILLEGAL_SYMBOL       => put("ILLEGAL_SYMBOL");       Handler(i); raise;
        !           104:     when ILLEGAL_OPERATION    => put("ILLEGAL_OPERATION");    Handler(i); raise;
        !           105:     when INFINITE_NUMBER      => put("INFINITE_NUMBER");      Handler(i); raise;
        !           106:     when OVERFLOW_OF_UNKNOWNS => put("OVERFLOW_OF_UNKNOWNS"); Handler(i);
        !           107:                                  Write_Symbol_Table; raise;
        !           108:     when BAD_BRACKET          => put("BAD_BRACKET");          Handler(i); raise;
        !           109:   end get;
        !           110:
        !           111:   procedure get ( s : in out Poly_Sys ) is
        !           112:   begin
        !           113:     get(Standard_Input,s);
        !           114:   end get;
        !           115:
        !           116:   procedure get ( file : in file_type; s : in out Poly_Sys ) is
        !           117:
        !           118:     i : integer := s'first;
        !           119:
        !           120:   begin
        !           121:     while i <= s'last loop
        !           122:       get(file,s(i));
        !           123:       i := i+1;
        !           124:     end loop;
        !           125:   exception
        !           126:     when ILLEGAL_CHARACTER    => put("ILLEGAL_CHARACTER");    Handler(i); raise;
        !           127:     when ILLEGAL_SYMBOL       => put("ILLEGAL_SYMBOL");       Handler(i); raise;
        !           128:     when ILLEGAL_OPERATION    => put("ILLEGAL_OPERATION");    Handler(i); raise;
        !           129:     when INFINITE_NUMBER      => put("INFINITE_NUMBER");      Handler(i); raise;
        !           130:     when OVERFLOW_OF_UNKNOWNS => put("OVERFLOW_OF_UNKNOWNS"); Handler(i);
        !           131:                                  Write_Symbol_Table; raise;
        !           132:     when BAD_BRACKET          => put("BAD_BRACKET");          Handler(i); raise;
        !           133:   end get;
        !           134:
        !           135: -- MORE USER FRIENDLY INPUT OPERATIONS :
        !           136:
        !           137:   procedure get ( lp : in out Link_to_Poly_Sys ) is
        !           138:
        !           139:     inpt : file_type;
        !           140:     n,m : natural;
        !           141:     onfile : character;
        !           142:
        !           143:   begin
        !           144:   --------------------------------------------
        !           145:   --  GETTING THE DIMENSION OF THE PROBLEM  --
        !           146:   --------------------------------------------
        !           147:     loop
        !           148:       put("Is the system on a file ? (y/n/i=info) ");
        !           149:       Ask_Alternative(onfile,"yni");
        !           150:       if onfile = 'i'
        !           151:        then new_line; Display_Format; new_line;
        !           152:       end if;
        !           153:       exit when onfile /= 'i';
        !           154:     end loop;
        !           155:     new_line;
        !           156:     if onfile = 'y'
        !           157:      then declare
        !           158:             procedure Read is
        !           159:             begin
        !           160:               put_line("Reading the name of the input file.");
        !           161:               Read_Name_and_Open_File(inpt);
        !           162:               get(inpt,n);
        !           163:             end Read;
        !           164:           begin
        !           165:            Read;
        !           166:           exception
        !           167:             when others => put_line("The data on the file is not correct.");
        !           168:                            put_line("A natural number is expected first.");
        !           169:                           put_line("Supply another file name."); Close(inpt);
        !           170:                            Read;
        !           171:           end;
        !           172:      else put("Give the number of polynomials : "); Read_Natural(n);
        !           173:     end if;
        !           174:   ---------------------------------------
        !           175:   --  GETTING THE POLYNOMIAL SYSTEM :  --
        !           176:   ---------------------------------------
        !           177:     if Symbol_Table.Empty
        !           178:      then Symbol_Table.Init(n);
        !           179:     end if;
        !           180:     lp := new Poly_Sys(1..n);
        !           181:     declare
        !           182:       procedure Read is
        !           183:       begin
        !           184:         if onfile = 'y'
        !           185:          then m := Scan_Line(inpt);
        !           186:               get(inpt,lp.all);
        !           187:               Close(inpt);
        !           188:          else put("Give the number of unknowns : "); Read_Natural(m);
        !           189:               put("Give "); put(n,2);
        !           190:               if n = 1
        !           191:                then put_line(" polynomial : ");
        !           192:                else put_line(" polynomials : ");
        !           193:               end if;
        !           194:               get(lp.all);
        !           195:               skip_line;  -- skip end_of_line symbol
        !           196:         end if;
        !           197:       exception
        !           198:         when others => if onfile = 'y' then Close(inpt); end if;
        !           199:                        put_line("Polynomial system read : "); put(lp.all,'*');
        !           200:                        raise;
        !           201:       end Read;
        !           202:     begin
        !           203:       Read;
        !           204:     exception
        !           205:       when others =>
        !           206:              if onfile = 'y'
        !           207:               then put_line("The polynomials on the file are incorrect."
        !           208:                           & " Try again...");
        !           209:               else put_line("The polynomials are incorrect. Try again...");
        !           210:              end if;
        !           211:              Clear(lp); Symbol_Table.Clear;
        !           212:              get(lp);
        !           213:     end;
        !           214:
        !           215:   end get;
        !           216:
        !           217:   procedure get ( file : in file_type; lp : in out Link_to_Poly_Sys ) is
        !           218:
        !           219:     n : natural;
        !           220:
        !           221:   begin
        !           222:     get(file,n);
        !           223:     lp := new Poly_Sys(1..n);
        !           224:     if Symbol_Table.Empty
        !           225:      then Symbol_Table.Init(n);
        !           226:     end if;
        !           227:     get(file,lp.all);
        !           228:     skip_line(file);    -- skip end_of_line symbol
        !           229:   end get;
        !           230:
        !           231: -- THE OUTPUT OPERATIONS :
        !           232:
        !           233:   procedure put ( n : in natural; s : in Poly_Sys; pow : in power := '*' ) is
        !           234:   begin
        !           235:     put(Standard_Output,n,s,pow);
        !           236:   end put;
        !           237:
        !           238:   procedure put ( n,m : in natural; s : in Poly_Sys; pow : in power := '*' ) is
        !           239:   begin
        !           240:     put(Standard_Output,n,m,s,pow);
        !           241:   end put;
        !           242:
        !           243:   procedure put ( file : in file_type; n : in natural; s : in Poly_Sys;
        !           244:                   pow : in power := '*' ) is
        !           245:   begin
        !           246:     put(file,n,2); new_line(file);
        !           247:     put(file,s,pow);
        !           248:   end put;
        !           249:
        !           250:   procedure put ( file : in file_type; n,m : in natural; s : in Poly_Sys;
        !           251:                   pow : in power := '*' ) is
        !           252:   begin
        !           253:     put(file,n,2); put(file," "); put(file,m,2); new_line(file);
        !           254:     put(file,s,pow);
        !           255:   end put;
        !           256:
        !           257:   procedure put ( s : in Poly_Sys; pow : in power ) is
        !           258:   begin
        !           259:     put(Standard_Output,s,pow);
        !           260:   end put;
        !           261:
        !           262:   procedure put ( file : in file_type; s : in Poly_Sys; pow : in power ) is
        !           263:   begin
        !           264:     for i in s'range loop
        !           265:       put(file,s(i),pow); new_line(file);
        !           266:     end loop;
        !           267:   end put;
        !           268:
        !           269:   procedure put ( s : in Poly_Sys ) is
        !           270:   begin
        !           271:     put(Standard_Output,s,'*');
        !           272:   end put;
        !           273:
        !           274:   procedure put ( file : in file_type; s : in Poly_Sys ) is
        !           275:   begin
        !           276:     put(file,s,'*');
        !           277:   end put;
        !           278:
        !           279:   procedure put_line ( s : in Poly_Sys ) is
        !           280:   begin
        !           281:     put_line(Standard_Output,s);
        !           282:   end put_line;
        !           283:
        !           284:   procedure put_line ( file : in file_type; s : in Poly_Sys ) is
        !           285:   begin
        !           286:     put_line(file,s,'*');
        !           287:   end put_line;
        !           288:
        !           289:   procedure put_line ( s : in Poly_Sys; pow : in Power ) is
        !           290:   begin
        !           291:     put_line(Standard_Output,s,pow);
        !           292:   end put_line;
        !           293:
        !           294:   procedure put_line ( file : in file_type; s : in Poly_Sys; pow : in Power ) is
        !           295:   begin
        !           296:     put(file,s'length,2); new_line(file);
        !           297:     for i in s'range loop
        !           298:       put_line(file,s(i),pow);
        !           299:     end loop;
        !           300:   end put_line;
        !           301:
        !           302:   procedure Display_Format is
        !           303:
        !           304:     s : array(1..3) of string(1..65);
        !           305:
        !           306:   begin
        !           307:     s(1):="  A  complex  polynomial  system  is  denoted  by  the  dimension";
        !           308:     s(2):="followed  by  as  many  complex  multivariate  polynomials as the";
        !           309:     s(3):="dimension.  The dimension is a positive natural number.          ";
        !           310:     for i in s'range loop
        !           311:       put_line(s(i));
        !           312:     end loop;
        !           313:     Standard_Complex_Polynomials_io.Display_Format;
        !           314:   end Display_Format;
        !           315:
        !           316: end Standard_Complex_Poly_Systems_io;

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