1#ifndef __FIBER_COORDINATEAXISARRAY_HPP
2#define __FIBER_COORDINATEAXISARRAY_HPP
4#ifndef DONT_USE_PRAGMA_ONCE
22template <
class T,
class Category>
76 bool locate(T&value)
const
80 value = (value - (*this)[0] ) / (*
this)[1];
109 , length( Src.length )
133 return (*
this)[0] + i*(*this)[1];
145 const T&delta = (*this)[1];
154 return (value - (*
this)[0] ) / delta;
178 bool locate(T&value)
const
199 void setupCoordinateLookupMap()
203 CoordinateLookupMap.
clear();
204 for(
index_t i=0; i<data.size(); i++)
206 CoordinateLookupMap[ data[i] ] = i;
232 return this->elements();
237 if (this->elements()<1)
return 0.0;
239 MEMCORE_PROFILE_THIS(
"CoordinateAxisArray::reverse(): Non STL Bin Search", 1);
243 size_t elements = CoordinateLookupMap.
size() - 1;
255 printf(
"\nReverse lookup, Explicit Coordinates: Elements= %d, Low= %d, high= %d\n", elements, low, high);
256 if(value<CoordinateLookupMap[low])
258 return CoordinateLookupMap[low];
260 else if(value>CoordinateLookupMap[high])
262 return CoordinateLookupMap[high];
264 printf(
"\nCoordinate in range");
268 if(value<CoordinateLookupMap[mid])
273 printf(
"\nReverse lookup, Explicit Coordinates: Elements= %d, Low= %d, high= %d\n", elements, low, high);
274 T LeftValue = CoordinateLookupMap[low];
275 T RightValue = CoordinateLookupMap[high];
276 index_t IndexValue = low;
279 if (CoordinateLookupMap.
empty() )
281 setupCoordinateLookupMap();
283 typename CoordinateLookupMap_t::const_iterator
284 LocationJustLargerThanValue = CoordinateLookupMap.
lower_bound( value );
286 if (LocationJustLargerThanValue == CoordinateLookupMap.
end() )
287 return double( CoordinateLookupMap.
rbegin()->second );
289 if (LocationJustLargerThanValue == CoordinateLookupMap.
begin() )
290 return double( CoordinateLookupMap.
begin()->second );
292 typename CoordinateLookupMap_t::const_iterator
293 LocationJustSmallerThanValue = LocationJustLargerThanValue;
294 LocationJustSmallerThanValue--;
296 T LeftValue = LocationJustSmallerThanValue->first;
297 T RightValue = LocationJustLargerThanValue ->first;
299 if(value < LeftValue)
301 printf(
"\n%lg, %lg, %lg\n", value, LeftValue, (value - LeftValue));
302 printf(
"%lg, %d \n", CoordinateLookupMap.
begin()->first,
int(CoordinateLookupMap.
begin()->second) );
306 assert( value >= LeftValue );
307 assert( value <= RightValue );
309 index_t IndexValue = LocationJustSmallerThanValue->second;
311 double Weight = (value - LeftValue) / ( RightValue - LeftValue);
313 return IndexValue + Weight;
327 bool locate(T&value)
const
331 value = (value - (*this)[0] ) / (*
this)[1];
constexpr void reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
bool empty() const noexcept
const_reverse_iterator rbegin() const noexcept
const_iterator end() const noexcept
size_type size() const noexcept
iterator lower_bound(const key_type &__x)
const_iterator begin() const noexcept
T operator()(index_t i) const
The element access function.
Definition CoordinateAxisArray.hpp:225
CoordinateAxisArray(index_t max_idx)
Construct an coordinate array.
Definition CoordinateAxisArray.hpp:215
T operator()(index_t i) const
The element access function.
Definition CoordinateAxisArray.hpp:131
CoordinateAxisArray(const T &C0, const T &C1, index_t max_idx)
Create a procedural array of equidistant values.
Definition CoordinateAxisArray.hpp:121
index_t Length() const
Return the length of the array in terms of points covered.
Definition CoordinateAxisArray.hpp:162
double reverse(const T &value) const
Compute the floating point index that corresponds to the given coordinate value.
Definition CoordinateAxisArray.hpp:143
T operator()(index_t i) const
The element access function.
Definition CoordinateAxisArray.hpp:48
CoordinateAxisArray(index_t max_idx)
Construct a polynomial array.
Definition CoordinateAxisArray.hpp:42
Definition CoordinateAxisArray.hpp:23
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
Definition CoordinateAxisArray.hpp:20
Definition CoordinateAxisArray.hpp:18
Definition CoordinateAxisArray.hpp:19