realroot_doc 0.1.1
monom< C, E > Struct Template Reference

Monomial class. More...

#include <monomial.hpp>

List of all members.

Public Types

Public Member Functions

Public Attributes

Static Public Attributes

Friends


Detailed Description

template<class C, class E = dynamic_exp<int>>
struct mmx::monom< C, E >

Monomial class.

Definition at line 62 of file monomial.hpp.


Member Typedef Documentation

typedef C coeff_t

Definition at line 86 of file monomial.hpp.

typedef E container_t

Definition at line 82 of file monomial.hpp.

typedef E exp_t

Definition at line 75 of file monomial.hpp.

typedef E::exponent_t exponent_t

Definition at line 83 of file monomial.hpp.

typedef int index_t

Definition at line 81 of file monomial.hpp.

typedef C Scalar

Definition at line 87 of file monomial.hpp.

typedef monom<C,E> self_t

Definition at line 88 of file monomial.hpp.

typedef E::size_type size_type

Definition at line 85 of file monomial.hpp.


Constructor & Destructor Documentation

monom ( ) [inline]

Definition at line 91 of file monomial.hpp.

References monom< C, E >::rep().

         : _coef(),_expt() {
    rep().resize(0); //COUNT<self_t>(' ');
  }
monom ( const C &  c,
const exp_t r 
) [inline]

Definition at line 95 of file monomial.hpp.

:_coef(c), _expt(r){}
monom ( const C &  c) [inline]

Definition at line 96 of file monomial.hpp.

References monom< C, E >::rep().

                    : _coef(c),_expt() {
    rep().resize(0);
  } 
monom ( int  i) [inline]

Definition at line 99 of file monomial.hpp.

References monom< C, E >::rep().

              :_coef(i), _expt() {
    rep().resize(0);
  }
monom ( const std::string &  s,
int  d,
variables vars = variables::default_ 
)

monom x[i]**d

Construction of the monom $x_{i}^{d}$.

Definition at line 284 of file monomial.hpp.

References monom< C, E >::rep().

                                     :_coef(1) {
  if(d == 0)
    rep().resize(0);
 else
     {
       int i=vars[s];
       rep().reserve(i+1);
       for(int j=0;j<i;j++) rep().set_expt(j,0);
       rep().set_expt(i,d);
     }
}
monom ( const C &  c,
unsigned  s,
const AsSize  
) [inline]

Definition at line 104 of file monomial.hpp.

:_coef(c),_expt(s){}
monom ( const C &  c,
int  d,
unsigned  i 
)

monom c*x[i]**d

Construction of the monom $c\,x_{i}^{d}$.

Definition at line 299 of file monomial.hpp.

References monom< C, E >::rep().

                                             :_coef(c) {
  if(d == 0)
    rep().resize(0);
  else
    {
      rep().reserve(v+1);
      for(unsigned j=0;j<v;j++) rep().set_expt(j,0);
      rep().set_expt(v,d);
    }
}
monom ( const C &  c,
int  s,
int *  t 
) [inline]

Definition at line 108 of file monomial.hpp.

References monom< C, E >::rep().

                                   :_coef(c), _expt(s){
    for(int i=0;i<s;i++) rep()[i]= t[i];
  }
monom ( const char *  s,
variables vars = monom< C, E >::var 
)

Definition at line 312 of file monomial.hpp.

References mmx::let::assign(), COEF, Monomial, synaps_input, synaps_inputlim, mmx::synaps_inputptr, TERMINATE, XID, yylex(), and yylval.

                                                 {
  int n = strlen(s);
  if (s[n-1]=='\n') {n--;}
  if(s[n-1]==';')
    {
      synaps_input = new char[n+1];
      memcpy(synaps_input,s,n); synaps_input[n]='\0';
      synaps_inputlim = synaps_input + n;
    }
  else
    {
      synaps_input = new char[n+2];
      memcpy(synaps_input,s,n); 
      synaps_input[n]=';'; synaps_input[n+1]='\0';
      synaps_inputlim = synaps_input + n+1;
    }
  synaps_inputptr=synaps_input;
  *this = Monomial((C)1);
  int Ask;

  for (;;) {
    Ask = yylex();
    if (Ask == COEF) { /* monome constant */
      C c;
      let::assign(c,yylval);
      free(yylval);
      *this *= c;
    }
    else if (Ask == XID) {
      char* p = strchr(yylval,'^');
      if (p == NULL)
        {
          *this *= Monomial(vars[std::string(yylval)],1);
        }
      else {
        p++;
        *this *= Monomial(vars[std::string(yylval,p-1)], atoi(p));
      }
      free(yylval);
    }
    else if (Ask == TERMINATE) {
      break;
    }
  }
  delete[] synaps_input;
}
monom ( const monom< C, E > &  m) [inline]

Definition at line 114 of file monomial.hpp.

:_coef(m._coef),_expt(m._expt) {}

Member Function Documentation

int* begin ( ) [inline]

Definition at line 132 of file monomial.hpp.

References monom< C, E >::rep().

{ return rep().begin(); }
int* begin ( ) const [inline]

Definition at line 133 of file monomial.hpp.

References monom< C, E >::rep().

{ return rep().begin(); }
C& coeff ( ) [inline]

Definition at line 129 of file monomial.hpp.

References monom< C, E >::_coef.

{ return _coef; }
const C& coeff ( ) const [inline]
exponent_t exponent ( size_type  i) const [inline]

Definition at line 142 of file monomial.hpp.

References monom< C, E >::rep().

{ return rep()[i]; }
exponent_t expt ( size_type  i) const [inline]

Definition at line 141 of file monomial.hpp.

References monom< C, E >::rep().

{ return rep()[i]; }
int l_variable ( ) const [inline]

Definition at line 137 of file monomial.hpp.

References mmx::lvar(), and monom< C, E >::rep().

{ return lvar(rep()); }
unsigned nbvar ( ) const [inline]

Definition at line 138 of file monomial.hpp.

References mmx::lvar(), and monom< C, E >::rep().

{ return lvar(rep())+1; }
int nvars ( ) const [inline]

Definition at line 136 of file monomial.hpp.

References mmx::lvar(), and monom< C, E >::rep().

{ return lvar(rep()); }
bool operator!= ( int  n) const [inline]

Definition at line 149 of file monomial.hpp.

{return !(*this==n);}
monom< C, E > & operator*= ( const C &  c) [inline]

Definition at line 405 of file monomial.hpp.

References mmx::erase(), and mmx::rep().

                                  {
  coeff() *= c;
  if (coeff()==0) erase(rep());
  return *this;
}
self_t& operator*= ( const self_t )
self_t& operator+= ( const self_t )
self_t operator- ( ) const [inline]

Definition at line 168 of file monomial.hpp.

References monom< C, E >::_coef, and monom< C, E >::rep().

{return self_t(-_coef,rep());}
self_t& operator-= ( const self_t )
monom< C, E > & operator/= ( const C &  c) [inline]

Definition at line 412 of file monomial.hpp.

References assert, mmx::erase(), and mmx::rep().

                                  {
  assert(c !=0);
  coeff() /= c;
  if (coeff()==0) erase(rep());
  return *this;
}
self_t& operator= ( const self_t m) [inline]

Definition at line 120 of file monomial.hpp.

References monom< C, E >::_coef, monom< C, E >::_expt, and monom< C, E >::coeff().

    {
      _coef = m.coeff(); 
      _expt = m._expt; 
      return *this;
    };
bool operator== ( int  n) const [inline]

Definition at line 360 of file monomial.hpp.

                                 {
  return (coeff()==n);
}
exponent_t operator[] ( size_type  i) const [inline]

Definition at line 140 of file monomial.hpp.

References monom< C, E >::rep().

{ return rep()[i]; }
const E& rep ( ) const [inline]

Definition at line 74 of file monomial.hpp.

References monom< C, E >::_expt.

{return (_expt);}
void set_coeff ( const C &  c) [inline]

Definition at line 130 of file monomial.hpp.

References monom< C, E >::_coef.

{ _coef = c; }
self_t& set_expt ( size_type  i,
exponent_t  d 
) [inline]

Definition at line 144 of file monomial.hpp.

References monom< C, E >::rep().

Referenced by as_helper< monom< T, TR >, monom< F, FR > >::cv().

    {rep().set_expt(i,d);return *this; }
unsigned size ( void  ) const [inline]

Definition at line 135 of file monomial.hpp.

References monom< C, E >::rep().

Referenced by as_helper< monom< T, TR >, monom< F, FR > >::cv(), and mmx::sparse::print_dual().

{ return rep().size(); }

Friends And Related Function Documentation

bool IsComparable ( const self_t m1,
const self_t m2 
) [friend]

Definition at line 162 of file monomial.hpp.

  {
    return m1.rep() == m2.rep();
  }
bool operator!= ( const self_t m1,
const self_t m2 
) [friend]

Definition at line 157 of file monomial.hpp.

  {
    return !(m1 == m2);
  }
bool operator== ( const self_t m1,
const self_t m2 
) [friend]

Definition at line 152 of file monomial.hpp.

  {
    return m1._coef == m2._coef && m1.rep() == m2.rep();
  }

Member Data Documentation

E _expt

Definition at line 72 of file monomial.hpp.

Referenced by monom< C, E >::operator=(), and monom< C, E >::rep().

variables var [static]

Definition at line 78 of file monomial.hpp.


The documentation for this struct was generated from the following file: