algebramix_doc 0.3
polynomial< C, V > Class Template Reference

#include <polynomial.hpp>

List of all members.

Public Member Functions

Static Public Member Functions

Friends


Detailed Description

template<typename C, typename V = typename polynomial_variant_helper< C >::PV>
class mmx::polynomial< C, V >

Examples:

crt_test.cpp, polynomial_int_test.cpp, polynomial_integer_test.cpp, polynomial_modular_test.cpp, and polynomial_polynomial_test.cpp.

Definition at line 86 of file polynomial.hpp.


Constructor & Destructor Documentation

polynomial ( ) [inline]

Definition at line 99 of file polynomial.hpp.

                       {
    nat l= aligned_size<C,V> (0);
    rep= new Polynomial_rep (mmx_new<C> (l), 0, l, Format (no_format ()));
  }
polynomial ( const format< C > &  fm) [inline]

Definition at line 104 of file polynomial.hpp.

                                       {
    nat l= aligned_size<C,V> (0);
    rep= new Polynomial_rep (mmx_new<C> (l), 0, l, fm);
  }
polynomial ( const T &  x) [inline]

Definition at line 108 of file polynomial.hpp.

                                                      {
    nat l= aligned_size<C,V> (1);
    C c= as<C> (x);
    C* a= mmx_formatted_new<C> (l, get_format (c));
    a[0]= c;
    rep= new Polynomial_rep (a, 1, l, get_format (c));
    rep->normalize ();
  }
polynomial ( const polynomial< T, V > &  P) [inline]

Definition at line 118 of file polynomial.hpp.

                                        {
    Format fm= as<Format > (CF(P));
    nat l= aligned_size<C,V> (N(P));
    C* a= mmx_formatted_new<C> (l, fm);
    Pol::cast (a, seg (P), N(P));
    rep= new Polynomial_rep (a, N(P), l, fm);
    rep->normalize ();
  }
polynomial ( const polynomial< T, V > &  P,
const format< C > &  fm 
) [inline]

Definition at line 128 of file polynomial.hpp.

                                                          {
    nat l= aligned_size<C,V> (N(P));
    C* a= mmx_formatted_new<C> (l, fm);
    Pol::cast (a, seg (P), N(P));
    rep= new Polynomial_rep (a, N(P), l, fm);
    rep->normalize ();
  }
polynomial ( const C x,
nat  n 
) [inline]

Definition at line 135 of file polynomial.hpp.

                                 {
    nat l= aligned_size<C,V> (n+1);
    C* a= mmx_formatted_new<C> (l, get_format (x));
    Pol::clear (a, n);
    a[n]= x;
    rep= new Polynomial_rep (a, n+1, l, get_format (x));
    rep->normalize ();
  }
polynomial ( C a,
nat  n,
const format< C > &  fm 
) [inline]

Definition at line 143 of file polynomial.hpp.

                                                    {
    rep= new Polynomial_rep (a, n, fm);
  }
polynomial ( C a,
nat  n,
nat  l,
const format< C > &  fm 
) [inline]

Definition at line 146 of file polynomial.hpp.

                                                           {
    rep= new Polynomial_rep (a, n, l, fm);
  }
polynomial ( const vector< C > &  v) [inline]

Definition at line 149 of file polynomial.hpp.

                                  {
    nat l= aligned_size<C,V> (N(v));
    C* a= mmx_formatted_new<C> (l, CF(v));
    Pol::copy (a, seg (v), N(v));
    rep= new Polynomial_rep (a, N(v), l, CF(v));
    rep->normalize ();
  }
polynomial ( const iterator< C > &  it) [inline]

Definition at line 156 of file polynomial.hpp.

                                     {
    nat i, l=0;
    nat s= aligned_size<C,V> (0);
    C* a= mmx_formatted_new<C> (s, CF(it));
    rep= new Polynomial_rep (a, 0, s, CF(it));
    for (i=0; busy (it); i++, ++it) {
      if (i >= l) {
        l= max ((nat) 1, l<<1);
        rep->extend (l);
      }
      rep->a[i]= *it;
    }
    rep->normalize ();
  }

Member Function Documentation

static generic get_variable_name ( ) [inline, static]

Definition at line 93 of file polynomial.hpp.

Referenced by mmx::flatten(), and polynomial< series< C, V >, U >::get_variable_name().

                                             {
    return S::get_variable_name (); }
polynomial< C, V > & operator*= ( const C c)

Definition at line 422 of file polynomial.hpp.

                                   {
  typedef implementation<polynomial_linear,V> Pol;
  secure ();
  Pol::mul_sc (rep->a, c, rep->n);
  rep->normalize ();
  return *this;
}
polynomial< C, V > C polynomial< C, V > V polynomial< C, V > & operator+= ( const polynomial< C, V > &  P)

Definition at line 400 of file polynomial.hpp.

References mmx::extend(), mmx::N(), mmx::normalize(), and mmx::seg().

                                            {
  typedef implementation<polynomial_linear,V> Pol;
  secure ();
  nat n1= rep->n, n2= N(P);
  if (n1 < n2) rep -> extend (n2);
  Pol::add (rep->a, seg (P), n2);
  if (n1 == n2) rep -> normalize ();
  return *this;
}
polynomial< C, V > & operator-= ( const polynomial< C, V > &  P)

Definition at line 411 of file polynomial.hpp.

References mmx::N(), and mmx::seg().

                                            {
  typedef implementation<polynomial_linear,V> Pol;
  secure ();
  nat n1= rep->n, n2= N(P);
  if (n1 < n2) rep->extend (n2);
  Pol::sub (rep->a, seg (P), n2);
  if (n1 == n2) rep->normalize ();
  return *this;
}
polynomial< C, V > & operator/= ( const C c)

Definition at line 431 of file polynomial.hpp.

                                   {
  typedef implementation<polynomial_linear,V> Pol;
  secure ();
  Pol::div_sc (rep->a, c, rep->n);
  rep->normalize ();
  return *this;
}
C operator[] ( nat  i) const [inline]

Definition at line 176 of file polynomial.hpp.

                                    {
    return i<rep->n? rep->a[i]: promote (0, CF(*this)); }
static void set_variable_name ( const generic &  x) [inline, static]

Friends And Related Function Documentation

polynomial<C,V> copy ( const polynomial< C, V > &  P) [friend]

Definition at line 170 of file polynomial.hpp.

Referenced by polynomial< series< C, V >, U >::polynomial().

                                                      {
    nat n= N(P), l= aligned_size<C,V> (n);
    C* r= mmx_formatted_new<C> (l, CF(P));
    Pol::copy (r, seg (P), n);
    return Polynomial (r, n, l, CF(P));
  }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines