DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
polynomial-read.cpp
Go to the documentation of this file.
1
16
29
45
46
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
;
69
MPolynomial<3,Ring,std::allocator<Ring>
> P;
70
MPolynomialReader<3,Ring>
reader;
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
// //
DGtal::MPolynomialReader
Aim: This class converts a string polynomial expression in a multivariate polynomial.
Definition
MPolynomialReader.h:259
DGtal::MPolynomialReader::read
Iterator read(Polynomial &p, Iterator begin, Iterator end)
Definition
MPolynomialReader.h:284
DGtal::MPolynomial
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
Definition
MPolynomial.h:970
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
Ring
RealPointT::Coordinate Ring
Definition
testPolynomial.cpp:69
examples
math
polynomial-read.cpp
Generated on
for DGtal by
1.18.0