DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
polynomial-read.cpp
1 
30 
31 #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;
53  MPolynomialReader<3,Ring> reader;
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 // //