diff --git a/derand.h b/derand.h index 69cbd74..e312bfa 100644 --- a/derand.h +++ b/derand.h @@ -12,6 +12,8 @@ namespace DE class Random { public: + + Random(); void Seed(u32 seed); diff --git a/derand.inl b/derand.inl index daca961..e6db650 100644 --- a/derand.inl +++ b/derand.inl @@ -1,11 +1,16 @@ #ifndef __derand_inl__ #define __derand_inl__ +#include #if !(defined(__derand_h__)) # error "derand.inl should only be included by derand.h" #endif +inline DE::Random::Random() +{ + Seed(static_cast(clock())); +} inline void DE::Random::Seed(u32 seed) { diff --git a/polyapprox.cpp b/polyapprox.cpp index a19f2ba..4316e29 100644 --- a/polyapprox.cpp +++ b/polyapprox.cpp @@ -4,7 +4,7 @@ #include "de.h" // the order of the polynomial (actually the number of coefficients, i.e. 1 = constant, 2 = line, etc.) -#define NUM_COEFFICIENTS 6 +#define NUM_COEFFICIENTS 8 // the function we're searching for double TargetFunction(double x) @@ -45,7 +45,7 @@ class PolySearch: public DE::Engine unsigned int test_count = 0; // accumulate squared error - for ( double i=-7.9287;i<=7.9287;i+=0.001 ) + for ( double i=-1.25;i<=1.25;i+=0.001 ) { // test double test = CalculatePolynomial(i,NUM_COEFFICIENTS,testcase); @@ -86,7 +86,7 @@ int main() de.Reset(); // run the DE - de.Solve(1000); + de.Solve(1500); // output winner in polynomial form printf("Best Polynomial Found\n=====================\ny =");