QPot 0.12.2.dev1+g4043351
QPot.h File Reference
#include <algorithm>
#include <stdexcept>
#include <string>

Go to the source code of this file.

Namespaces

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

Macros

#define QPOT_ASSERT(expr)
 All assertions are implemented as: More...
 
#define QPOT_DEBUG(expr)
 Intensive assertions (e.g. More...
 
#define QPOT_REQUIRE(expr)   QPOT_ASSERT_IMPL(expr, __FILE__, __LINE__, __FUNCTION__)
 Assertions that cannot be disable. More...
 
#define QPOT_WARNING_PYTHON(message)
 All warnings specific to the Python API are implemented as: More...
 
#define QPOT_VERSION   "@PROJECT_VERSION@"
 Current version. More...
 

Functions

std::string QPot::version ()
 Return version string, e.g. More...
 
std::vector< std::string > QPot::version_dependencies ()
 Return versions of this library and of all of its dependencies. More...
 
template<class It , class T , class R = size_t>
QPot::iterator::lower_bound (const It first, const It last, const T &value, R guess=0, size_t proximity=10)
 Return index of the first element in the range [first, last) such that element < value is false (i.e. More...
 
template<class T , class V , class R >
void QPot::inplace::lower_bound (const T &matrix, const V &value, R &index, size_t proximity=10)
 Similar to lower_bound but on the last axis of an nd-array (e.g. More...
 
template<class V , class I >
void QPot::inplace::cumsum_chunk (V &cumsum, const V &delta, const I &shift)
 Update the chunk of a cumsum computed and stored in chunks. More...
 
template<class T , class V , class R >
QPot::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 >
QPot::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 >
QPot::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

License: This project is released under the MIT License.

Definition in file QPot.h.

Macro Definition Documentation

◆ QPOT_ASSERT

#define QPOT_ASSERT (   expr)

All assertions are implemented as:

QPOT_ASSERT(...)

They can be enabled by:

#define QPOT_ENABLE_ASSERT

(before including QPot). The advantage is that:

  • File and line-number are displayed if the assertion fails.
  • QPot's assertions can be enabled/disabled independently from those of other libraries.
Exceptions
std::runtime_error

Definition at line 54 of file QPot.h.

◆ QPOT_DEBUG

#define QPOT_DEBUG (   expr)

Intensive assertions (e.g.

checking if input is sorted) are implemented as:

QPOT_DEBUG(...)

They can be enabled by:

#define QPOT_ENABLE_DEBUG

(before including QPot).

Exceptions
std::runtime_error

Definition at line 73 of file QPot.h.

◆ QPOT_REQUIRE

#define QPOT_REQUIRE (   expr)    QPOT_ASSERT_IMPL(expr, __FILE__, __LINE__, __FUNCTION__)

Assertions that cannot be disable.

Exceptions
std::runtime_error

Definition at line 81 of file QPot.h.

◆ QPOT_VERSION

#define QPOT_VERSION   "@PROJECT_VERSION@"

Current version.

Either:

  • Configure using CMake at install time. Internally uses::
    python -c "from setuptools_scm import get_version; print(get_version())"
    
  • Define externally using::
    -DQPOT_VERSION="`python -c "from setuptools_scm import get_version; print(get_version())"`"
    
    From the root of this project. This is what setup.py does.

Note that both CMakeLists.txt and setup.py will construct the version using setuptools_scm. Tip: use the environment variable SETUPTOOLS_SCM_PRETEND_VERSION to overwrite the automatic version.

Definition at line 118 of file QPot.h.

◆ QPOT_WARNING_PYTHON

#define QPOT_WARNING_PYTHON (   message)

All warnings specific to the Python API are implemented as:

QPOT_WARNING_PYTHON(...)

They can be enabled by:

#define QPOT_ENABLE_WARNING_PYTHON

Definition at line 95 of file QPot.h.

Function Documentation

◆ cumsum_chunk()

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

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

Parameters
cumsumThe current chunk of the cumsum (updated).
deltaThe 'diff's of the next chunk in the cumsum.
shiftThe shift per row.

Definition at line 288 of file QPot.h.

◆ lower_bound() [1/2]

template<class It , class T , class R = size_t>
R QPot::iterator::lower_bound ( const It  first,
const It  last,
const T &  value,
guess = 0,
size_t  proximity = 10 
)
inline

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.

Compared to the default function, 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
firstIterator defining the beginning of the range to examine (e.g. a.begin()).
lastIterator defining the end of the range to examine (e.g. a.end())
valueValue to find.
guessGuess of the index where to find the value.
proximitySize of the proximity search around guess (use 0 to disable proximity search).
Returns
The index of value (i.e. a[index] < value <= a[index + 1]).

Definition at line 214 of file QPot.h.

◆ lower_bound() [2/2]

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

Similar to lower_bound but on the last axis of an nd-array (e.g.

per row of a rank 2 matrix).

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

Definition at line 254 of file QPot.h.