DGtal 1.3.0
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
DGtal::MPolynomialGrammar< Iterator > Struct Template Reference

#include <DGtal/io/readers/MPolynomialReader.h>

Inheritance diagram for DGtal::MPolynomialGrammar< Iterator >:

Public Member Functions

 MPolynomialGrammar ()
 

Data Fields

qi::rule< Iterator, detail::top_node(), ascii::space_type > top
 
qi::rule< Iterator, detail::top_node(), ascii::space_type > mulexpr
 
qi::rule< Iterator, detail::expr_node(), ascii::space_type > subexpr
 
qi::rule< Iterator, detail::top_node(), ascii::space_type > expexpr
 
qi::rule< Iterator, detail::monomial_node(), ascii::space_type > monomial
 
qi::rule< Iterator, detail::power_node(), ascii::space_type > variable
 
qi::rule< Iterator, detail::power_node(), ascii::space_type > genvariable
 
qi::rule< Iterator, detail::power_node(), ascii::space_type > litvariable
 

Detailed Description

template<typename Iterator>
struct DGtal::MPolynomialGrammar< Iterator >

Defines a grammar for parsing multi-variate polynomials. Based on boost::spirit. You should use a MPolynomialReader to make polynomials from input strings. Another way is to use the overloaded DGtal::operator>>(std::istream &,MPolynomial<n,TRing,TAlloc> &).

Definition at line 148 of file MPolynomialReader.h.

Constructor & Destructor Documentation

◆ MPolynomialGrammar()

template<typename Iterator >
DGtal::MPolynomialGrammar< Iterator >::MPolynomialGrammar ( )
inline

Definition at line 151 of file MPolynomialReader.h.

152 : MPolynomialGrammar::base_type(top)
153 {
154 using qi::eps;
155 using qi::lit;
156 using qi::int_;
157 using qi::_val;
158 using qi::_1;
159 using qi::double_;
160 using phoenix::at_c;
161 using phoenix::push_back;
162
163 top = // An expression is an additive or subtractive expression
164 mulexpr [push_back(at_c<1>(_val), _1)]
165 >> *( ( lit('+') [ push_back(at_c<0>(_val), '+') ]
166 >> mulexpr [push_back(at_c<1>(_val), _1)] )
167 | ( ( lit('-') [ push_back(at_c<0>(_val), '-') ]
168 >> mulexpr [push_back(at_c<1>(_val), _1)] ) ) );
169
170 mulexpr = // Each mul expression may be a product of sub-expressions
171 subexpr [push_back(at_c<1>(_val), _1)]
172 >> *( ( lit('*') [ push_back(at_c<0>(_val), '*') ]
173 >> mulexpr [push_back(at_c<1>(_val), _1)] ) );
174
175 subexpr = // a sub-expression is a monomial or some ( ) or some ( )^k
176 monomial
177 | expexpr;
178
179 expexpr = // ( expr ) or ( expr )^k
180 lit('(') [ push_back(at_c<0>(_val), '^') ]
181 >> top [ push_back(at_c<1>(_val), _1) ]
182 >> lit(')')
183 >> ( ( lit('^') >> int_ [ at_c<2>(_val) = _1 ] )
184 | eps [ at_c<2>(_val) = 1 ] ) ;
185
186 monomial = // coef.power(s)*, or power(s)+
187 ( double_ [at_c<0>(_val) = _1]
188 >> *( genvariable [push_back(at_c<1>(_val), _1)] ) )
189 | +( genvariable [push_back(at_c<1>(_val), _1)]
190 >> eps [at_c<0>(_val) = 1] );
191
192 genvariable = // may be some X_k^m or x^m, y^m ...
194 variable = // X_0 X_1 ... X_0^4 X_1^2 X_3^0 ...
195 lit('X') >> lit('_')
196 >> int_ [at_c<0>(_val) = _1]
197 >> ( ( lit('^') >> int_ [at_c<1>(_val) = _1] ) // X_k^e
198 | eps [at_c<1>(_val) = 1] // X_k
199 );
200 litvariable = // x y z t x^4 y^5 z^2 ...
201 ( lit('x') [at_c<0>(_val) = 0]
202 | lit('y') [at_c<0>(_val) = 1]
203 | lit('z') [at_c<0>(_val) = 2]
204 | lit('t') [at_c<0>(_val) = 3] )
205 >> ( ( lit('^') >> int_ [at_c<1>(_val) = _1] ) // x^3 z^4
206 | eps [at_c<1>(_val) = 1] // x y z
207 );
208
209 }
qi::rule< Iterator, detail::power_node(), ascii::space_type > genvariable
qi::rule< Iterator, detail::top_node(), ascii::space_type > expexpr
qi::rule< Iterator, detail::expr_node(), ascii::space_type > subexpr
qi::rule< Iterator, detail::top_node(), ascii::space_type > mulexpr
qi::rule< Iterator, detail::monomial_node(), ascii::space_type > monomial
qi::rule< Iterator, detail::power_node(), ascii::space_type > variable
qi::rule< Iterator, detail::power_node(), ascii::space_type > litvariable

References DGtal::MPolynomialGrammar< Iterator >::expexpr, DGtal::MPolynomialGrammar< Iterator >::genvariable, DGtal::MPolynomialGrammar< Iterator >::litvariable, DGtal::MPolynomialGrammar< Iterator >::monomial, DGtal::MPolynomialGrammar< Iterator >::mulexpr, DGtal::MPolynomialGrammar< Iterator >::subexpr, and DGtal::MPolynomialGrammar< Iterator >::variable.

Field Documentation

◆ expexpr

template<typename Iterator >
qi::rule<Iterator, detail::top_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::expexpr

◆ genvariable

template<typename Iterator >
qi::rule<Iterator, detail::power_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::genvariable

◆ litvariable

template<typename Iterator >
qi::rule<Iterator, detail::power_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::litvariable

◆ monomial

template<typename Iterator >
qi::rule<Iterator, detail::monomial_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::monomial

◆ mulexpr

template<typename Iterator >
qi::rule<Iterator, detail::top_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::mulexpr

◆ subexpr

template<typename Iterator >
qi::rule<Iterator, detail::expr_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::subexpr

◆ top

template<typename Iterator >
qi::rule<Iterator, detail::top_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::top

Definition at line 212 of file MPolynomialReader.h.

◆ variable

template<typename Iterator >
qi::rule<Iterator, detail::power_node(), ascii::space_type> DGtal::MPolynomialGrammar< Iterator >::variable

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