|
|
@ -14,18 +14,15 @@ |
|
|
|
#pragma mark - |
|
|
|
#pragma mark memory |
|
|
|
|
|
|
|
AttractorKernel::AttractorKernel(const unsigned int dimension, const unsigned int numberOfParameters): |
|
|
|
numberOfParameters(numberOfParameters), dimension(dimension) { |
|
|
|
AttractorKernel::AttractorKernel(const unsigned int dimension, const unsigned int numberOfParameters) : |
|
|
|
numberOfParameters(numberOfParameters), dimension(dimension){ |
|
|
|
|
|
|
|
try { |
|
|
|
parameters = new double[numberOfParameters]; |
|
|
|
|
|
|
|
vectorNew = new double[dimension]; |
|
|
|
vectorOld = new double[dimension]; |
|
|
|
} catch (std::bad_alloc& e) { |
|
|
|
std::cerr << "Exception: " << e.what() << std::endl; |
|
|
|
std::cerr << "Quiting because nothing to do... " << std::endl; |
|
|
|
exit(1); |
|
|
|
allocate(); |
|
|
|
} |
|
|
|
catch (std::exception& e) { |
|
|
|
std::cout << "Couldn't construct AttractorKernel: " << e.what() << std::endl; |
|
|
|
dealloc(); |
|
|
|
} |
|
|
|
|
|
|
|
std::fill_n(parameters, numberOfParameters, 0.0); |
|
|
@ -35,26 +32,22 @@ numberOfParameters(numberOfParameters), dimension(dimension) { |
|
|
|
} |
|
|
|
|
|
|
|
AttractorKernel::~AttractorKernel(){ |
|
|
|
delete[] vectorOld; |
|
|
|
delete[] vectorNew; |
|
|
|
delete[] parameters; |
|
|
|
dealloc(); |
|
|
|
} |
|
|
|
|
|
|
|
void AttractorKernel::reallocParameters(const unsigned int newNumberOfParameters){ |
|
|
|
void AttractorKernel::allocate(){ |
|
|
|
parameters = new double[numberOfParameters]; |
|
|
|
vectorNew = new double[dimension]; |
|
|
|
vectorOld = new double[dimension]; |
|
|
|
} |
|
|
|
|
|
|
|
void AttractorKernel::dealloc(){ |
|
|
|
delete[] vectorOld; |
|
|
|
vectorOld = NULL; |
|
|
|
delete[] vectorNew; |
|
|
|
vectorNew = NULL; |
|
|
|
delete[] parameters; |
|
|
|
|
|
|
|
numberOfParameters = newNumberOfParameters; |
|
|
|
|
|
|
|
try { |
|
|
|
parameters = new double[numberOfParameters]; |
|
|
|
} |
|
|
|
catch (std::bad_alloc& e) { |
|
|
|
std::cerr << "Exception: " << e.what() << std::endl; |
|
|
|
std::cerr << "Quiting because nothing to do... " << std::endl; |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
std::fill_n(parameters, numberOfParameters, 0.0); |
|
|
|
parameters = NULL; |
|
|
|
} |
|
|
|
|
|
|
|
#pragma mark - |
|
|
|