Utilities#

template<typename T>
inline int sign(T val)#

Complexity: Constant

Returns:

the sign of val

template<typename T, typename Iter, internal::require_forward_iterator<Iter> = true>
inline Iter lower_bound(Iter first, Iter last, T val)#

Searches for a element in the range [first, last[ that is greater or equal than val.

Complexity: Logarithmic in std::distance(first, last)

Note

The range must be sorted in ascended order.

Parameters:
  • first[in] iterator to the first element in the range

  • last[in] iterator to the “past-the-end” element in the range

  • val[in] value to compare the element to

Returns:

iterator to the first element in the range that satisfy the conditions, or last if no element is found

template<typename Array, typename T>
inline index_t lower_bound(const Array &array, T val)#
template<typename Array, typename T>
inline index_t lower_bound(const Array &array, T val, index_t begin, index_t end)#

Searches for a element in the container that is greater or equal than val. If begin and end are not provided, search the entire container.

Complexity: Logarithmic in array.size()

Note

The entries of the container must be sorted in ascended order. The container must also support the subscript operator [], and if the range [begin, end[ is not defined, the size() routine.

Parameters:
  • array[in] container

  • val[in] value to compare the element to

  • begin[in] first element in the search range (optional)

  • end[in] “past-the-end” element in the search range (optional)

Returns:

the index of the first element in the container that satisfy the conditions, or -1 if no element was found.

template<typename T, typename Iter, internal::require_forward_iterator<Iter> = true>
inline Iter upper_bound(Iter first, Iter last, T val)#

Searches for a element in the range [first, last[ that is greater than val.

Complexity: Logarithmic in std::distance(first, last)

Note

The range must be sorted in ascended order.

Parameters:
  • first[in] iterator to the first element in the range

  • last[in] iterator to the “past-the-end” element in the range

  • val[in] value to compare the element to

Returns:

iterator to the first element in the range that satisfy the conditions, or last if no element is found

template<typename Array, typename T>
inline index_t upper_bound(const Array &array, T val)#
template<typename Array, typename T>
inline index_t upper_bound(const Array &array, T val, index_t begin, index_t end)#

Searches for a element in the container that is greater than val. If begin and end are not provided, search the entire container.

Complexity: Logarithmic in array.size()

Note

The entries of the container must be sorted in ascended order. The container must also support the subscript operator [], and if the range [begin, end[ is not defined, the size() routine.

Parameters:
  • array[in] container

  • val[in] value to compare the element to

  • begin[in] first element in the search range (optional)

  • end[in] “past-the-end” element in the search range (optional)

Returns:

the index of the first element in the container that satisfy the conditions, or -1 if no element was found.

template<typename InIter, typename OutIter, internal::require_input_iterator<InIter> = true>
inline void inclusive_scan(InIter first, InIter last, OutIter out)#

Calculates the prefix (or cumulative) sum of the range [first, last[ and then write the results to the range beginning in the out iterator. The “inclusive” indicates that the i-th element is included in the i-th sum.

Complexity: Linear in std::distance(first, last)

Parameters:
  • first[in] iterator to the first element in the range

  • last[in] iterator to the “past-the-end” element in the range

  • out[out] iterator to the first element in the output range

template<typename E>
inline void inclusive_scan(MatrixBase<E> &expr, internal::NoAxis)#
template<typename E>
inline void inclusive_scan(MatrixBase<E> &expr, internal::Rowwise)#
template<typename E>
inline void inclusive_scan(MatrixBase<E> &expr)#

Calculates the prefix (or cumulative) sum of a matrix expression and then write the result to another matrix or vector. The “inclusive” indicates that the i-th element is included in the i-th sum.

Complexity: Linear in expr.size()

Parameters:
  • in[in] input expression

  • out[out] output matrix or vector

  • axis[in] operation axis (optional)

template<typename InIter, typename OutIter, internal::require_input_iterator<InIter> = true>
inline void exclusive_scan(InIter first, InIter last, OutIter out)#

Calculates the prefix (or cumulative) sum of the range [first, last[ and then write the results to the range beginning in the out iterator. The “exclusive” indicates that the i-th element is excluded in the i-th sum.

Complexity: Linear in std::distance(first, last)

Parameters:
  • first[in] iterator to the first element in the range

  • last[in] iterator to the “past-the-end” element in the range

  • out[out] iterator to the first element in the output range

template<typename E>
inline void exclusive_scan(MatrixBase<E> &expr, internal::NoAxis)#
template<typename E>
inline void exclusive_scan(MatrixBase<E> &expr, internal::Rowwise)#
template<typename E>
inline void exclusive_scan(MatrixBase<E> &expr)#

Calculates the prefix (or cumulative) sum of a matrix expression and then write the result to another matrix or vector. The “inclusive” indicates that the i-th element is included in the i-th sum.

Complexity: Linear in expr.size()

Parameters:
  • in[in] input expression

  • out[out] output matrix or vector

  • axis[in] operation axis (optional)