"platforms/vscode:/vscode.git/clone" did not exist on "8196dbf76cc22e5867c7974aa56b20379e139998"
Commit b4dcef47 authored by peastman's avatar peastman
Browse files

Merge pull request #1465 from peastman/tabulated

Optimized reference implementation of continuous tabulated functions
parents abbf0b67 fc0689ac
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2014 Stanford University and the Authors. * * Portions copyright (c) 2014-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
double evaluateDerivative(const double* arguments, const int* derivOrder) const; double evaluateDerivative(const double* arguments, const int* derivOrder) const;
CustomFunction* clone() const; CustomFunction* clone() const;
private: private:
ReferenceContinuous1DFunction(const ReferenceContinuous1DFunction& other);
const Continuous1DFunction& function; const Continuous1DFunction& function;
double min, max; double min, max;
std::vector<double> x, values, derivs; std::vector<double> x, values, derivs;
...@@ -71,6 +72,7 @@ public: ...@@ -71,6 +72,7 @@ public:
double evaluateDerivative(const double* arguments, const int* derivOrder) const; double evaluateDerivative(const double* arguments, const int* derivOrder) const;
CustomFunction* clone() const; CustomFunction* clone() const;
private: private:
ReferenceContinuous2DFunction(const ReferenceContinuous2DFunction& other);
const Continuous2DFunction& function; const Continuous2DFunction& function;
int xsize, ysize; int xsize, ysize;
double xmin, xmax, ymin, ymax; double xmin, xmax, ymin, ymax;
...@@ -89,6 +91,7 @@ public: ...@@ -89,6 +91,7 @@ public:
double evaluateDerivative(const double* arguments, const int* derivOrder) const; double evaluateDerivative(const double* arguments, const int* derivOrder) const;
CustomFunction* clone() const; CustomFunction* clone() const;
private: private:
ReferenceContinuous3DFunction(const ReferenceContinuous3DFunction& other);
const Continuous3DFunction& function; const Continuous3DFunction& function;
int xsize, ysize, zsize; int xsize, ysize, zsize;
double xmin, xmax, ymin, ymax, zmin, zmax; double xmin, xmax, ymin, ymax, zmin, zmax;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2014 Stanford University and the Authors. * * Portions copyright (c) 2014-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -80,6 +80,13 @@ ReferenceContinuous1DFunction::ReferenceContinuous1DFunction(const Continuous1DF ...@@ -80,6 +80,13 @@ ReferenceContinuous1DFunction::ReferenceContinuous1DFunction(const Continuous1DF
SplineFitter::createNaturalSpline(x, values, derivs); SplineFitter::createNaturalSpline(x, values, derivs);
} }
ReferenceContinuous1DFunction::ReferenceContinuous1DFunction(const ReferenceContinuous1DFunction& other) : function(other.function) {
function.getFunctionParameters(values, min, max);
x = other.x;
values = other.values;
derivs = other.derivs;
}
int ReferenceContinuous1DFunction::getNumArguments() const { int ReferenceContinuous1DFunction::getNumArguments() const {
return 1; return 1;
} }
...@@ -99,7 +106,7 @@ double ReferenceContinuous1DFunction::evaluateDerivative(const double* arguments ...@@ -99,7 +106,7 @@ double ReferenceContinuous1DFunction::evaluateDerivative(const double* arguments
} }
CustomFunction* ReferenceContinuous1DFunction::clone() const { CustomFunction* ReferenceContinuous1DFunction::clone() const {
return new ReferenceContinuous1DFunction(function); return new ReferenceContinuous1DFunction(*this);
} }
ReferenceContinuous2DFunction::ReferenceContinuous2DFunction(const Continuous2DFunction& function) : function(function) { ReferenceContinuous2DFunction::ReferenceContinuous2DFunction(const Continuous2DFunction& function) : function(function) {
...@@ -113,6 +120,14 @@ ReferenceContinuous2DFunction::ReferenceContinuous2DFunction(const Continuous2DF ...@@ -113,6 +120,14 @@ ReferenceContinuous2DFunction::ReferenceContinuous2DFunction(const Continuous2DF
SplineFitter::create2DNaturalSpline(x, y, values, c); SplineFitter::create2DNaturalSpline(x, y, values, c);
} }
ReferenceContinuous2DFunction::ReferenceContinuous2DFunction(const ReferenceContinuous2DFunction& other) : function(other.function) {
function.getFunctionParameters(xsize, ysize, values, xmin, xmax, ymin, ymax);
x = other.x;
y = other.y;
values = other.values;
c = other.c;
}
int ReferenceContinuous2DFunction::getNumArguments() const { int ReferenceContinuous2DFunction::getNumArguments() const {
return 2; return 2;
} }
...@@ -144,7 +159,7 @@ double ReferenceContinuous2DFunction::evaluateDerivative(const double* arguments ...@@ -144,7 +159,7 @@ double ReferenceContinuous2DFunction::evaluateDerivative(const double* arguments
} }
CustomFunction* ReferenceContinuous2DFunction::clone() const { CustomFunction* ReferenceContinuous2DFunction::clone() const {
return new ReferenceContinuous2DFunction(function); return new ReferenceContinuous2DFunction(*this);
} }
ReferenceContinuous3DFunction::ReferenceContinuous3DFunction(const Continuous3DFunction& function) : function(function) { ReferenceContinuous3DFunction::ReferenceContinuous3DFunction(const Continuous3DFunction& function) : function(function) {
...@@ -161,6 +176,15 @@ ReferenceContinuous3DFunction::ReferenceContinuous3DFunction(const Continuous3DF ...@@ -161,6 +176,15 @@ ReferenceContinuous3DFunction::ReferenceContinuous3DFunction(const Continuous3DF
SplineFitter::create3DNaturalSpline(x, y, z, values, c); SplineFitter::create3DNaturalSpline(x, y, z, values, c);
} }
ReferenceContinuous3DFunction::ReferenceContinuous3DFunction(const ReferenceContinuous3DFunction& other) : function(other.function) {
function.getFunctionParameters(xsize, ysize, zsize, values, xmin, xmax, ymin, ymax, zmin, zmax);
x = other.x;
y = other.y;
z = other.z;
values = other.values;
c = other.c;
}
int ReferenceContinuous3DFunction::getNumArguments() const { int ReferenceContinuous3DFunction::getNumArguments() const {
return 3; return 3;
} }
...@@ -200,7 +224,7 @@ double ReferenceContinuous3DFunction::evaluateDerivative(const double* arguments ...@@ -200,7 +224,7 @@ double ReferenceContinuous3DFunction::evaluateDerivative(const double* arguments
} }
CustomFunction* ReferenceContinuous3DFunction::clone() const { CustomFunction* ReferenceContinuous3DFunction::clone() const {
return new ReferenceContinuous3DFunction(function); return new ReferenceContinuous3DFunction(*this);
} }
ReferenceDiscrete1DFunction::ReferenceDiscrete1DFunction(const Discrete1DFunction& function) : function(function) { ReferenceDiscrete1DFunction::ReferenceDiscrete1DFunction(const Discrete1DFunction& function) : function(function) {
......
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