MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / lower_bound

Function lower_bound

Src/Base/AMReX_Algorithm.H:276–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274 */
275 template<typename ItType, typename ValType>
276 AMREX_GPU_HOST_DEVICE
277 ItType lower_bound (ItType first, ItType last, const ValType& val)
278 {
279 AMREX_IF_ON_DEVICE((
280 std::ptrdiff_t count = last-first;
281 while(count>0)
282 {
283 auto it = first;
284 const auto step = count/2;
285 it += step;
286 if (*it < val){
287 first = ++it;
288 count -= step + 1;
289 }
290 else{
291 count = step;
292 }
293 }
294
295 return first;
296 ))
297 AMREX_IF_ON_HOST((
298 return std::lower_bound(first, last, val);
299 ))
300 }
301
302 /**
303 * \brief Fill a range with linearly spaced values over a closed interval.

Callers 3

knapsackFunction · 0.85
KnapSackProcessorMapMethod · 0.85
localindexMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected