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

File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Matrices / ts_natvec.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:24 2000 UTC (23 years, 7 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 Standard_Natural_Vectors;
with Standard_Natural_Vectors_io;
with Standard_Natural_VecVecs;
with Standard_Natural_VecVecs_io;
with Multprec_Natural_Vectors;
with Multprec_Natural_Vectors_io;
with Multprec_Natural_VecVecs;
with Multprec_Natural_VecVecs_io;

procedure ts_natvec is

-- DESCRIPTION :
--   Tests the vector packages of standard and multi-precision naturals.

  procedure Test_Standard_Vectors_io is

    use Standard_Natural_Vectors,Standard_Natural_Vectors_io;

    n : natural;

  begin
    put("Give the dimension : "); get(n);
    declare
      nv : Vector(1..n);
    begin
      put("Give "); put(n,1); put_line(" natural numbers : "); get(nv);
      put("Your vector : "); put(nv); new_line;
    end;
  end Test_Standard_Vectors_io;

  procedure Test_Standard_Addition is

    use Standard_Natural_Vectors,Standard_Natural_Vectors_io;

    n : natural;

  begin
    put("Give the dimension : "); get(n);
    declare
      a,b,sum : Vector(1..n);
    begin
      put("Give "); put(n,1); put_line(" natural numbers : "); get(a);
      put("-> vector a  : "); put(a); new_line;
      put("Give "); put(n,1); put_line(" natural numbers : "); get(b);
      put("-> vector b  : "); put(b); new_line;
      sum := a+b;
      put(" The sum a+b : "); put(sum); new_line;
    end;
  end Test_Standard_Addition;

  procedure Test_Standard_VecVecs_io is

    use Standard_Natural_VecVecs,Standard_Natural_VecVecs_io;

    n : natural;

  begin
    put("Give the dimension : "); get(n);
    declare
      nv : VecVec(1..n);
    begin
      put("Give "); put(n,1); put_line(" natural vectors : "); get(n,nv);
      put_line("Your vector : "); put(nv); new_line;
    end;
  end Test_Standard_VecVecs_io;

  procedure Test_Multprec_Vectors_io is

    use Multprec_Natural_Vectors,Multprec_Natural_Vectors_io;

    n : natural;

  begin
    put("Give the dimension : "); get(n);
    declare
      nv : Vector(1..n);
    begin
      put("Give "); put(n,1); put_line(" natural numbers : "); get(nv);
      put_line("Your vector : "); put_line(nv);
    end;
  end Test_Multprec_Vectors_io;

  procedure Test_Multprec_VecVecs_io is

    use Multprec_Natural_VecVecs,Multprec_Natural_VecVecs_io;

    n : natural;

  begin
    put("Give the dimension : "); get(n);
    declare
      nv : VecVec(1..n);
    begin
      put("Give "); put(n,1); put_line(" natural vectors : "); get(n,nv);
      put_line("Your vector : "); put_line(nv);
    end;
  end Test_Multprec_VecVecs_io;

  procedure Main is

    ans : character;

  begin
    new_line;
    put_line("Interactive testing of vectors of natural numbers.");
    loop
      new_line;
      put_line("Choose one of the following : ");
      put_line("  0. exit the program.");
      put_line("  1. io of vectors of standard natural numbers.");
      put_line("  2. addition of vectors of standard natural numbers.");
      put_line("  3. io of vectors of vectors of standard natural numbers.");
      put_line("  4. io of vectors of multi-precision natural numbers.");
      put_line("  5. io of vectors of vectors of multi-precision naturals.");
      put("Make your choice (0,1,2,3, or 4) : "); get(ans);
      case ans is
        when '1' => Test_Standard_Vectors_io;
        when '2' => Test_Standard_Addition;
        when '3' => Test_Standard_VecVecs_io;
        when '4' => Test_Multprec_Vectors_io;
        when '5' => Test_Multprec_VecVecs_io;
        when others => null;
      end case;
      exit when (ans = '0');
    end loop;
  end Main;

begin
  Main;
end ts_natvec;