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

File: [local] / OpenXM_contrib / PHC / Ada / Schubert / ts_brackpols.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:32 2000 UTC (23 years, 6 months ago) by maekawa
Branch: PHC, MAIN
CVS Tags: v2, maekawa-ipv6, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, HEAD
Changes since 1.1: +0 -0 lines

Import the second public release of PHCpack.

OKed by Jan Verschelde.

with text_io,integer_io;               use text_io,integer_io;
with Complex_Numbers;                  use Complex_Numbers;
with Brackets,Brackets_io;             use Brackets,Brackets_io;
with Bracket_Monomials;                use Bracket_Monomials;
with Bracket_Monomials_io;             use Bracket_Monomials_io;
with Bracket_Polynomials;              use Bracket_Polynomials;
with Bracket_Polynomials_io;           use Bracket_Polynomials_io;

procedure ts_brackpols is

  procedure Compare ( p : in Bracket_Polynomial; t : in Bracket_Term ) is

  -- DESCRIPTION :
  --   Compares every monomial in p with the term t.

    procedure Compare ( tt : in Bracket_Term; continue : out boolean ) is
    begin
      if tt < t
       then put(tt); put(" < "); put(t);
       elsif tt > t
           then put(tt); put(" > "); put(t);
           else put(tt); put(" = "); put(t);
      end if;
      new_line;
      if tt > t
       then put(tt); put(" > "); put(t);
       elsif tt < t
           then put(tt); put(" < "); put(t);
           else put(tt); put(" = "); put(t);
      end if;
      new_line;
      continue := true;
    end Compare;
    procedure Compare_Terms is new Enumerate_Terms(Compare);

  begin
    Compare_Terms(p);
  end Compare;

  procedure Interactive_Read ( d : in natural; t : out Bracket_Term ) is

    m : natural;
    b : Bracket(1..d);
    s,c : integer;
    bm : Bracket_Monomial;

  begin
    c := 1;
    put("Give the number of brackets in the monomial : "); get(m);
    for i in 1..m loop
      put("Give "); put(d,1); put(" numbers for the ");
      put(i,1); put("th bracket : "); get(b,s);
      c := s*c;
      Multiply(bm,b);
    end loop;
    put_line("The bracket monomial : "); put(bm); new_line;
    if c > 0
     then t.coeff := CMPLX(1.0);
     else t.coeff := -CMPLX(1.0);
    end if;
    t.monom := bm;
  end Interactive_Read;

  procedure Interactive_Read ( d : in natural; p : out Bracket_Polynomial ) is

    m : natural;
    bp : Bracket_Polynomial;

  begin
    put_line("Reading a bracket polynomial.");
    put("Give the number of monomials : "); get(m);
    for i in 1..m loop
      declare
        bt : Bracket_Term;
      begin
        put("Reading bracket monomial "); put(i,1); new_line;
        Interactive_Read(d,bt);
        put_line("The bracket term : "); put(bt);
        Compare(bp,bt);
        Add(bp,bt);
        put_line("The bracket polynomial : "); put(bp);
      end;
    end loop;
    p := bp;
  end Interactive_Read;

  procedure Main is

    d : natural;
    bp : Bracket_Polynomial;

  begin
    put("Give the number of entries in the brackets : "); get(d);
    Interactive_Read(d,bp);
    put_line("The bracket polynomial : "); put(bp);
  end Main;

begin
  Main;
end ts_brackpols;