DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
polynomial-derivative.cpp
Go to the documentation of this file.
1
13
31
32
35
#include <iostream>
36
#include <string>
37
#include <sstream>
38
#include "DGtal/math/MPolynomial.h"
39
#include "DGtal/io/readers/MPolynomialReader.h"
41
43
44
using namespace
DGtal
;
45
47
48
void
usage
(
int
,
char
** argv )
49
{
50
std::cerr <<
"Usage: "
<< argv[ 0 ] <<
" <P>"
<< std::endl;
51
std::cerr <<
"\t - computes the first and second derivative of the given polynomial P (in one variable)."
<< std::endl;
52
}
53
57
int
main
(
int
argc,
char
** argv )
58
{
59
if
( argc < 2 )
60
{
61
usage
( argc, argv );
62
return
1;
63
}
64
66
typedef
double
Ring
;
67
typedef
MPolynomial<1, Ring>
MyPolynomial;
69
71
std::string polynomialString( argv[ 1 ] );
72
std::istringstream polynomialIStream( polynomialString );
73
MyPolynomial P;
74
polynomialIStream >> P;
75
MyPolynomial P1 =
derivative<0>
( P );
76
MyPolynomial P2 =
derivative<0>
( P1 );
77
std::cout <<
"P(X_0) = "
<< P << std::endl;
78
std::cout <<
"P'(X_0) = "
<< P1 << std::endl;
79
std::cout <<
"P''(X_0) = "
<< P2 << std::endl;
81
return
0;
82
}
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
DGtal::derivative
MPolynomial< n, Ring, Alloc > derivative(const MPolynomial< n, Ring, Alloc > &p)
Definition
MPolynomial.h:1981
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
usage
void usage(int, char **argv)
Definition
testPolynomial.cpp:58
Ring
RealPointT::Coordinate Ring
Definition
testPolynomial.cpp:69
examples
math
polynomial-derivative.cpp
Generated on
for DGtal by
1.18.0