[BACK]Return to symmetric_randomize.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Root_Counts / Symmetry

File: [local] / OpenXM_contrib / PHC / Ada / Root_Counts / Symmetry / symmetric_randomize.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:31 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 Standard_Complex_Numbers;           use Standard_Complex_Numbers;
with Standard_Random_Numbers;            use Standard_Random_Numbers;
with Standard_Integer_Vectors;           use Standard_Integer_Vectors;
with Standard_Complex_Laur_Polys;        use Standard_Complex_Laur_Polys;
with Permutations,Permute_Operations;    use Permutations,Permute_Operations;

function Symmetric_Randomize ( p : Laur_Sys; v,w : List_of_Permutations )
                             return Laur_Sys is

  res : Laur_Sys(p'range);
  
  procedure Symmetric_Randomize_Terms ( index : in natural; py : in Poly ) is

    tpy : Term;

    procedure Permute_and_Randomize ( t : in Term ) is

      tmpv,tmpw : List_of_Permutations;

    begin
      tmpv := v;  tmpw := w;
      while not Is_Null(tmpv) loop
        declare
          permt : Term := Permutation(Head_Of(tmpv).all)*t;
          indw : natural := Head_Of(tmpw)(index);
        begin
          if Coeff(res(indw),permt.dg) = Create(0.0)
           then Add(res(indw),permt);
          end if;
          Clear(permt);
        end;
        tmpv := Tail_Of(tmpv); 
        tmpw := Tail_Of(tmpw);
      end loop;
    end Permute_and_Randomize;

    procedure Pick_Term ( t : in Term; cont : out boolean ) is
    begin
      if Coeff(res(index),t.dg) = Create(0.0)
       then Copy(t,tpy);
            tpy.cf := Random1;
            cont := false;
       else cont := true;
      end if;
    end Pick_Term;
    procedure Pick_A_Term is new Visiting_Iterator(Pick_Term);

  begin
    tpy.cf := Create(0.0);
    Pick_A_Term(py);
    if tpy.cf /= Create(0.0)
     then Permute_and_Randomize(tpy);
          Clear(tpy);
    end if;
  end Symmetric_Randomize_Terms;

begin
  res := (res'range => Null_Poly);
  for k in res'range loop
    while Number_of_Terms(res(k)) < Number_of_Terms(p(k)) loop
      Symmetric_Randomize_Terms(k,p(k));
    end loop;
  end loop;
  return res;
end Symmetric_Randomize;