DGtal  0.9.3beta
polynomial-read.cpp
1 
30 #include <iostream>
32 #include <iomanip>
33 #include <sstream>
34 #include "DGtal/base/Common.h"
35 #include "DGtal/math/MPolynomial.h"
36 #include "DGtal/io/readers/MPolynomialReader.h"
38 
39 using namespace std;
40 using namespace DGtal;
41 
42 
44 // Standard services - public :
45 
49 int main( int /*argc*/, char** /*argv*/ )
50 {
51  typedef double Ring;
54  string str;
55 
56  std::cout << "Type any multi-variate polynomial, then press return." << std::endl
57  << "Examples: xyz^3-4yz, (x+y+z)*(x-y-z)^2." << std::endl;
58  do {
59  getline( cin, str );
60  if ( cin.good() && ( ! str.empty() ) )
61  {
62  std::string::const_iterator iter
63  = reader.read( P, str.begin(), str.end() );
64  bool ok = iter == str.end();
65  if ( ! ok )
66  {
67  std::cerr << "ERROR: I read only <"
68  << str.substr( 0, iter - str.begin() )
69  << ">, and I built P=" << P << std::endl;
70  }
71  std::cout << (ok ? "Ok : " : "Err: ") << P << std::endl;
72  }
73  } while ( ! str.empty() );
74  return 0;
75 }
76 // //
Iterator read(Polynomial &p, Iterator begin, Iterator end)
Aim: This class converts a string polynomial expression in a multivariate polynomial.
STL namespace.
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field...
Definition: MPolynomial.h:58
DGtal is the top-level namespace which contains all DGtal functions and types.