Annotation of OpenXM_contrib/PHC/Ada/Schubert/ts_detsys.adb, Revision 1.1
1.1 ! maekawa 1: with text_io,integer_io; use text_io,integer_io;
! 2: with Timing_Package; use Timing_Package;
! 3: with Standard_Complex_Numbers; use Standard_Complex_Numbers;
! 4: with Standard_Complex_Numbers_io; use Standard_Complex_Numbers_io;
! 5: with Standard_Complex_Vectors;
! 6: with Standard_Complex_Vectors_io; use Standard_Complex_Vectors_io;
! 7: with Standard_Complex_Matrices;
! 8: with Standard_Complex_Matrices_io; use Standard_Complex_Matrices_io;
! 9: with Standard_Random_Matrices; use Standard_Random_Matrices;
! 10: with Standard_Complex_VecMats; use Standard_Complex_VecMats;
! 11: with Standard_Complex_Poly_Matrices;
! 12: with Standard_Complex_Poly_Matrices_io; use Standard_Complex_Poly_Matrices_io;
! 13: with Matrix_Indeterminates;
! 14: with Standard_Complex_Poly_Systems; use Standard_Complex_Poly_Systems;
! 15: with Standard_Complex_Poly_SysFun; use Standard_Complex_Poly_SysFun;
! 16: with Standard_Complex_Jaco_Matrices; use Standard_Complex_Jaco_Matrices;
! 17: with Brackets; use Brackets;
! 18: with Symbolic_Minor_Equations; use Symbolic_Minor_Equations;
! 19: with Determinantal_Systems; use Determinantal_Systems;
! 20:
! 21: procedure ts_detsys is
! 22:
! 23: -- DESCRIPTION :
! 24: -- This procedure tests the operations in the package Determinantal_Systems.
! 25:
! 26: function Random_Sequence ( n,n1,n2 : natural ) return VecMat is
! 27:
! 28: -- DESCRIPTION :
! 29: -- Returns a sequence of n randomly generated n1-by-n2 matrices.
! 30:
! 31: res : VecMat(1..n);
! 32:
! 33: begin
! 34: for i in 1..n loop
! 35: res(i) := new Standard_Complex_Matrices.Matrix'(Random_Matrix(n1,n2));
! 36: end loop;
! 37: return res;
! 38: end Random_Sequence;
! 39:
! 40: function Vector_Rep ( mat : Standard_Complex_Matrices.Matrix )
! 41: return Standard_Complex_Vectors.Vector is
! 42:
! 43: -- DESCRIPTION :
! 44: -- Returns the elements in the matrix as one long vector.
! 45:
! 46: res : Standard_Complex_Vectors.Vector(1..mat'length(1)*mat'length(2));
! 47: cnt : natural := 0;
! 48:
! 49: begin
! 50: for i in mat'range(1) loop
! 51: for j in mat'range(2) loop
! 52: cnt := cnt+1;
! 53: res(cnt) := mat(i,j);
! 54: end loop;
! 55: end loop;
! 56: return res;
! 57: end Vector_Rep;
! 58:
! 59: procedure Test_Evaluator ( m,p : in natural ) is
! 60:
! 61: -- DESCRIPTION :
! 62: -- Test the evaluating routine in determinantal systems.
! 63:
! 64: n : constant natural := m+p;
! 65: mp : constant natural := m*p;
! 66: xmat : constant Standard_Complex_Matrices.Matrix := Random_Matrix(n,p);
! 67: xvec : constant Standard_Complex_Vectors.Vector := Vector_Rep(xmat);
! 68: l : constant Standard_Complex_Matrices.Matrix := Random_Matrix(n,m);
! 69: planes : VecMat(1..mp) := Random_Sequence(mp,n,m);
! 70: deteva : Standard_Complex_Vectors.Vector(1..mp) := Eval(planes,xmat);
! 71: detjac : Standard_Complex_Matrices.Matrix(1..mp,1..n*p)
! 72: := Diff(planes,xmat);
! 73: top : Bracket(1..p) := (1..p => 1);
! 74: bottom : Bracket(1..p) := (1..p => n);
! 75: xpm : Standard_Complex_Poly_Matrices.Matrix(1..n,1..p)
! 76: := Localization_Pattern(n,top,bottom);
! 77: sys : Poly_Sys(1..m*p) := Polynomial_Equations(planes,xpm);
! 78: syseva : Standard_Complex_Vectors.Vector(1..mp) := Eval(sys,xvec);
! 79: sysjac : Jaco_Mat(1..mp,1..n*p) := Create(sys);
! 80: jaceva : Standard_Complex_Matrices.Matrix(1..mp,1..n*p)
! 81: := Eval(sysjac,xvec);
! 82: nb : natural;
! 83: timer : Timing_Widget;
! 84:
! 85: begin
! 86: Matrix_Indeterminates.Initialize_Symbols(n,p);
! 87: put_line("the matrix of indeterminates : "); put(xpm);
! 88: put("Intersecting random "); put(p,1); put("-plane with ");
! 89: put(m*p,1); put(" random "); put(m,1); put_line("-planes.");
! 90: put_line("Determinantal Evaluation : "); put_line(deteva); new_line;
! 91: put_line("Polynomial Evaluation : "); put_line(syseva); new_line;
! 92: put_line("Determinantal Differentation : "); put(detjac,2); new_line;
! 93: put_line("Polynomial Differentation : "); put(jaceva,2); new_line;
! 94: put("Give number of evaluations : "); get(nb);
! 95: tstart(timer);
! 96: for i in 1..nb loop
! 97: deteva := Eval(planes,xmat);
! 98: detjac := Diff(planes,xmat);
! 99: end loop;
! 100: tstop(timer);
! 101: print_times(Standard_Output,timer,"determinantal evaluations");
! 102: tstart(timer);
! 103: for i in 1..nb loop
! 104: syseva := Eval(sys,xvec);
! 105: jaceva := Eval(sysjac,xvec);
! 106: end loop;
! 107: tstop(timer);
! 108: print_times(Standard_Output,timer,"polynomial evaluations");
! 109: end Test_Evaluator;
! 110:
! 111: procedure Main is
! 112:
! 113: m,p : natural;
! 114:
! 115: begin
! 116: put("Give m : "); get(m);
! 117: put("Give p : "); get(p);
! 118: Test_Evaluator(m,p);
! 119: end Main;
! 120:
! 121: begin
! 122: new_line;
! 123: put_line("Polynomial systems generated from determinantal expansions.");
! 124: new_line;
! 125: Main;
! 126: end ts_detsys;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>