34#include "DGtal/base/Common.h"
35#include "DGtal/math/MPolynomial.h"
36#include "DGtal/io/readers/MPolynomialReader.h"
49template <
typename Ring>
63durchblickC(
const double & x,
const double & y,
const double z )
65 return x*x*x*y + x*z*z*z + y*y*y*z + z*z*z + 5.0 * z;
74 unsigned int nbok = 0;
77 trace.
beginBlock (
"Testing block ... Evaluation speed of mpolynomials (naive)" );
78 trace.
info() << setprecision( 15 ) <<
"step is " << step << std::endl;
79 trace.
info() <<
"approximately " << 8.0/(step*step*step) <<
" computations." << std::endl;
82 for (
double x = -1.0; x < 1.0; x += step )
84 for (
double y = -1.0; y < 1.0; y += step )
86 for (
double z = -1.0; z < 1.0; z += step )
90 trace.
info() <<
"Total = " << total << std::endl;
93 trace.
beginBlock (
"Testing block ... Evaluation speed of mpolynomials" );
96 for (
double x = -1.0; x < 1.0; x += step )
99 for (
double y = -1.0; y < 1.0; y += step )
102 for (
double z = -1.0; z < 1.0; z += step )
106 trace.
info() <<
"Total1 = " << total1 << std::endl;
111 for (
double x = -1.0; x < 1.0; x += step )
113 for (
double y = -1.0; y < 1.0; y += step )
115 for (
double z = -1.0; z < 1.0; z += step )
119 trace.
info() <<
"Total2 = " << total2 << std::endl;
121 nbok += fabs( total1 - total ) < 1e-8 ? 1 : 0;
123 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
124 <<
"fabs( total1 - total ) < 1e-8" << std::endl;
125 nbok += fabs( total2 - total ) < 1e-8 ? 1 : 0;
127 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
128 <<
"fabs( total2 - total ) < 1e-8" << std::endl;
130 trace.
info() <<
"For information, ImaGene::Polynomial3 takes 164ms for step=0.01 and 1604ms for step = 0.005." << std::endl;
140 unsigned int nbok = 0;
149 nbok += e == 24592 ? 1 : 0;
153 trace.
info() << g <<
" and " << h << std::endl;
170 std::cout <<
"Q(x,y,z)=1+xy^2+x^4yz = " << Q << std::endl;
171 std::cout <<
" degree = " << Q.
degree() << std::endl;
172 std::cout <<
" leading = " << Q.
leading() << std::endl;
173 std::cout <<
" Q[0] = " << Q[ 0 ] << std::endl;
174 std::cout <<
" Q[1] = " << Q[ 1 ] << std::endl;
175 std::cout <<
" Q[2] = " << Q[ 2 ] << std::endl;
176 std::cout <<
" Q[3] = " << Q[ 3 ] << std::endl;
177 std::cout <<
" Q[4] = " << Q[ 4 ] << std::endl;
197 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
const MPolyNM1 & leading() const
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
MPolynomial< 1, Ring, Alloc > mmonomial(unsigned int e)
MPolynomial< n, Ring, Alloc > Xe_k(unsigned int k, unsigned int e)
MPolynomial< 1, Ring, Alloc > gcd(const MPolynomial< 1, Ring, Alloc > &f, const MPolynomial< 1, Ring, Alloc > &g)
MPolynomial< n, Ring, Alloc > derivative(const MPolynomial< n, Ring, Alloc > &p)
MPolynomial< 3, Ring, std::allocator< Ring > > durchblick()
bool testMPolynomialSpeed(double step=0.01)
double durchblickC(const double &x, const double &y, const double z)