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

Changed indx2indx to ensure correct handling of indicies very far from FOV

parent 1f05b288
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include "newmat.h"
#include "miscmaths/miscmaths.h"
......@@ -1135,6 +1136,30 @@ inline std::pair<double,double> Splinterpolator<T>::range() const
//
/////////////////////////////////////////////////////////////////////
template<class T>
inline unsigned int Splinterpolator<T>::indx2indx(int indx, unsigned int d) const
{
if (d > (_ndim-1)) return(0);
if (indx >= 0 && indx < static_cast<int>(_dim[d])) return(indx);
int dim = static_cast<int>(_dim[d]); // To ensure right behaviour of integer division
if (_et[d] == Constant) {
if (indx < 0) indx = 0;
else if (indx >= dim) indx = dim-1;
}
else if (_et[d] == Zeros || _et[d] == Mirror) {
while (indx < 0) indx = 2*dim*((indx+1)/dim) - 1 - indx;
while (indx >= dim) indx = 2*dim*(indx/dim) - 1 - indx;
}
else if (_et[d] == Periodic) {
while (indx < 0) indx += dim;
while (indx >= dim) indx -= dim;
}
return(static_cast<unsigned int>(indx));
}
/*
template<class T>
inline unsigned int Splinterpolator<T>::indx2indx(int indx, unsigned int d) const
{
......@@ -1177,7 +1202,7 @@ inline unsigned int Splinterpolator<T>::indx2indx(int indx, unsigned int d) cons
return(indx);
}
*/
// The next routine is defunct and will be moved out of this file.
/*
......
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