DGtal 1.4.0
Loading...
Searching...
No Matches
polynomial2-derivative.cpp File Reference
#include <iostream>
#include <string>
#include <sstream>
#include "DGtal/math/MPolynomial.h"
#include "DGtal/io/readers/MPolynomialReader.h"
Include dependency graph for polynomial2-derivative.cpp:

Go to the source code of this file.

Functions

void usage (int, char **argv)
 
int main (int argc, char **argv)
 

Detailed Description

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 5127), University of Savoie, France
Date
2012/02/06

An example file named polynomial2-derivative.

This file is part of the DGtal library.

Definition in file polynomial2-derivative.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Main.

[polynomial2-derivative-types]

[polynomial2-derivative-types]

[polynomial2-derivative-process]

[polynomial2-derivative-process]

Definition at line 57 of file polynomial2-derivative.cpp.

58{
59 if ( argc < 2 )
60 {
61 usage( argc, argv );
62 return 1;
63 }
64
66 typedef double Ring;
67 typedef MPolynomial<2, Ring> MyPolynomial;
69
71 std::string polynomialString( argv[ 1 ] );
72 std::istringstream polynomialIStream( polynomialString );
73 MyPolynomial P;
74 polynomialIStream >> P;
75 MyPolynomial P1_0 = derivative<0>( P );
76 MyPolynomial P2_0 = derivative<0>( P1_0 );
77 MyPolynomial P0_1 = derivative<1>( P );
78 MyPolynomial P0_2 = derivative<1>( P0_1 );
79 MyPolynomial P1_1 = derivative<1>( P1_0 );
80 MyPolynomial P1_1b= derivative<0>( P0_1 );
81 std::cout << "P(X_0,X_1) = " << P << std::endl;
82 std::cout << "dP/dX_0(X_0,X_1) = " << P1_0 << std::endl;
83 std::cout << "dP/dX_1(X_0,X_1) = " << P0_1 << std::endl;
84 std::cout << "d/dX_1 dP/dX_0(X_0,X_1) = " << P1_1 << std::endl;
85 std::cout << "d/dX_0 dP/dX_1(X_0,X_1) = " << P1_1b << std::endl;
86 std::cout << "d/dX_0 dP/dX_0(X_0,X_1) = " << P2_0 << std::endl;
87 std::cout << "d/dX_1 dP/dX_1(X_0,X_1) = " << P0_2 << std::endl;
89 return 0;
90}
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
MPolynomial< n, Ring, Alloc > derivative(const MPolynomial< n, Ring, Alloc > &p)

References DGtal::derivative().

◆ usage()

void usage ( int ,
char ** argv )

Definition at line 48 of file polynomial2-derivative.cpp.

49{
50 std::cerr << "Usage: " << argv[ 0 ] << " <P(x,y)>" << std::endl;
51 std::cerr << "\t - computes the first and second derivatives of the given polynomial P (in two variables)." << std::endl;
52}