2017-01-06 00:01:44 +01:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
|
|
#ifndef EIGEN_ARITHMETIC_SEQUENCE_H
|
|
|
|
|
#define EIGEN_ARITHMETIC_SEQUENCE_H
|
|
|
|
|
|
2023-08-21 16:25:22 +00:00
|
|
|
// IWYU pragma: private
|
2021-09-10 19:12:26 +00:00
|
|
|
#include "./InternalHeaderCheck.h"
|
|
|
|
|
|
2017-01-06 00:01:44 +01:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
2017-01-18 11:35:27 +01:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
// Helper to cleanup the type of the increment:
|
|
|
|
|
template <typename T>
|
|
|
|
|
struct cleanup_seq_incr {
|
|
|
|
|
typedef typename cleanup_index_type<T, DynamicIndex>::type type;
|
|
|
|
|
};
|
|
|
|
|
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
} // namespace internal
|
2017-01-18 11:35:27 +01:00
|
|
|
|
2017-01-06 00:01:44 +01:00
|
|
|
//--------------------------------------------------------------------------------
|
2017-01-09 17:35:21 +01:00
|
|
|
// seq(first,last,incr) and seqN(first,size,incr)
|
2017-01-06 00:01:44 +01:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
|
|
2017-01-24 09:39:49 +01:00
|
|
|
template <typename FirstType = Index, typename SizeType = Index, typename IncrType = internal::FixedInt<1> >
|
2017-01-18 11:35:27 +01:00
|
|
|
class ArithmeticSequence;
|
|
|
|
|
|
|
|
|
|
template <typename FirstType, typename SizeType, typename IncrType>
|
|
|
|
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
|
|
|
|
typename internal::cleanup_index_type<SizeType>::type,
|
|
|
|
|
typename internal::cleanup_seq_incr<IncrType>::type>
|
|
|
|
|
seqN(FirstType first, SizeType size, IncrType incr);
|
|
|
|
|
|
2017-01-16 16:20:16 +01:00
|
|
|
/** \class ArithmeticSequence
|
2017-01-11 14:28:28 +01:00
|
|
|
* \ingroup Core_Module
|
2017-01-10 22:58:58 +01:00
|
|
|
*
|
|
|
|
|
* This class represents an arithmetic progression \f$ a_0, a_1, a_2, ..., a_{n-1}\f$ defined by
|
|
|
|
|
* its \em first value \f$ a_0 \f$, its \em size (aka length) \em n, and the \em increment (aka stride)
|
|
|
|
|
* that is equal to \f$ a_{i+1}-a_{i}\f$ for any \em i.
|
|
|
|
|
*
|
2017-01-11 14:28:28 +01:00
|
|
|
* It is internally used as the return type of the Eigen::seq and Eigen::seqN functions, and as the input arguments
|
2017-01-10 22:58:58 +01:00
|
|
|
* of DenseBase::operator()(const RowIndices&, const ColIndices&), and most of the time this is the
|
|
|
|
|
* only way it is used.
|
|
|
|
|
*
|
|
|
|
|
* \tparam FirstType type of the first element, usually an Index,
|
|
|
|
|
* but internally it can be a symbolic expression
|
|
|
|
|
* \tparam SizeType type representing the size of the sequence, usually an Index
|
|
|
|
|
* or a compile time integral constant. Internally, it can also be a symbolic expression
|
|
|
|
|
* \tparam IncrType type of the increment, can be a runtime Index, or a compile time integral constant (default is
|
|
|
|
|
* compile-time 1)
|
|
|
|
|
*
|
2017-01-11 14:28:28 +01:00
|
|
|
* \sa Eigen::seq, Eigen::seqN, DenseBase::operator()(const RowIndices&, const ColIndices&), class IndexedView
|
2017-01-10 22:58:58 +01:00
|
|
|
*/
|
2017-01-18 11:35:27 +01:00
|
|
|
template <typename FirstType, typename SizeType, typename IncrType>
|
2017-01-16 16:20:16 +01:00
|
|
|
class ArithmeticSequence {
|
2017-01-09 17:35:21 +01:00
|
|
|
public:
|
2017-01-16 16:20:16 +01:00
|
|
|
ArithmeticSequence(FirstType first, SizeType size) : m_first(first), m_size(size) {}
|
|
|
|
|
ArithmeticSequence(FirstType first, SizeType size, IncrType incr) : m_first(first), m_size(size), m_incr(incr) {}
|
2017-01-06 00:01:44 +01:00
|
|
|
|
2017-01-09 17:35:21 +01:00
|
|
|
enum {
|
2017-01-17 11:33:57 +01:00
|
|
|
SizeAtCompileTime = internal::get_fixed_value<SizeType>::value,
|
|
|
|
|
IncrAtCompileTime = internal::get_fixed_value<IncrType, DynamicIndex>::value
|
2017-01-09 17:35:21 +01:00
|
|
|
};
|
|
|
|
|
|
2017-01-10 22:58:58 +01:00
|
|
|
/** \returns the size, i.e., number of elements, of the sequence */
|
2017-01-09 17:35:21 +01:00
|
|
|
Index size() const { return m_size; }
|
2017-01-10 22:58:58 +01:00
|
|
|
|
|
|
|
|
/** \returns the first element \f$ a_0 \f$ in the sequence */
|
2017-01-10 14:25:30 +01:00
|
|
|
Index first() const { return m_first; }
|
2017-01-10 22:58:58 +01:00
|
|
|
|
|
|
|
|
/** \returns the value \f$ a_i \f$ at index \a i in the sequence. */
|
2017-01-09 17:35:21 +01:00
|
|
|
Index operator[](Index i) const { return m_first + i * m_incr; }
|
2017-01-06 00:01:44 +01:00
|
|
|
|
2017-01-09 17:35:21 +01:00
|
|
|
const FirstType& firstObject() const { return m_first; }
|
|
|
|
|
const SizeType& sizeObject() const { return m_size; }
|
|
|
|
|
const IncrType& incrObject() const { return m_incr; }
|
|
|
|
|
|
|
|
|
|
protected:
|
2017-01-06 00:01:44 +01:00
|
|
|
FirstType m_first;
|
|
|
|
|
SizeType m_size;
|
2017-01-06 13:10:10 +01:00
|
|
|
IncrType m_incr;
|
2017-01-06 00:01:44 +01:00
|
|
|
|
2017-01-18 11:35:27 +01:00
|
|
|
public:
|
2017-01-19 19:57:32 +01:00
|
|
|
auto reverse() const -> decltype(Eigen::seqN(m_first + (m_size + fix<-1>()) * m_incr, m_size, -m_incr)) {
|
|
|
|
|
return seqN(m_first + (m_size + fix<-1>()) * m_incr, m_size, -m_incr);
|
2017-01-18 11:35:27 +01:00
|
|
|
}
|
2017-01-16 16:17:01 +01:00
|
|
|
};
|
2017-01-09 17:35:21 +01:00
|
|
|
|
2017-01-16 16:20:16 +01:00
|
|
|
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and increment \a incr
|
2017-01-11 14:28:28 +01:00
|
|
|
*
|
|
|
|
|
* \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
|
2017-01-06 13:10:10 +01:00
|
|
|
template <typename FirstType, typename SizeType, typename IncrType>
|
2017-01-17 11:33:57 +01:00
|
|
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
|
|
|
|
typename internal::cleanup_index_type<SizeType>::type,
|
|
|
|
|
typename internal::cleanup_seq_incr<IncrType>::type>
|
2017-01-09 17:35:21 +01:00
|
|
|
seqN(FirstType first, SizeType size, IncrType incr) {
|
2017-01-17 11:33:57 +01:00
|
|
|
return ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
|
|
|
|
typename internal::cleanup_index_type<SizeType>::type,
|
|
|
|
|
typename internal::cleanup_seq_incr<IncrType>::type>(first, size, incr);
|
2017-01-06 00:01:44 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-16 16:20:16 +01:00
|
|
|
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and unit increment
|
2017-01-11 14:28:28 +01:00
|
|
|
*
|
2017-01-10 22:58:58 +01:00
|
|
|
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType) */
|
2017-01-06 00:01:44 +01:00
|
|
|
template <typename FirstType, typename SizeType>
|
2017-01-17 11:33:57 +01:00
|
|
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
|
|
|
|
typename internal::cleanup_index_type<SizeType>::type>
|
2017-01-09 17:35:21 +01:00
|
|
|
seqN(FirstType first, SizeType size) {
|
2017-01-17 11:33:57 +01:00
|
|
|
return ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
|
|
|
|
typename internal::cleanup_index_type<SizeType>::type>(first, size);
|
2017-01-06 00:01:44 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 22:58:58 +01:00
|
|
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
|
|
|
|
|
2017-01-16 16:20:16 +01:00
|
|
|
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and with positive (or negative) increment \a
|
|
|
|
|
* incr
|
2017-01-10 22:58:58 +01:00
|
|
|
*
|
|
|
|
|
* It is essentially an alias to:
|
|
|
|
|
* \code
|
2017-01-11 14:28:28 +01:00
|
|
|
* seqN(f, (l-f+incr)/incr, incr);
|
2017-01-10 22:58:58 +01:00
|
|
|
* \endcode
|
|
|
|
|
*
|
2017-01-11 14:28:28 +01:00
|
|
|
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType)
|
2017-01-10 22:58:58 +01:00
|
|
|
*/
|
2017-01-11 14:28:28 +01:00
|
|
|
template <typename FirstType, typename LastType, typename IncrType>
|
|
|
|
|
auto seq(FirstType f, LastType l, IncrType incr);
|
2017-01-10 22:58:58 +01:00
|
|
|
|
2017-01-16 16:20:16 +01:00
|
|
|
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and unit increment
|
2017-01-10 22:58:58 +01:00
|
|
|
*
|
|
|
|
|
* It is essentially an alias to:
|
|
|
|
|
* \code
|
2017-01-11 14:28:28 +01:00
|
|
|
* seqN(f,l-f+1);
|
2017-01-10 22:58:58 +01:00
|
|
|
* \endcode
|
|
|
|
|
*
|
2017-01-11 14:28:28 +01:00
|
|
|
* \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType)
|
2017-01-10 22:58:58 +01:00
|
|
|
*/
|
2017-01-11 14:28:28 +01:00
|
|
|
template <typename FirstType, typename LastType>
|
|
|
|
|
auto seq(FirstType f, LastType l);
|
2017-01-10 22:58:58 +01:00
|
|
|
|
|
|
|
|
#else // EIGEN_PARSED_BY_DOXYGEN
|
|
|
|
|
|
2017-01-09 23:42:16 +01:00
|
|
|
template <typename FirstType, typename LastType>
|
2017-01-24 16:28:12 +01:00
|
|
|
auto seq(FirstType f, LastType l)
|
|
|
|
|
-> decltype(seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
|
|
|
|
(typename internal::cleanup_index_type<LastType>::type(l) -
|
|
|
|
|
typename internal::cleanup_index_type<FirstType>::type(f) + fix<1>()))) {
|
|
|
|
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
|
|
|
|
(typename internal::cleanup_index_type<LastType>::type(l) -
|
|
|
|
|
typename internal::cleanup_index_type<FirstType>::type(f) + fix<1>()));
|
2017-01-09 23:42:16 +01:00
|
|
|
}
|
2017-01-06 13:10:10 +01:00
|
|
|
|
2017-01-09 23:42:16 +01:00
|
|
|
template <typename FirstType, typename LastType, typename IncrType>
|
|
|
|
|
auto seq(FirstType f, LastType l, IncrType incr)
|
2017-01-24 16:28:12 +01:00
|
|
|
-> decltype(seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
|
|
|
|
(typename internal::cleanup_index_type<LastType>::type(l) -
|
|
|
|
|
typename internal::cleanup_index_type<FirstType>::type(f) +
|
|
|
|
|
typename internal::cleanup_seq_incr<IncrType>::type(incr)) /
|
|
|
|
|
typename internal::cleanup_seq_incr<IncrType>::type(incr),
|
|
|
|
|
typename internal::cleanup_seq_incr<IncrType>::type(incr))) {
|
2017-01-16 16:17:01 +01:00
|
|
|
typedef typename internal::cleanup_seq_incr<IncrType>::type CleanedIncrType;
|
2017-01-24 16:28:12 +01:00
|
|
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
|
|
|
|
(typename internal::cleanup_index_type<LastType>::type(l) -
|
|
|
|
|
typename internal::cleanup_index_type<FirstType>::type(f) + CleanedIncrType(incr)) /
|
|
|
|
|
CleanedIncrType(incr),
|
|
|
|
|
CleanedIncrType(incr));
|
2017-01-09 23:42:16 +01:00
|
|
|
}
|
2018-07-23 16:20:25 +02:00
|
|
|
|
2017-01-10 22:58:58 +01:00
|
|
|
#endif // EIGEN_PARSED_BY_DOXYGEN
|
|
|
|
|
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
namespace placeholders {
|
2018-07-23 16:20:25 +02:00
|
|
|
|
|
|
|
|
/** \cpp11
|
|
|
|
|
* \returns a symbolic ArithmeticSequence representing the last \a size elements with increment \a incr.
|
|
|
|
|
*
|
|
|
|
|
* It is a shortcut for: \code seqN(last-(size-fix<1>)*incr, size, incr) \endcode
|
|
|
|
|
*
|
|
|
|
|
* \sa lastN(SizeType), seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
|
|
|
|
|
template <typename SizeType, typename IncrType>
|
|
|
|
|
auto lastN(SizeType size, IncrType incr)
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
-> decltype(seqN(Eigen::placeholders::last - (size - fix<1>()) * incr, size, incr)) {
|
|
|
|
|
return seqN(Eigen::placeholders::last - (size - fix<1>()) * incr, size, incr);
|
2018-07-23 16:20:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \cpp11
|
|
|
|
|
* \returns a symbolic ArithmeticSequence representing the last \a size elements with a unit increment.
|
|
|
|
|
*
|
|
|
|
|
* It is a shortcut for: \code seq(last+fix<1>-size, last) \endcode
|
|
|
|
|
*
|
|
|
|
|
* \sa lastN(SizeType,IncrType, seqN(FirstType,SizeType), seq(FirstType,LastType) */
|
|
|
|
|
template <typename SizeType>
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
auto lastN(SizeType size) -> decltype(seqN(Eigen::placeholders::last + fix<1>() - size, size)) {
|
|
|
|
|
return seqN(Eigen::placeholders::last + fix<1>() - size, size);
|
2018-07-23 16:20:25 +02:00
|
|
|
}
|
|
|
|
|
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
} // namespace placeholders
|
|
|
|
|
|
2017-01-06 00:01:44 +01:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
// Convert a symbolic span into a usable one (i.e., remove last/end "keywords")
|
2017-01-09 23:42:16 +01:00
|
|
|
template <typename T>
|
|
|
|
|
struct make_size_type {
|
2022-03-16 16:43:40 +00:00
|
|
|
typedef std::conditional_t<symbolic::is_symbolic<T>::value, Index, T> type;
|
2017-01-09 23:42:16 +01:00
|
|
|
};
|
|
|
|
|
|
2017-01-11 17:24:02 +01:00
|
|
|
template <typename FirstType, typename SizeType, typename IncrType, int XprSize>
|
2017-01-16 16:20:16 +01:00
|
|
|
struct IndexedViewCompatibleType<ArithmeticSequence<FirstType, SizeType, IncrType>, XprSize> {
|
|
|
|
|
typedef ArithmeticSequence<Index, typename make_size_type<SizeType>::type, IncrType> type;
|
2017-01-06 00:01:44 +01:00
|
|
|
};
|
|
|
|
|
|
2017-01-06 13:10:10 +01:00
|
|
|
template <typename FirstType, typename SizeType, typename IncrType>
|
2017-01-16 16:20:16 +01:00
|
|
|
ArithmeticSequence<Index, typename make_size_type<SizeType>::type, IncrType> makeIndexedViewCompatible(
|
2017-01-16 22:21:23 +01:00
|
|
|
const ArithmeticSequence<FirstType, SizeType, IncrType>& ids, Index size, SpecializedType) {
|
2017-01-16 16:20:16 +01:00
|
|
|
return ArithmeticSequence<Index, typename make_size_type<SizeType>::type, IncrType>(
|
2017-01-10 11:06:02 +01:00
|
|
|
eval_expr_given_size(ids.firstObject(), size), eval_expr_given_size(ids.sizeObject(), size), ids.incrObject());
|
2017-01-06 00:01:44 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-11 17:24:02 +01:00
|
|
|
template <typename FirstType, typename SizeType, typename IncrType>
|
2017-01-16 16:20:16 +01:00
|
|
|
struct get_compile_time_incr<ArithmeticSequence<FirstType, SizeType, IncrType> > {
|
2017-01-17 11:33:57 +01:00
|
|
|
enum { value = get_fixed_value<IncrType, DynamicIndex>::value };
|
2017-01-06 15:54:55 +01:00
|
|
|
};
|
|
|
|
|
|
2024-02-20 18:21:45 +00:00
|
|
|
template <typename FirstType, typename SizeType, typename IncrType>
|
|
|
|
|
constexpr Index get_runtime_incr(const ArithmeticSequence<FirstType, SizeType, IncrType>& x) EIGEN_NOEXCEPT {
|
|
|
|
|
return static_cast<Index>(x.incrObject());
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-06 00:01:44 +01:00
|
|
|
} // end namespace internal
|
|
|
|
|
|
2018-09-20 22:57:10 +02:00
|
|
|
/** \namespace Eigen::indexing
|
|
|
|
|
* \ingroup Core_Module
|
|
|
|
|
*
|
|
|
|
|
* The sole purpose of this namespace is to be able to import all functions
|
|
|
|
|
* and symbols that are expected to be used within operator() for indexing
|
|
|
|
|
* and slicing. If you already imported the whole Eigen namespace:
|
|
|
|
|
* \code using namespace Eigen; \endcode
|
|
|
|
|
* then you are already all set. Otherwise, if you don't want/cannot import
|
|
|
|
|
* the whole Eigen namespace, the following line:
|
|
|
|
|
* \code using namespace Eigen::indexing; \endcode
|
|
|
|
|
* is equivalent to:
|
|
|
|
|
* \code
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
using Eigen::fix;
|
2018-09-20 22:57:10 +02:00
|
|
|
using Eigen::seq;
|
|
|
|
|
using Eigen::seqN;
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
using Eigen::placeholders::all;
|
|
|
|
|
using Eigen::placeholders::last;
|
|
|
|
|
using Eigen::placeholders::lastN; // c++11 only
|
|
|
|
|
using Eigen::placeholders::lastp1;
|
2018-09-20 22:57:10 +02:00
|
|
|
\endcode
|
|
|
|
|
*/
|
|
|
|
|
namespace indexing {
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
using Eigen::fix;
|
2018-09-20 22:57:10 +02:00
|
|
|
using Eigen::seq;
|
|
|
|
|
using Eigen::seqN;
|
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the
`Eigen::` namespace. This prevents us from using the `last` or `all`
names for any parameters or local variables, otherwise spitting out
warnings about shadowing or hiding the global values. Many external
projects (and our own examples) also heavily use
```
using namespace Eigen;
```
which means these conflict with external libraries as well, e.g.
`std::fill(first,last,value)`.
It seems originally these were placed in a separate namespace
`Eigen::placeholders`, which has since been deprecated. I propose
to un-deprecate this, and restore the original locations.
These symbols are also imported into `Eigen::indexing`, which
additionally imports `fix` and `seq`. An alternative is to remove the
`placeholders` namespace and stick with `indexing`.
NOTE: this is an API-breaking change.
Fixes #2321.
2021-09-15 14:10:29 -07:00
|
|
|
using Eigen::placeholders::all;
|
|
|
|
|
using Eigen::placeholders::last;
|
|
|
|
|
using Eigen::placeholders::lastN;
|
|
|
|
|
using Eigen::placeholders::lastp1;
|
2018-09-20 22:57:10 +02:00
|
|
|
} // namespace indexing
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2017-01-06 00:01:44 +01:00
|
|
|
} // end namespace Eigen
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2017-01-06 00:01:44 +01:00
|
|
|
#endif // EIGEN_ARITHMETIC_SEQUENCE_H
|