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

File: [local] / OpenXM_contrib / PHC / Ada / Root_Counts / Implift / power_lists.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:29 2000 UTC (23 years, 8 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_Integer_Vectors;           use Standard_Integer_Vectors;

package body Power_Lists is

  function Create ( p : Standard_Complex_Polynomials.Poly ) return List is

    res,res_last : List;

    procedure Visit_Term ( t : in Standard_Complex_Polynomials.Term;
                           cont : out boolean ) is

      h : Link_to_Vector;

    begin
      h := new Standard_Integer_Vectors.Vector(t.dg'range);
      for j in h'range loop
        h(j) := t.dg(j);
      end loop;
      Append(res,res_last,h);
      cont := true;
    end Visit_Term;
    procedure Visit_Terms is
      new Standard_Complex_Polynomials.Visiting_Iterator(Visit_Term);

  begin
    Visit_Terms(p);
    return res;
  end Create;

  function Create ( p : Standard_Complex_Laur_Polys.Poly ) return List is

    res,res_last : List;

    procedure Visit_Term ( t : in Standard_Complex_Laur_Polys.Term;
                           cont : out boolean ) is

      h : Link_to_Vector;

    begin
      h := new Standard_Integer_Vectors.Vector(t.dg'range);
      for j in h'range loop
        h(j) := t.dg(j);
      end loop;
      Append(res,res_last,h);
      cont := true;
    end Visit_Term;
    procedure Visit_Terms is
      new Standard_Complex_Laur_Polys.Visiting_Iterator(Visit_Term);

  begin
    Visit_Terms(p);
    return res;
  end Create;

  function Select_Terms ( p : Standard_Complex_Polynomials.Poly; l : List )
                        return Standard_Complex_Polynomials.Poly is

    res : Standard_Complex_Polynomials.Poly
        := Standard_Complex_Polynomials.Null_Poly;

    procedure Select_Term ( t : in Standard_Complex_Polynomials.Term;
                            cont : out boolean ) is

      v : Standard_Integer_Vectors.Vector(t.dg'range);

    begin
      for i in v'range loop
        v(i) := t.dg(i);
      end loop;
      if Is_In(l,v)
       then Add(res,t);
      end if;
      cont := true;
    end Select_Term;
    procedure Select_Poly is
      new Standard_Complex_Polynomials.Visiting_Iterator ( Select_Term );

  begin
    Select_Poly(p);
    return res;
  end Select_Terms;

  function Select_Terms ( p : Standard_Complex_Laur_Polys.Poly; l : List )
                        return Standard_Complex_Laur_Polys.Poly is

    res : Standard_Complex_Laur_Polys.Poly
        := Standard_Complex_Laur_Polys.Null_Poly;

    procedure Select_Term ( t : in Standard_Complex_Laur_Polys.Term;
                            cont : out boolean ) is

      v : Standard_Integer_Vectors.Vector(t.dg'range);

    begin
      for i in v'range loop
        v(i) := t.dg(i);
      end loop;
      if Is_In(l,v)
       then Add(res,t);
      end if;
      cont := true;
    end Select_Term;
    procedure Select_Poly is
      new Standard_Complex_Laur_Polys.Visiting_Iterator ( Select_Term );

  begin
    Select_Poly(p);
    return res;
  end Select_Terms;

  function Create ( p : Poly_Sys ) return Array_of_Lists is

    res : Array_of_Lists(p'range);

  begin
    for i in p'range loop
      res(i) := Create(p(i));
    end loop;
    return res;
  end Create;

  function Create ( p : Laur_Sys ) return Array_of_Lists is

    res : Array_of_Lists(p'range);

  begin
    for i in p'range loop
      res(i) := Create(p(i));
    end loop;
    return res;
  end Create;

  function Select_Terms ( p : Poly_Sys; al : Array_of_Lists ) 
                        return Poly_Sys is

    res : Poly_Sys(p'range);

  begin
    for i in p'range loop
      res(i) := Select_Terms(p(i),al(i));
    end loop;
    return res;
  end Select_Terms;

  function Select_Terms ( p : Laur_Sys; al : Array_of_Lists ) 
                        return Laur_Sys is

    res : Laur_Sys(p'range);

  begin
    for i in p'range loop
      res(i) := Select_Terms(p(i),al(i));
    end loop;
    return res;
  end Select_Terms;

end Power_Lists;