Skip to content
Snippets Groups Projects
Commit f3d4b2ff authored by Lorenzo Moneta's avatar Lorenzo Moneta
Browse files

fix copy constructor (Coverity) and SetFunction

git-svn-id: http://root.cern.ch/svn/root/trunk@44142 27541ba8-7e3a-0410-8455-c3a389f83636
parent 340d6029
No related branches found
No related tags found
No related merge requests found
......@@ -191,11 +191,11 @@ public:
return Derivative3(x);
}
/** Set function for derivative calculation (function is not copied in)
/** Set function for derivative calculation (copy the function if option has been enabled in the constructor)
\@param f Function to be differentiated
*/
void SetFunction (const IGenFunction & f) { fFunction = &f; }
void SetFunction (const IGenFunction & f);
/** Set step size for derivative calculation
......
......@@ -28,7 +28,7 @@ RichardsonDerivator::RichardsonDerivator(double h) :
// Default Constructor.
}
RichardsonDerivator::RichardsonDerivator(const ROOT::Math::IGenFunction & f, double h, bool copyFunc) :
fFunctionCopied(false),
fFunctionCopied(copyFunc),
fStepSize(h),
fLastError(0),
fFunction(0)
......@@ -38,6 +38,7 @@ RichardsonDerivator::RichardsonDerivator(const ROOT::Math::IGenFunction & f, dou
else fFunction = &f;
}
RichardsonDerivator::~RichardsonDerivator()
{
// destructor
......@@ -54,15 +55,24 @@ RichardsonDerivator::RichardsonDerivator(const RichardsonDerivator & rhs)
RichardsonDerivator & RichardsonDerivator::operator= ( const RichardsonDerivator & rhs)
{
// Assignment operator
if (&rhs == this) return *this;
fFunctionCopied = rhs.fFunctionCopied;
fStepSize = rhs.fStepSize;
fLastError = rhs.fLastError;
fFunction = rhs.fFunction;
if (fFunctionCopied && fFunction != 0)
fFunction = fFunction->Clone();
SetFunction(*rhs.fFunction);
return *this;
}
void RichardsonDerivator::SetFunction(const ROOT::Math::IGenFunction & f)
{
// set function
if (fFunctionCopied) {
if (fFunction) delete fFunction;
fFunction = f.Clone();
}
else fFunction = &f;
}
double RichardsonDerivator::Derivative1 (double x)
{
const double kC1 = 1.E-15;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment