aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-07-13 11:16:37 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-07-13 11:16:37 -0700
commitb80036abec3c008306852334d7c8f057fee11d54 (patch)
treed66953452950cf8d4a6eccb9606f081a857f12ba /unsupported
parent3912ca0d5388fc58853d2fd8f1773e920f55523b (diff)
Enabled the construction of a fixed sized tensor directly from an expression.
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorBase.h2
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h17
-rw-r--r--unsupported/test/cxx11_tensor_intdiv.cpp13
3 files changed, 32 insertions, 0 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
index 165bd8a89..ca712f9c5 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
@@ -492,6 +492,7 @@ class TensorBase<Derived, ReadOnlyAccessors>
protected:
template <typename Scalar, std::size_t NumIndices, int Options, typename IndexType> friend class Tensor;
+ template <typename Scalar, typename Dimensions, int Option, typename IndexTypes> friend class TensorFixedSize;
template <typename OtherDerived, int AccessLevel> friend class TensorBase;
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE const Derived& derived() const { return *static_cast<const Derived*>(this); }
@@ -508,6 +509,7 @@ class TensorBase<Derived, WriteAccessors> : public TensorBase<Derived, ReadOnlyA
static const int NumDimensions = DerivedTraits::NumDimensions;
template <typename Scalar, std::size_t NumIndices, int Options, typename IndexType> friend class Tensor;
+ template <typename Scalar, typename Dimensions, int Option, typename IndexTypes> friend class TensorFixedSize;
template <typename OtherDerived, int AccessLevel> friend class TensorBase;
EIGEN_DEVICE_FUNC
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h b/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
index 76998b690..5e511dc4b 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
@@ -197,6 +197,23 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
}
#endif
+ template<typename OtherDerived>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE TensorFixedSize(const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
+ {
+ typedef TensorAssignOp<TensorFixedSize, const OtherDerived> Assign;
+ Assign assign(*this, other.derived());
+ internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
+ }
+ template<typename OtherDerived>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE TensorFixedSize(const TensorBase<OtherDerived, WriteAccessors>& other)
+ {
+ typedef TensorAssignOp<TensorFixedSize, const OtherDerived> Assign;
+ Assign assign(*this, other.derived());
+ internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
+ }
+
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE TensorFixedSize& operator=(const TensorFixedSize& other)
{
diff --git a/unsupported/test/cxx11_tensor_intdiv.cpp b/unsupported/test/cxx11_tensor_intdiv.cpp
index a50356c74..134329034 100644
--- a/unsupported/test/cxx11_tensor_intdiv.cpp
+++ b/unsupported/test/cxx11_tensor_intdiv.cpp
@@ -68,10 +68,23 @@ void test_unsigned_64bit()
}
+void test_specific()
+{
+ // A particular combination that exposed a bug in the past.
+ int64_t div = 209715200;
+ int64_t num = 3238002688;
+ Eigen::internal::TensorIntDivisor<int64_t> divider =
+ Eigen::internal::TensorIntDivisor<int64_t>(div);
+ int64_t result = num/div;
+ int64_t result_op = divider.divide(num);
+ VERIFY_IS_EQUAL(result, result_op);
+}
+
void test_cxx11_tensor_intdiv()
{
CALL_SUBTEST_1(test_signed_32bit());
CALL_SUBTEST_2(test_unsigned_32bit());
CALL_SUBTEST_3(test_signed_64bit());
CALL_SUBTEST_4(test_unsigned_64bit());
+ CALL_SUBTEST_5(test_specific());
}