mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fix return type for TensorEvaluator<TensorSlicingOp>::data
This commit is contained in:
parent
9d993c709b
commit
31afdcb4c2
@ -463,8 +463,8 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
|
|||||||
return m_impl.coeff(inputCoords);
|
return m_impl.coeff(inputCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType* data() const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar* data() const {
|
||||||
CoeffReturnType* result = m_impl.data();
|
Scalar* result = m_impl.data();
|
||||||
if (result) {
|
if (result) {
|
||||||
Index offset = 0;
|
Index offset = 0;
|
||||||
if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
|
if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
|
||||||
|
@ -114,6 +114,16 @@ static void test_simple_slice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_const_slice()
|
||||||
|
{
|
||||||
|
const float b[1] = {42};
|
||||||
|
TensorMap<Tensor<const float, 1> > m(b, 1);
|
||||||
|
DSizes<DenseIndex, 1> offsets;
|
||||||
|
offsets[0] = 0;
|
||||||
|
TensorRef<Tensor<const float, 1> > slice_ref(m.slice(offsets, m.dimensions()));
|
||||||
|
VERIFY_IS_EQUAL(slice_ref(0), 42);
|
||||||
|
}
|
||||||
|
|
||||||
template<int DataLayout>
|
template<int DataLayout>
|
||||||
static void test_slice_in_expr() {
|
static void test_slice_in_expr() {
|
||||||
typedef Matrix<float, Dynamic, Dynamic, DataLayout> Mtx;
|
typedef Matrix<float, Dynamic, Dynamic, DataLayout> Mtx;
|
||||||
@ -333,6 +343,7 @@ void test_cxx11_tensor_morphing()
|
|||||||
|
|
||||||
CALL_SUBTEST(test_simple_slice<ColMajor>());
|
CALL_SUBTEST(test_simple_slice<ColMajor>());
|
||||||
CALL_SUBTEST(test_simple_slice<RowMajor>());
|
CALL_SUBTEST(test_simple_slice<RowMajor>());
|
||||||
|
CALL_SUBTEST(test_const_slice());
|
||||||
CALL_SUBTEST(test_slice_in_expr<ColMajor>());
|
CALL_SUBTEST(test_slice_in_expr<ColMajor>());
|
||||||
CALL_SUBTEST(test_slice_in_expr<RowMajor>());
|
CALL_SUBTEST(test_slice_in_expr<RowMajor>());
|
||||||
CALL_SUBTEST(test_slice_as_lvalue<ColMajor>());
|
CALL_SUBTEST(test_slice_as_lvalue<ColMajor>());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user