Skip to content
Snippets Groups Projects
Commit 1ddffee6 authored by Jesper Andersson's avatar Jesper Andersson
Browse files

Added assignment operator

parent 60d67031
No related branches found
No related tags found
No related merge requests found
......@@ -60,6 +60,9 @@ public:
// Destructor
virtual ~Splinterpolator() { if(_own_coef) delete [] _coef; }
// Assignment. May be removed in future
Splinterpolator& operator=(const Splinterpolator& s);
// Set new data in Splinterpolator.
void Set(const T *data, const std::vector<unsigned int>& dim, const std::vector<ExtrapolationType>& et, unsigned int order=3, bool copy_low_order=true, double prec=1e-8)
{
......@@ -201,7 +204,7 @@ private:
// Disallowed member functions
//
Splinterpolator(const Splinterpolator& s); // Don't allow copy-construction
Splinterpolator& operator=(const Splinterpolator& s); // Don't allow assignment
// Splinterpolator& operator=(const Splinterpolator& s); // Don't allow assignment
};
/////////////////////////////////////////////////////////////////////
......@@ -210,6 +213,29 @@ private:
//
/////////////////////////////////////////////////////////////////////
template<class T>
Splinterpolator<T>& Splinterpolator<T>::operator=(const Splinterpolator<T>& src)
{
if (_own_coef) delete [] _coef;
_valid = src._valid;
_own_coef = src._own_coef;
_cptr = src._cptr;
_order = src._order;
_ndim = src._ndim;
_prec = src._prec;
_dim = src._dim;
_et = src._et;
if (_own_coef) { // If we need to do a deep copy
unsigned int ts = 1;
for (unsigned int i=0; i<_ndim; i++) ts *= _dim[i];
_coef = new T[ts];
memcpy(_coef,src._coef,ts*sizeof(T));
}
return(*this);
}
/////////////////////////////////////////////////////////////////////
//
// Returns interpolated value at location coord.
......
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