Annotation of OpenXM_contrib/PHC/Ada/Root_Counts/Symmetry/symmetric_randomize.adb, Revision 1.1
1.1 ! maekawa 1: with Standard_Complex_Numbers; use Standard_Complex_Numbers;
! 2: with Standard_Random_Numbers; use Standard_Random_Numbers;
! 3: with Standard_Integer_Vectors; use Standard_Integer_Vectors;
! 4: with Standard_Complex_Laur_Polys; use Standard_Complex_Laur_Polys;
! 5: with Permutations,Permute_Operations; use Permutations,Permute_Operations;
! 6:
! 7: function Symmetric_Randomize ( p : Laur_Sys; v,w : List_of_Permutations )
! 8: return Laur_Sys is
! 9:
! 10: res : Laur_Sys(p'range);
! 11:
! 12: procedure Symmetric_Randomize_Terms ( index : in natural; py : in Poly ) is
! 13:
! 14: tpy : Term;
! 15:
! 16: procedure Permute_and_Randomize ( t : in Term ) is
! 17:
! 18: tmpv,tmpw : List_of_Permutations;
! 19:
! 20: begin
! 21: tmpv := v; tmpw := w;
! 22: while not Is_Null(tmpv) loop
! 23: declare
! 24: permt : Term := Permutation(Head_Of(tmpv).all)*t;
! 25: indw : natural := Head_Of(tmpw)(index);
! 26: begin
! 27: if Coeff(res(indw),permt.dg) = Create(0.0)
! 28: then Add(res(indw),permt);
! 29: end if;
! 30: Clear(permt);
! 31: end;
! 32: tmpv := Tail_Of(tmpv);
! 33: tmpw := Tail_Of(tmpw);
! 34: end loop;
! 35: end Permute_and_Randomize;
! 36:
! 37: procedure Pick_Term ( t : in Term; cont : out boolean ) is
! 38: begin
! 39: if Coeff(res(index),t.dg) = Create(0.0)
! 40: then Copy(t,tpy);
! 41: tpy.cf := Random1;
! 42: cont := false;
! 43: else cont := true;
! 44: end if;
! 45: end Pick_Term;
! 46: procedure Pick_A_Term is new Visiting_Iterator(Pick_Term);
! 47:
! 48: begin
! 49: tpy.cf := Create(0.0);
! 50: Pick_A_Term(py);
! 51: if tpy.cf /= Create(0.0)
! 52: then Permute_and_Randomize(tpy);
! 53: Clear(tpy);
! 54: end if;
! 55: end Symmetric_Randomize_Terms;
! 56:
! 57: begin
! 58: res := (res'range => Null_Poly);
! 59: for k in res'range loop
! 60: while Number_of_Terms(res(k)) < Number_of_Terms(p(k)) loop
! 61: Symmetric_Randomize_Terms(k,p(k));
! 62: end loop;
! 63: end loop;
! 64: return res;
! 65: end Symmetric_Randomize;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>