|
@ -8,37 +8,32 @@ |
|
|
|
|
|
|
|
|
#include "Polynomial.hpp" |
|
|
#include "Polynomial.hpp" |
|
|
#include <algorithm> |
|
|
#include <algorithm> |
|
|
//#include <iostream>
|
|
|
|
|
|
|
|
|
|
|
|
Polynomial::Polynomial(): |
|
|
|
|
|
AttractorKernel(3, 0), |
|
|
|
|
|
orde(2){ |
|
|
|
|
|
|
|
|
|
|
|
init(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Polynomial::Polynomial(const unsigned int dimension, const unsigned int orde): |
|
|
unsigned int calculateNumberOfParameters(const unsigned int dimension, const unsigned int orde) { |
|
|
AttractorKernel(dimension, 0), |
|
|
|
|
|
orde(orde) { |
|
|
|
|
|
init(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Polynomial::init() { |
|
|
|
|
|
const unsigned int number = calculateNumberOfParameters(); |
|
|
|
|
|
reallocParameters(number); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// i want to has constexpr, so the ctor can be clean :]
|
|
|
|
|
|
unsigned int Polynomial::calculateNumberOfParameters() { |
|
|
|
|
|
double n_coef = orde + 1; |
|
|
double n_coef = orde + 1; |
|
|
for (unsigned int i = 2; i <= dimension; i++) { |
|
|
for (unsigned int i = 2; i <= dimension; i++) { |
|
|
n_coef = n_coef*(orde + i)/(i - 1); |
|
|
n_coef = n_coef*(orde + i)/(i - 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const unsigned int output = (unsigned int) n_coef; |
|
|
const unsigned int output = (unsigned int) n_coef; |
|
|
return output; |
|
|
return output; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - |
|
|
|
|
|
#pragma mark ctors |
|
|
|
|
|
|
|
|
|
|
|
Polynomial::Polynomial(): |
|
|
|
|
|
AttractorKernel(3, calculateNumberOfParameters(3, 2)), orde(2){} |
|
|
|
|
|
|
|
|
|
|
|
Polynomial::Polynomial(const unsigned int dimension, const unsigned int orde): |
|
|
|
|
|
AttractorKernel(dimension, calculateNumberOfParameters(dimension, orde)), orde(orde){} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - |
|
|
|
|
|
#pragma mark attractor |
|
|
|
|
|
|
|
|
void Polynomial::operator()() { |
|
|
void Polynomial::operator()() { |
|
|
std::swap(vectorNew, vectorOld); |
|
|
std::swap(vectorNew, vectorOld); |
|
|
|
|
|
|
|
@ -49,7 +44,6 @@ void Polynomial::operator()() { |
|
|
m++; |
|
|
m++; |
|
|
recur(i, 0, 1, m); |
|
|
recur(i, 0, 1, m); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Polynomial::recur(unsigned int curr_dimension, unsigned int prev_i, unsigned int n, unsigned int& m, double prev_product) { |
|
|
void Polynomial::recur(unsigned int curr_dimension, unsigned int prev_i, unsigned int n, unsigned int& m, double prev_product) { |
|
|