34 #include "DGtal/base/Common.h"
35 #include "DGtal/math/MPolynomial.h"
36 #include "DGtal/io/readers/MPolynomialReader.h"
40 using namespace DGtal;
56 string s1 =
"1.5 X_0^2 X_2^3 X_1^5 * (4 X_0^3 + X_1^2)^2";
58 string s2 =
"2 X_0^2 X_2 X_1^5";
59 string s3 = s1 +
" * " + s2;
60 string s4 =
"(" + s2 +
")^4 * (" + s1 +
")^1 - 3 X_2^3";
61 string s5 =
"x^3y+xz^3+y^3z+z^3+5z";
62 string s6 =
"(y^2+z^2-1)^2 +(x^2+y^2-1)^3";
63 string s7 =
"(y^2+z^2-1)^2 Abrahamovitch";
64 bool ok1 = reader.
read( P, s1.begin(), s1.end() ) == s1.end();
65 trace.
info() <<
"- Parsing " << s1 <<
" : " << ok1 <<
" " << P << std::endl;
66 bool ok2 = reader.
read( P, s2.begin(), s2.end() ) == s2.end();
67 trace.
info() <<
"- Parsing " << s2 <<
" : " << ok2 <<
" " << P << std::endl;
68 bool ok3 = reader.
read( P, s3.begin(), s3.end() ) == s3.end();
69 trace.
info() <<
"- Parsing " << s3 <<
" : " << ok3 <<
" " << P << std::endl;
70 bool ok4 = reader.
read( P, s4.begin(), s4.end() ) == s4.end();
71 trace.
info() <<
"- Parsing " << s4 <<
" : " << ok4 <<
" " << P << std::endl;
72 bool ok5 = reader.
read( P, s5.begin(), s5.end() ) == s5.end();
73 trace.
info() <<
"- Parsing " << s5 <<
" : " << ok5 <<
" " << P << std::endl;
74 bool ok6 = reader.
read( P, s6.begin(), s6.end() ) == s6.end();
75 trace.
info() <<
"- Parsing " << s6 <<
" : " << ok6 <<
" " << P << std::endl;
76 bool ok7 = reader.
read( P, s7.begin(), s7.end() ) == s7.end();
77 trace.
info() <<
"- Parsing " << s7 <<
" : " << ok7 <<
" " << P << std::endl;
79 string s8 =
"(zyx^2+x^2-1)^2 + xy AVERTY";
80 std::istringstream sin( s8 );
83 trace.
info() <<
"- Read " << P <<
" and " << other << std::endl;
85 return ok1 && ok2 && ok3 && ok4 && ok5 && ok6 && (!ok7);
96 string s3 = s1 +
"+" + s2 +
"-2";
97 string s4 =
"(" + s1 +
")+(" + s2 +
")-2";
98 string s5 =
"(" + s1 +
")+ " + s2 +
" -2";
99 bool ok1 = reader.
read( P1, s1.begin(), s1.end() ) == s1.end();
100 bool ok2 = reader.
read( P2, s2.begin(), s2.end() ) == s2.end();
102 bool ok3 = reader.
read( Q2, s3.begin(), s3.end() ) == s3.end();
103 bool ok4 = reader.
read( Q3, s4.begin(), s4.end() ) == s4.end();
104 bool ok4b= reader.
read( Q4, s5.begin(), s5.end() ) == s5.end();
106 trace.
info() <<
"- Read Q1=" << Q1 <<
" from addition of monomials. " << std::endl;
107 trace.
info() <<
"- Read Q2=" << Q2 <<
" from string: " << s3 << std::endl;
108 trace.
info() <<
"- Read Q3=" << Q3 <<
" from string: " << s4 << std::endl;
109 trace.
info() <<
"- Read Q4=" << Q4 <<
" from string: " << s5 << std::endl;
112 return ok1 && ok2 && ok3 && ok4 && ok5 && ok6 && ok4b;
123 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class converts a string polynomial expression in a multivariate polynomial.
Iterator read(Polynomial &p, Iterator begin, Iterator end)
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
bool testMPolynomialReader()
bool testMPolynomialReader2()