// 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/.
// Helper to cleanup the type of the increment: template<typename T> struct cleanup_seq_incr { typedeftypename cleanup_index_type<T,DynamicIndex>::type type;
};
}
//-------------------------------------------------------------------------------- // seq(first,last,incr) and seqN(first,size,incr) //--------------------------------------------------------------------------------
template<typename FirstType=Index,typename SizeType=Index,typename IncrType=internal::FixedInt<1> > class ArithmeticSequence;
/** \class ArithmeticSequence * \ingroup Core_Module * * 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. * * It is internally used as the return type of the Eigen::seq and Eigen::seqN functions, and as the input arguments * 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) * * \sa Eigen::seq, Eigen::seqN, DenseBase::operator()(const RowIndices&, const ColIndices&), class IndexedView
*/ template<typename FirstType,typename SizeType,typename IncrType> class ArithmeticSequence
{ public:
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) {}
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and unit increment *
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType) */ template<typename FirstType,typename SizeType>
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,typename internal::cleanup_index_type<SizeType>::type >
seqN(FirstType first, SizeType size) { return ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,typename internal::cleanup_index_type<SizeType>::type>(first,size);
}
#ifdef EIGEN_PARSED_BY_DOXYGEN
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and with positive (or negative) increment \a incr * * It is essentially an alias to: * \code * seqN(f, (l-f+incr)/incr, incr); * \endcode * * \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType)
*/ template<typename FirstType,typename LastType, typename IncrType> auto seq(FirstType f, LastType l, IncrType incr);
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and unit increment * * It is essentially an alias to: * \code * seqN(f,l-f+1); * \endcode * * \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType)
*/ template<typename FirstType,typename LastType> auto seq(FirstType f, LastType l);
#if EIGEN_HAS_CXX11 || defined(EIGEN_PARSED_BY_DOXYGEN) /** \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)
-> decltype(seqN(Eigen::last-(size-fix<1>())*incr, size, incr))
{ return seqN(Eigen::last-(size-fix<1>())*incr, size, incr);
}
/** \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> auto lastN(SizeType size)
-> decltype(seqN(Eigen::last+fix<1>()-size, size))
{ return seqN(Eigen::last+fix<1>()-size, size);
} #endif
namespace internal {
// Convert a symbolic span into a usable one (i.e., remove last/end "keywords") template<typename T> struct make_size_type { typedeftypename internal::conditional<symbolic::is_symbolic<T>::value, Index, T>::type type;
};
/** \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 using Eigen::all; using Eigen::seq; using Eigen::seqN; using Eigen::lastN; // c++11 only using Eigen::last; using Eigen::lastp1; using Eigen::fix; \endcode
*/ namespace indexing { using Eigen::all; using Eigen::seq; using Eigen::seqN; #if EIGEN_HAS_CXX11 using Eigen::lastN; #endif using Eigen::last; using Eigen::lastp1; using Eigen::fix;
}
} // end namespace Eigen
#endif// EIGEN_ARITHMETIC_SEQUENCE_H
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.