|
@ -20,24 +20,21 @@ |
|
|
int verbose = 0; |
|
|
int verbose = 0; |
|
|
Logger logger(std::cout, LOG_VERBOSE); |
|
|
Logger logger(std::cout, LOG_VERBOSE); |
|
|
|
|
|
|
|
|
inline double test(const int dimension, const double doubling, const double percentage){ |
|
|
inline double test(const unsigned int dimension){ |
|
|
LOG("making vector", |
|
|
LOG("making vector", |
|
|
srand(time(0)); |
|
|
std::vector<double *> buffer(10000000); |
|
|
std::vector<double *> buffer(1000000); |
|
|
|
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
LOG("making random data", |
|
|
LOG("making random data", |
|
|
for(auto & p : buffer){ |
|
|
for(auto & p : buffer){ |
|
|
p = new double[dimension]; |
|
|
p = new double[dimension]; |
|
|
for(unsigned int i = 2;i < dimension; ++i){ |
|
|
for(unsigned int i = 0;i < dimension; ++i){ |
|
|
p[i] = rand() / (double) RAND_MAX - 0.5; |
|
|
p[i] = rand() / (double) RAND_MAX - 0.5; |
|
|
} |
|
|
} |
|
|
p[0] = p[1]*p[1]; |
|
|
|
|
|
p[1] = std::sin(5.0*p[2]); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
LOG("calculate fractal dimension", |
|
|
LOG("calculate fractal dimension", |
|
|
double f = fractal_dimension(buffer.begin(), buffer.end(), dimension, doubling, percentage); |
|
|
double f = fractal_dimension(buffer.begin(), buffer.end(), dimension); |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
LOG("freeing data", |
|
|
LOG("freeing data", |
|
@ -50,22 +47,11 @@ inline double test(const int dimension, const double doubling, const double perc |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int main(){ |
|
|
int main(){ |
|
|
double percentages[] = {0.00015, 0.00010, 0.00006, 0.00004, 0.000015}; |
|
|
srand(time(0)); |
|
|
std::cout << "... |"; |
|
|
for (unsigned int i = 1; i <= 6; ++i) { |
|
|
for(auto p : percentages) std::cout << "\t" << p; |
|
|
std::cout << i << " =>"; |
|
|
std::cout << std::endl << "----------------------------------------------" << std::endl; |
|
|
for(unsigned int j = 0; j < 10; ++j) { |
|
|
|
|
|
std::cout << "\t" << test(i); |
|
|
for (double doubling = 2.0; doubling <= 3.0; doubling += 0.1){ |
|
|
|
|
|
std::cout << doubling << " |"; |
|
|
|
|
|
for (auto p : percentages){ |
|
|
|
|
|
double sse = 0; |
|
|
|
|
|
for (int i = 3; i <= 6; ++i) { |
|
|
|
|
|
for(int j = 0; j < 20; ++j) { |
|
|
|
|
|
double e = (i-2) - test(i, doubling, p); |
|
|
|
|
|
sse += e*e; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
std::cout << "\t" << sse; |
|
|
|
|
|
} |
|
|
} |
|
|
std::cout << std::endl; |
|
|
std::cout << std::endl; |
|
|
} |
|
|
} |
|
|