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

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

1.1     ! maekawa     1: with text_io,integer_io;                 use text_io,integer_io;
        !             2: with Symbol_Table;
        !             3: with Standard_Complex_Numbers;           use Standard_Complex_Numbers;
        !             4: with Standard_Complex_Numbers_io;        use Standard_Complex_Numbers_io;
        !             5: with Standard_Natural_Vectors;
        !             6: with Standard_Complex_Vectors;           use Standard_Complex_Vectors;
        !             7: with Standard_Complex_Vectors_io;        use Standard_Complex_Vectors_io;
        !             8: with Standard_Integer_VecVecs;
        !             9: with Standard_Integer_VecVecs_io;        use Standard_Integer_VecVecs_io;
        !            10: with Standard_Complex_Polynomials;       use Standard_Complex_Polynomials;
        !            11: with Standard_Complex_Polynomials_io;    use Standard_Complex_Polynomials_io;
        !            12: with Standard_Complex_Poly_Functions;    use Standard_Complex_Poly_Functions;
        !            13: with Exponent_Vectors;                   use Exponent_Vectors;
        !            14:
        !            15: procedure ts_expvec is
        !            16:
        !            17: -- DESCRIPTION :
        !            18: --   This routine provides basic testing routines for complex polynomials.
        !            19:
        !            20:   procedure Read ( m : out natural;
        !            21:                    q : out Standard_Complex_Polynomials.Poly ) is
        !            22:
        !            23:   -- DESCRIPTION :
        !            24:   --   Tests the input/output of a polynomial in several variables
        !            25:   --   and with complex coefficients.
        !            26:
        !            27:     n : natural;
        !            28:     p : Standard_Complex_Polynomials.Poly;
        !            29:
        !            30:   begin
        !            31:     put("Give the number of variables : "); get(n);
        !            32:     Symbol_Table.Init(n);
        !            33:     put_line("Give a polynomial (terminate with ;) : "); get(p);
        !            34:     put_line("Your polynomial : "); put(p); new_line;
        !            35:     Symbol_Table.Clear;
        !            36:     q := p;
        !            37:     m := n;
        !            38:   end Read;
        !            39:
        !            40:   function Coeff ( p : Standard_Complex_Polynomials.Poly;
        !            41:                    e : Standard_Integer_VecVecs.VecVec )
        !            42:                  return Standard_Complex_Vectors.Vector is
        !            43:
        !            44:     res : Standard_Complex_Vectors.Vector(e'range);
        !            45:     deg : Degrees := new Standard_Natural_Vectors.Vector(e(e'first)'range);
        !            46:
        !            47:   begin
        !            48:     for i in e'range loop
        !            49:       for j in e(i)'range loop
        !            50:         deg(j) := e(i)(j);
        !            51:       end loop;
        !            52:       res(i) := Coeff(p,deg);
        !            53:     end loop;
        !            54:     Clear(deg);
        !            55:     return res;
        !            56:   end Coeff;
        !            57:
        !            58:   procedure Test_Eval ( n : in natural;
        !            59:                         p : in Standard_Complex_Polynomials.Poly ) is
        !            60:
        !            61:     ev : constant Standard_Integer_VecVecs.VecVec := Create(p);
        !            62:     cf : Standard_Complex_Vectors.Vector(ev'range) := Coeff(p,ev);
        !            63:     x : Standard_Complex_Vectors.Vector(1..n);
        !            64:     y1,y2 : Complex_Number;
        !            65:     ans : character;
        !            66:
        !            67:   begin
        !            68:     put_line("The exponent vectors : "); put(ev);
        !            69:     put_line("The coefficients : ");
        !            70:     for i in cf'range loop
        !            71:       put(cf(i)); new_line;
        !            72:     end loop;
        !            73:     loop
        !            74:       put("Give "); put(n,1); put_line(" complex numbers : ");
        !            75:       for i in x'range loop
        !            76:         get(x(i));
        !            77:       end loop;
        !            78:       y1 := Eval(p,x);
        !            79:       y2 := Eval(ev,cf,x);
        !            80:       put("Eval poly p(x) : "); put(y1); new_line;
        !            81:       put("Eval cf*ev^x   : "); put(y2); new_line;
        !            82:       put("Do you want more tests ? (y/n) "); get(ans);
        !            83:       exit when ans /= 'y';
        !            84:     end loop;
        !            85:   end Test_Eval;
        !            86:
        !            87:   procedure Main is
        !            88:
        !            89:     n : natural;
        !            90:     p : Poly;
        !            91:
        !            92:   begin
        !            93:     new_line;
        !            94:     put_line("Interactive testing of the operations on exponent vectors.");
        !            95:     new_line;
        !            96:     Read(n,p);
        !            97:     Test_Eval(n,p);
        !            98:   end Main;
        !            99:
        !           100: begin
        !           101:   Main;
        !           102: end ts_expvec;

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