Commit 8097a594 authored by Charlles Abreu's avatar Charlles Abreu
Browse files

Continuous1DFunction with setPeriodic and getPeriodic methods

parent b04a0a94
......@@ -96,7 +96,7 @@ public:
*
* @param periodic whether the function is periodic
*/
void getPeriodicityStatus(bool& periodic) const;
void getPeriodic(bool& periodic) const;
/**
* Set the parameters for the tabulated function.
*
......@@ -107,6 +107,12 @@ public:
* @param max the value of x corresponding to the last element of values
*/
void setFunctionParameters(const std::vector<double>& values, double min, double max);
/**
* Set the periodicity status for the tabulated function.
*
* @param periodic whether the function is periodic with period L = max - min
*/
void setPeriodic(bool periodic);
/**
* Create a deep copy of the tabulated function.
*
......
......@@ -46,7 +46,7 @@ void Continuous1DFunction::getFunctionParameters(vector<double>& values, double&
max = this->max;
}
void Continuous1DFunction::getPeriodicityStatus(bool& periodic) const {
void Continuous1DFunction::getPeriodic(bool& periodic) const {
periodic = this->periodic;
}
......@@ -67,6 +67,10 @@ void Continuous1DFunction::setFunctionParameters(const vector<double>& values, d
this->max = max;
}
void Continuous1DFunction::setPeriodic(bool periodic) {
this->periodic = periodic;
}
Continuous1DFunction* Continuous1DFunction::Copy() const {
vector<double> new_vec(values.size());
for (size_t i = 0; i < values.size(); i++)
......
......@@ -721,7 +721,7 @@ vector<float> ExpressionUtilities::computeFunctionCoefficients(const TabulatedFu
double min, max;
fn.getFunctionParameters(values, min, max);
bool periodic;
fn.getPeriodicityStatus(periodic);
fn.getPeriodic(periodic);
int numValues = values.size();
vector<double> x(numValues), derivs;
for (int i = 0; i < numValues; i++)
......
......@@ -76,7 +76,7 @@ extern "C" OPENMM_EXPORT CustomFunction* createReferenceTabulatedFunction(const
ReferenceContinuous1DFunction::ReferenceContinuous1DFunction(const Continuous1DFunction& function) : function(function) {
function.getFunctionParameters(values, min, max);
function.getPeriodicityStatus(periodic);
function.getPeriodic(periodic);
int numValues = values.size();
x.resize(numValues);
for (int i = 0; i < numValues; i++)
......@@ -89,7 +89,7 @@ ReferenceContinuous1DFunction::ReferenceContinuous1DFunction(const Continuous1DF
ReferenceContinuous1DFunction::ReferenceContinuous1DFunction(const ReferenceContinuous1DFunction& other) : function(other.function) {
function.getFunctionParameters(values, min, max);
function.getPeriodicityStatus(periodic);
function.getPeriodic(periodic);
x = other.x;
values = other.values;
derivs = other.derivs;
......
......@@ -52,7 +52,7 @@ void Continuous1DFunctionProxy::serialize(const void* object, SerializationNode&
for (auto v : values)
valuesNode.createChildNode("Value").setDoubleProperty("v", v);
bool periodic;
function.getPeriodicityStatus(periodic);
function.getPeriodic(periodic);
node.setBoolProperty("periodic", periodic);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment