QPot 0.12.2.dev1+g4043351
QPot Namespace Reference

Function to find items in an increase range, and to store this range in chunks. More...

Functions

std::string version ()
 Return version string, e.g. More...
 
std::vector< std::string > version_dependencies ()
 Return versions of this library and of all of its dependencies. More...
 
template<class T , class V , class R >
lower_bound (const T &matrix, const V &value, const R &index, size_t proximity=10)
 Iterating on the last axis of an nd-array (e.g. More...
 
template<class T , class V , class R >
lower_bound (const T &matrix, const V &value)
 Iterating on the last axis of an nd-array (e.g. More...
 
template<class V , class I >
cumsum_chunk (const V &cumsum, const V &delta, const I &shift)
 Update the chunk of a cumsum computed and stored in chunks. More...
 

Detailed Description

Function to find items in an increase range, and to store this range in chunks.

Function Documentation

◆ cumsum_chunk()

template<class V , class I >
V QPot::cumsum_chunk ( const V &  cumsum,
const V &  delta,
const I &  shift 
)
inline

Update the chunk of a cumsum computed and stored in chunks.

Example

Consider a full array:

da = np.random.random(N)
a = np.cumsum(a)

With chunk settings:

n = ...  # size of each new chunk
nbuffer = ... # number of items to buffer

The the first chunk:

chunk = np.copy(a[:n + nbuffer])
nchunk = n + nbuffer
istart = np.array(0)

Then, moving right:

QPot.cumsum_chunk_inplace(chunk, da[istart + nchunk : istart + nchunk + n], n)
istart += n

Or, moving left:

QPot.cumsum_chunk_inplace(chunk, da[istart - n : istart + 1], -n)
istart -= n
Parameters
cumsumThe current chunk of the cumsum.
deltaThe 'diff's of the next chunk in the cumsum.
shiftThe shift per row.
Returns
Same shape as cumsum.

Definition at line 414 of file QPot.h.

◆ lower_bound() [1/2]

template<class T , class V , class R >
R QPot::lower_bound ( const T &  matrix,
const V &  value 
)
inline

Iterating on the last axis of an nd-array (e.g.

per row of a rank 2 matrix): Return index of the first element in the range [first, last) such that element < value is false (i.e. greater or equal to), or last if no such element is found.

Parameters
matrixThe matrix defining a range per row.
valueThe value to find (per row).
Returns
Same shape as value.

Definition at line 370 of file QPot.h.

◆ lower_bound() [2/2]

template<class T , class V , class R >
R QPot::lower_bound ( const T &  matrix,
const V &  value,
const R &  index,
size_t  proximity = 10 
)
inline

Iterating on the last axis of an nd-array (e.g.

per row of a rank 2 matrix): Return index of the first element in the range [first, last) such that element < value is false (i.e. greater or equal to), or last if no such element is found.

This function allows for a guess of the index and a proximity search around. This could be efficient for finding items in large arrays.

Parameters
matrixThe matrix defining a range per row.
valueThe value to find (per row).
indexInitial guess on index.
proximitySize of the proximity search around guess (use 0 to disable proximity search).
Returns
Same shape as index.

Definition at line 353 of file QPot.h.

◆ version()

std::string QPot::version ( )
inline

Return version string, e.g.

:

"0.8.0"
Returns
std::string

Definition at line 144 of file QPot.h.

◆ version_dependencies()

std::vector< std::string > QPot::version_dependencies ( )
inline

Return versions of this library and of all of its dependencies.

The output is a list of strings, e.g.:

"qpot=0.8.0",
"xtensor=0.20.1"
...
Returns
List of strings.

Definition at line 159 of file QPot.h.