DGtal  1.4.2
polynomial-read.cpp File Reference
#include <iostream>
#include <iomanip>
#include <sstream>
#include "DGtal/base/Common.h"
#include "DGtal/math/MPolynomial.h"
#include "DGtal/io/readers/MPolynomialReader.h"
Include dependency graph for polynomial-read.cpp:

Go to the source code of this file.

Functions

int main (int, char **)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
Date
2012/02/12

Functions for testing class Signal.

This file is part of the DGtal library.

Definition in file polynomial-read.cpp.

Function Documentation

◆ main()

int main ( int  ,
char **   
)

A simple example to show how to read a multivariate-polynomial from stdin.

Definition at line 66 of file polynomial-read.cpp.

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 }
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

References DGtal::MPolynomialReader< n, TRing, TAlloc, TIterator >::read().