DGtal  1.4.beta
polynomial-read.cpp
Go to the documentation of this file.
1 
48 #include <iostream>
49 #include <iomanip>
50 #include <sstream>
51 #include "DGtal/base/Common.h"
52 #include "DGtal/math/MPolynomial.h"
53 #include "DGtal/io/readers/MPolynomialReader.h"
55 
56 using namespace std;
57 using namespace DGtal;
58 
59 
61 // Standard services - public :
62 
66 int main( int /*argc*/, char** /*argv*/ )
67 {
68  typedef double Ring;
71  string str;
72 
73  std::cout << "Type any multi-variate polynomial, then press return." << std::endl
74  << "Examples: xyz^3-4yz, (x+y+z)*(x-y-z)^2." << std::endl;
75  do {
76  getline( cin, str );
77  if ( cin.good() && ( ! str.empty() ) )
78  {
79  std::string::const_iterator iter
80  = reader.read( P, str.begin(), str.end() );
81  bool ok = iter == str.end();
82  if ( ! ok )
83  {
84  std::cerr << "ERROR: I read only <"
85  << str.substr( 0, iter - str.begin() )
86  << ">, and I built P=" << P << std::endl;
87  }
88  std::cout << (ok ? "Ok : " : "Err: ") << P << std::endl;
89  }
90  } while ( ! str.empty() );
91  return 0;
92 }
93 // //
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.
Definition: MPolynomial.h:965
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int, char **)