aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/ArithmeticSequence.h27
-rw-r--r--Eigen/src/Core/IndexedView.h35
-rw-r--r--Eigen/src/Core/util/Constants.h4
3 files changed, 45 insertions, 21 deletions
diff --git a/Eigen/src/Core/ArithmeticSequence.h b/Eigen/src/Core/ArithmeticSequence.h
index 06b6b53eb..1585c1dbf 100644
--- a/Eigen/src/Core/ArithmeticSequence.h
+++ b/Eigen/src/Core/ArithmeticSequence.h
@@ -160,7 +160,7 @@ span(FirstType first, SizeType size) {
namespace internal {
template<typename T, int XprSize, typename EnableIf = void> struct get_compile_time_size {
- enum { value = -1 };
+ enum { value = Dynamic };
};
template<typename T, int XprSize> struct get_compile_time_size<T,XprSize,typename internal::enable_if<((T::SizeAtCompileTime&0)==0)>::type> {
@@ -173,6 +173,21 @@ template<typename T, int XprSize, int N> struct get_compile_time_size<std::array
};
#endif
+template<typename T, typename EnableIf = void> struct get_compile_time_incr {
+ enum { value = UndefinedIncr };
+};
+
+template<typename FirstType,typename LastType,typename IncrType>
+struct get_compile_time_incr<Range_t<FirstType,LastType,IncrType> > {
+ enum { value = get_compile_time<IncrType,DynamicIndex>::value };
+};
+
+template<typename FirstType,typename SizeType,typename IncrType>
+struct get_compile_time_incr<Span_t<FirstType,SizeType,IncrType> > {
+ enum { value = get_compile_time<IncrType,DynamicIndex>::value };
+};
+
+
// MakeIndexing/make_indexing turn an arbitrary object of type T into something usable by MatrixSlice
template<typename T,typename EnableIf=void>
struct MakeIndexing {
@@ -180,7 +195,7 @@ struct MakeIndexing {
};
template<typename T>
-const T& make_indexing(const T& x, Index size) { return x; }
+const T& make_indexing(const T& x, Index /*size*/) { return x; }
struct IntAsArray {
enum {
@@ -192,6 +207,10 @@ struct IntAsArray {
Index m_value;
};
+template<> struct get_compile_time_incr<IntAsArray> {
+ enum { value = 1 }; // 1 or 0 ??
+};
+
// Turn a single index into something that looks like an array (i.e., that exposes a .size(), and operatro[](int) methods)
template<typename T>
struct MakeIndexing<T,typename internal::enable_if<internal::is_integral<T>::value>::type> {
@@ -254,6 +273,10 @@ template<int XprSize> struct get_compile_time_size<AllRange,XprSize> {
enum { value = XprSize };
};
+template<> struct get_compile_time_incr<AllRange> {
+ enum { value = 1 };
+};
+
} // end namespace internal
} // end namespace Eigen
diff --git a/Eigen/src/Core/IndexedView.h b/Eigen/src/Core/IndexedView.h
index bc1eff8f9..26c048584 100644
--- a/Eigen/src/Core/IndexedView.h
+++ b/Eigen/src/Core/IndexedView.h
@@ -29,12 +29,24 @@ struct traits<IndexedView<XprType, RowIndices, ColIndices> >
: (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
: XprTypeIsRowMajor,
+ RowIncr = get_compile_time_incr<RowIndices>::value,
+ ColIncr = get_compile_time_incr<ColIndices>::value,
+ InnerIncr = IsRowMajor ? ColIncr : RowIncr,
+ OuterIncr = IsRowMajor ? RowIncr : ColIncr,
+
+ HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
+ XprInnerStride = HasSameStorageOrderAsXprType ? int(inner_stride_at_compile_time<XprType>::ret) : int(outer_stride_at_compile_time<XprType>::ret),
+ XprOuterstride = HasSameStorageOrderAsXprType ? int(outer_stride_at_compile_time<XprType>::ret) : int(inner_stride_at_compile_time<XprType>::ret),
+
+ InnerStrideAtCompileTime = InnerIncr<0 || InnerIncr==DynamicIndex || XprInnerStride==Dynamic ? Dynamic : XprInnerStride * InnerIncr,
+ OuterStrideAtCompileTime = OuterIncr<0 || OuterIncr==DynamicIndex || XprOuterstride==Dynamic ? Dynamic : XprOuterstride * OuterIncr,
+
+ // FIXME we deal with compile-time strides if and only if we have DirectAccessBit flag,
+ // but this is too strict regarding negative strides...
+ DirectAccessMask = (InnerIncr!=UndefinedIncr && OuterIncr!=UndefinedIncr && InnerIncr>=0 && OuterIncr>=0) ? DirectAccessBit : 0,
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
- Flags = (traits<XprType>::Flags & HereditaryBits) | FlagsLvalueBit | FlagsRowMajorBit,
- //MatrixTypeInnerStride = inner_stride_at_compile_time<XprType>::ret,
- InnerStrideAtCompileTime = int(Dynamic),
- OuterStrideAtCompileTime = int(Dynamic)
+ Flags = (traits<XprType>::Flags & (HereditaryBits | DirectAccessMask)) | FlagsLvalueBit | FlagsRowMajorBit
};
};
@@ -72,21 +84,6 @@ public:
const RowIndices& rowIndices() const { return m_rowIndices; }
const ColIndices& colIndices() const { return m_colIndices; }
-// std::pair<Index,Index> index(Index i, Index j) const {
-// return std::pair<Index,Index>(m_rowIndices[i], m_colIndices[j]);
-// }
-//
-// void print() const {
-// for(Index i=0; i<rows(); ++i)
-// {
-// for(Index j=0; j<cols(); ++j)
-// {
-// std::pair<Index,Index> k = index(i,j);
-// std::cout << '(' << k.first << ',' << k.second << ") ";
-// }
-// std::cout << '\n';
-// }
-// }
protected:
MatrixTypeNested m_xpr;
RowIndices m_rowIndices;
diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h
index 7587d6842..5d37e5d04 100644
--- a/Eigen/src/Core/util/Constants.h
+++ b/Eigen/src/Core/util/Constants.h
@@ -25,6 +25,10 @@ const int Dynamic = -1;
*/
const int DynamicIndex = 0xffffff;
+/** This value means that the increment to go from one value to another in a sequence is not constant for each step.
+ */
+const int UndefinedIncr = 0xfffffe;
+
/** This value means +Infinity; it is currently used only as the p parameter to MatrixBase::lpNorm<int>().
* The value Infinity there means the L-infinity norm.
*/