10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_BASE_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_BASE_H
25 #ifndef EIGEN_PARSED_BY_DOXYGEN
28 template<
typename Derived>
32 typedef internal::traits<Derived> DerivedTraits;
33 typedef typename DerivedTraits::Scalar Scalar;
34 typedef typename DerivedTraits::Index
Index;
35 typedef typename internal::remove_const<Scalar>::type CoeffReturnType;
36 static const int NumDimensions = DerivedTraits::NumDimensions;
39 template <
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
40 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<CustomNullaryOp, const Derived>
41 nullaryExpr(
const CustomNullaryOp& func)
const {
42 return TensorCwiseNullaryOp<CustomNullaryOp, const Derived>(derived(), func);
47 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived>
48 constant(
const Scalar& value)
const {
49 return nullaryExpr(internal::scalar_constant_op<Scalar>(value));
53 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<internal::UniformRandomGenerator<Scalar>,
const Derived>
55 return nullaryExpr(internal::UniformRandomGenerator<Scalar>());
57 template <
typename RandomGenerator> EIGEN_DEVICE_FUNC
58 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<RandomGenerator, const Derived>
59 random(
const RandomGenerator& gen = RandomGenerator())
const {
60 return nullaryExpr(gen);
64 template <
typename Generator> EIGEN_DEVICE_FUNC
65 EIGEN_STRONG_INLINE
const TensorGeneratorOp<Generator, const Derived>
66 generate(
const Generator& generator)
const {
67 return TensorGeneratorOp<Generator, const Derived>(derived(), generator);
71 template <
typename CustomUnaryOp> EIGEN_DEVICE_FUNC
72 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<CustomUnaryOp, const Derived>
73 unaryExpr(
const CustomUnaryOp& func)
const {
74 return TensorCwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
79 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_opposite_op<Scalar>,
const Derived>
81 return unaryExpr(internal::scalar_opposite_op<Scalar>());
85 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_sqrt_op<Scalar>,
const Derived>
87 return unaryExpr(internal::scalar_sqrt_op<Scalar>());
91 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_sign_op<Scalar>,
const Derived>
93 return unaryExpr(internal::scalar_sign_op<Scalar>());
97 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_rsqrt_op<Scalar>,
const Derived>
99 return unaryExpr(internal::scalar_rsqrt_op<Scalar>());
103 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_square_op<Scalar>,
const Derived>
105 return unaryExpr(internal::scalar_square_op<Scalar>());
109 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_cube_op<Scalar>,
const Derived>
111 return unaryExpr(internal::scalar_cube_op<Scalar>());
115 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_inverse_op<Scalar>,
const Derived>
117 return unaryExpr(internal::scalar_inverse_op<Scalar>());
121 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_tanh_op<Scalar>,
const Derived>
123 return unaryExpr(internal::scalar_tanh_op<Scalar>());
127 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_lgamma_op<Scalar>,
const Derived>
129 return unaryExpr(internal::scalar_lgamma_op<Scalar>());
133 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_digamma_op<Scalar>,
const Derived>
135 return unaryExpr(internal::scalar_digamma_op<Scalar>());
139 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
140 const TensorCwiseBinaryOp<internal::scalar_igamma_op<Scalar>,
const Derived,
const OtherDerived>
141 igamma(
const OtherDerived& other)
const {
142 return binaryExpr(other.derived(), internal::scalar_igamma_op<Scalar>());
146 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
147 const TensorCwiseBinaryOp<internal::scalar_igammac_op<Scalar>,
const Derived,
const OtherDerived>
148 igammac(
const OtherDerived& other)
const {
149 return binaryExpr(other.derived(), internal::scalar_igammac_op<Scalar>());
153 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
154 const TensorCwiseBinaryOp<internal::scalar_zeta_op<Scalar>,
const Derived,
const OtherDerived>
155 zeta(
const OtherDerived& other)
const {
156 return binaryExpr(other.derived(), internal::scalar_zeta_op<Scalar>());
160 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
161 const TensorCwiseBinaryOp<internal::scalar_polygamma_op<Scalar>,
const Derived,
const OtherDerived>
162 polygamma(
const OtherDerived& other)
const {
163 return binaryExpr(other.derived(), internal::scalar_polygamma_op<Scalar>());
167 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_erf_op<Scalar>,
const Derived>
169 return unaryExpr(internal::scalar_erf_op<Scalar>());
173 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_erfc_op<Scalar>,
const Derived>
175 return unaryExpr(internal::scalar_erfc_op<Scalar>());
179 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_sigmoid_op<Scalar>,
const Derived>
181 return unaryExpr(internal::scalar_sigmoid_op<Scalar>());
185 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_exp_op<Scalar>,
const Derived>
187 return unaryExpr(internal::scalar_exp_op<Scalar>());
191 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log_op<Scalar>,
const Derived>
193 return unaryExpr(internal::scalar_log_op<Scalar>());
197 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log1p_op<Scalar>,
const Derived>
199 return unaryExpr(internal::scalar_log1p_op<Scalar>());
203 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_abs_op<Scalar>,
const Derived>
205 return unaryExpr(internal::scalar_abs_op<Scalar>());
209 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_conjugate_op<Scalar>,
const Derived>
211 return unaryExpr(internal::scalar_conjugate_op<Scalar>());
215 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_pow_op<Scalar,Scalar> >,
const Derived>
216 pow(Scalar exponent)
const {
217 return unaryExpr(internal::bind2nd_op<internal::scalar_pow_op<Scalar,Scalar> >(exponent));
221 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_real_op<Scalar>,
const Derived>
223 return unaryExpr(internal::scalar_real_op<Scalar>());
227 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_imag_op<Scalar>,
const Derived>
229 return unaryExpr(internal::scalar_imag_op<Scalar>());
233 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_sum_op<Scalar,Scalar> >,
const Derived>
234 operator+ (Scalar rhs)
const {
235 return unaryExpr(internal::bind2nd_op<internal::scalar_sum_op<Scalar,Scalar> >(rhs));
239 EIGEN_STRONG_INLINE
friend
240 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_sum_op<Scalar> >,
const Derived>
241 operator+ (Scalar lhs,
const Derived& rhs) {
242 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_sum_op<Scalar> >(lhs));
246 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_difference_op<Scalar,Scalar> >,
const Derived>
247 operator- (Scalar rhs)
const {
248 EIGEN_STATIC_ASSERT((NumTraits<Scalar>::IsSigned || internal::is_same<Scalar,
const std::complex<float> >::value), YOU_MADE_A_PROGRAMMING_MISTAKE);
249 return unaryExpr(internal::bind2nd_op<internal::scalar_difference_op<Scalar,Scalar> >(rhs));
253 EIGEN_STRONG_INLINE
friend
254 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_difference_op<Scalar> >,
const Derived>
255 operator- (Scalar lhs,
const Derived& rhs) {
256 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_difference_op<Scalar> >(lhs));
260 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_product_op<Scalar,Scalar> >,
const Derived>
262 return unaryExpr(internal::bind2nd_op<internal::scalar_product_op<Scalar,Scalar> >(rhs));
266 EIGEN_STRONG_INLINE
friend
267 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_product_op<Scalar> >,
const Derived>
268 operator* (Scalar lhs,
const Derived& rhs) {
269 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_product_op<Scalar> >(lhs));
273 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_quotient_op<Scalar,Scalar> >,
const Derived>
274 operator/ (Scalar rhs)
const {
275 return unaryExpr(internal::bind2nd_op<internal::scalar_quotient_op<Scalar,Scalar> >(rhs));
279 EIGEN_STRONG_INLINE
friend
280 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_quotient_op<Scalar> >,
const Derived>
281 operator/ (Scalar lhs,
const Derived& rhs) {
282 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_quotient_op<Scalar> >(lhs));
286 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_mod_op<Scalar>,
const Derived>
287 operator% (Scalar rhs)
const {
288 EIGEN_STATIC_ASSERT(NumTraits<Scalar>::IsInteger, YOU_MADE_A_PROGRAMMING_MISTAKE_TRY_MOD);
289 return unaryExpr(internal::scalar_mod_op<Scalar>(rhs));
293 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_max_op<Scalar>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
294 cwiseMax(Scalar threshold)
const {
295 return cwiseMax(constant(threshold));
299 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_min_op<Scalar>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
300 cwiseMin(Scalar threshold)
const {
301 return cwiseMin(constant(threshold));
304 template <
typename NewType> EIGEN_DEVICE_FUNC
305 EIGEN_STRONG_INLINE
const TensorConversionOp<NewType, const Derived>
307 return TensorConversionOp<NewType, const Derived>(derived());
311 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_round_op<Scalar>,
const Derived>
313 return unaryExpr(internal::scalar_round_op<Scalar>());
317 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_ceil_op<Scalar>,
const Derived>
319 return unaryExpr(internal::scalar_ceil_op<Scalar>());
323 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_floor_op<Scalar>,
const Derived>
325 return unaryExpr(internal::scalar_floor_op<Scalar>());
329 template <
typename CustomBinaryOp,
typename OtherDerived> EIGEN_DEVICE_FUNC
330 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>
331 binaryExpr(
const OtherDerived& other,
const CustomBinaryOp& func)
const {
332 return TensorCwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>(derived(), other, func);
336 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
337 const TensorCwiseBinaryOp<internal::scalar_sum_op<Scalar>,
const Derived,
const OtherDerived>
338 operator+(
const OtherDerived& other)
const {
339 return binaryExpr(other.derived(), internal::scalar_sum_op<Scalar>());
342 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
343 const TensorCwiseBinaryOp<internal::scalar_difference_op<Scalar>,
const Derived,
const OtherDerived>
344 operator-(
const OtherDerived& other)
const {
345 return binaryExpr(other.derived(), internal::scalar_difference_op<Scalar>());
348 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
349 const TensorCwiseBinaryOp<internal::scalar_product_op<Scalar>,
const Derived,
const OtherDerived>
350 operator*(
const OtherDerived& other)
const {
351 return binaryExpr(other.derived(), internal::scalar_product_op<Scalar>());
354 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
355 const TensorCwiseBinaryOp<internal::scalar_quotient_op<Scalar>,
const Derived,
const OtherDerived>
356 operator/(
const OtherDerived& other)
const {
357 return binaryExpr(other.derived(), internal::scalar_quotient_op<Scalar>());
360 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
361 const TensorCwiseBinaryOp<internal::scalar_max_op<Scalar>,
const Derived,
const OtherDerived>
362 cwiseMax(
const OtherDerived& other)
const {
363 return binaryExpr(other.derived(), internal::scalar_max_op<Scalar>());
366 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
367 const TensorCwiseBinaryOp<internal::scalar_min_op<Scalar>,
const Derived,
const OtherDerived>
368 cwiseMin(
const OtherDerived& other)
const {
369 return binaryExpr(other.derived(), internal::scalar_min_op<Scalar>());
372 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
373 const TensorCwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
374 operator&&(
const OtherDerived& other)
const {
375 return binaryExpr(other.derived(), internal::scalar_boolean_and_op());
378 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
379 const TensorCwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
380 operator||(
const OtherDerived& other)
const {
381 return binaryExpr(other.derived(), internal::scalar_boolean_or_op());
384 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
385 const TensorCwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>
386 operator^(
const OtherDerived& other)
const {
387 return binaryExpr(other.derived(), internal::scalar_boolean_xor_op());
391 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
392 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>,
const Derived,
const OtherDerived>
393 operator<(
const OtherDerived& other)
const {
394 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>());
396 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
397 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>,
const Derived,
const OtherDerived>
398 operator<=(
const OtherDerived& other)
const {
399 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>());
401 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
402 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>,
const Derived,
const OtherDerived>
403 operator>(
const OtherDerived& other)
const {
404 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>());
406 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
407 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>,
const Derived,
const OtherDerived>
408 operator>=(
const OtherDerived& other)
const {
409 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>());
412 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
413 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>,
const Derived,
const OtherDerived>
414 operator==(
const OtherDerived& other)
const {
415 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>());
418 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
419 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>,
const Derived,
const OtherDerived>
420 operator!=(
const OtherDerived& other)
const {
421 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>());
426 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
427 operator<(Scalar threshold)
const {
428 return operator<(constant(threshold));
431 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
432 operator<=(Scalar threshold)
const {
433 return operator<=(constant(threshold));
436 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
437 operator>(Scalar threshold)
const {
438 return operator>(constant(threshold));
441 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
442 operator>=(Scalar threshold)
const {
443 return operator>=(constant(threshold));
446 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
447 operator==(Scalar threshold)
const {
448 return operator==(constant(threshold));
451 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
452 operator!=(Scalar threshold)
const {
453 return operator!=(constant(threshold));
458 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isnan_op<Scalar>,
const Derived>
460 return unaryExpr(internal::scalar_isnan_op<Scalar>());
463 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isinf_op<Scalar>,
const Derived>
465 return unaryExpr(internal::scalar_isinf_op<Scalar>());
468 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isfinite_op<Scalar>,
const Derived>
470 return unaryExpr(internal::scalar_isfinite_op<Scalar>());
474 template<
typename ThenDerived,
typename ElseDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
475 const TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>
476 select(
const ThenDerived& thenTensor,
const ElseDerived& elseTensor)
const {
477 return TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>(derived(), thenTensor.derived(), elseTensor.derived());
481 typedef Eigen::IndexPair<Index> DimensionPair;
483 template<
typename OtherDerived,
typename Dimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
484 const TensorContractionOp<const Dimensions, const Derived, const OtherDerived>
485 contract(
const OtherDerived& other,
const Dimensions& dims)
const {
486 return TensorContractionOp<const Dimensions, const Derived, const OtherDerived>(derived(), other.derived(), dims);
490 template<
typename KernelDerived,
typename Dimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
491 const TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>
492 convolve(
const KernelDerived& kernel,
const Dimensions& dims)
const {
493 return TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>(derived(), kernel.derived(), dims);
497 template <
int FFTDataType,
int FFTDirection,
typename FFT> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
498 const TensorFFTOp<const FFT, const Derived, FFTDataType, FFTDirection>
499 fft(
const FFT& fft)
const {
500 return TensorFFTOp<const FFT, const Derived, FFTDataType, FFTDirection>(derived(), fft);
504 typedef TensorScanOp<internal::SumReducer<CoeffReturnType>,
const Derived> TensorScanSumOp;
505 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
506 const TensorScanSumOp
507 cumsum(
const Index& axis,
bool exclusive =
false)
const {
508 return TensorScanSumOp(derived(), axis, exclusive);
511 typedef TensorScanOp<internal::ProdReducer<CoeffReturnType>,
const Derived> TensorScanProdOp;
512 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
513 const TensorScanProdOp
514 cumprod(
const Index& axis,
bool exclusive =
false)
const {
515 return TensorScanProdOp(derived(), axis, exclusive);
518 template <
typename Reducer>
519 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
520 const TensorScanOp<Reducer, const Derived>
521 scan(
const Index& axis,
const Reducer& reducer,
bool exclusive =
false)
const {
522 return TensorScanOp<Reducer, const Derived>(derived(), axis, exclusive, reducer);
526 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
527 const TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const Dims,
const Derived>
528 sum(
const Dims& dims)
const {
529 return TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::SumReducer<CoeffReturnType>());
532 const TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
534 DimensionList<Index, NumDimensions> in_dims;
535 return TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::SumReducer<CoeffReturnType>());
538 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
539 const TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const Dims,
const Derived>
540 mean(
const Dims& dims)
const {
541 return TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::MeanReducer<CoeffReturnType>());
544 const TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
546 DimensionList<Index, NumDimensions> in_dims;
547 return TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MeanReducer<CoeffReturnType>());
550 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
551 const TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const Dims,
const Derived>
552 prod(
const Dims& dims)
const {
553 return TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::ProdReducer<CoeffReturnType>());
556 const TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
558 DimensionList<Index, NumDimensions> in_dims;
559 return TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::ProdReducer<CoeffReturnType>());
562 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
563 const TensorReductionOp<internal::MaxReducer<CoeffReturnType>,
const Dims,
const Derived>
564 maximum(
const Dims& dims)
const {
565 return TensorReductionOp<internal::MaxReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::MaxReducer<CoeffReturnType>());
568 const TensorReductionOp<internal::MaxReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
570 DimensionList<Index, NumDimensions> in_dims;
571 return TensorReductionOp<internal::MaxReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MaxReducer<CoeffReturnType>());
574 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
575 const TensorReductionOp<internal::MinReducer<CoeffReturnType>,
const Dims,
const Derived>
576 minimum(
const Dims& dims)
const {
577 return TensorReductionOp<internal::MinReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::MinReducer<CoeffReturnType>());
580 const TensorReductionOp<internal::MinReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
582 DimensionList<Index, NumDimensions> in_dims;
583 return TensorReductionOp<internal::MinReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MinReducer<CoeffReturnType>());
586 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
587 const TensorReductionOp<internal::AndReducer, const Dims, const TensorConversionOp<bool, const Derived> >
588 all(
const Dims& dims)
const {
589 return cast<bool>().reduce(dims, internal::AndReducer());
592 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
593 const TensorReductionOp<internal::AndReducer, const DimensionList<Index, NumDimensions>,
const TensorConversionOp<bool, const Derived> >
595 DimensionList<Index, NumDimensions> in_dims;
596 return cast<bool>().reduce(in_dims, internal::AndReducer());
599 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
600 const TensorReductionOp<internal::OrReducer, const Dims, const TensorConversionOp<bool, const Derived> >
601 any(
const Dims& dims)
const {
602 return cast<bool>().reduce(dims, internal::OrReducer());
605 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
606 const TensorReductionOp<internal::OrReducer, const DimensionList<Index, NumDimensions>,
const TensorConversionOp<bool, const Derived> >
608 DimensionList<Index, NumDimensions> in_dims;
609 return cast<bool>().reduce(in_dims, internal::OrReducer());
612 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
613 const TensorTupleReducerOp<
614 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
615 const array<Index, NumDimensions>,
const Derived>
617 array<Index, NumDimensions> in_dims;
618 for (
int d = 0; d < NumDimensions; ++d) in_dims[d] = d;
619 return TensorTupleReducerOp<
620 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
621 const array<Index, NumDimensions>,
622 const Derived>(derived(), internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >(), -1, in_dims);
625 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
626 const TensorTupleReducerOp<
627 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
628 const array<Index, NumDimensions>,
const Derived>
630 array<Index, NumDimensions> in_dims;
631 for (
int d = 0; d < NumDimensions; ++d) in_dims[d] = d;
632 return TensorTupleReducerOp<
633 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
634 const array<Index, NumDimensions>,
635 const Derived>(derived(), internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >(), -1, in_dims);
638 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
639 const TensorTupleReducerOp<
640 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
641 const array<Index, 1>,
const Derived>
642 argmax(
const int return_dim)
const {
643 array<Index, 1> in_dims;
644 in_dims[0] = return_dim;
645 return TensorTupleReducerOp<
646 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
647 const array<Index, 1>,
648 const Derived>(derived(), internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >(), return_dim, in_dims);
651 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
652 const TensorTupleReducerOp<
653 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
654 const array<Index, 1>,
const Derived>
655 argmin(
const int return_dim)
const {
656 array<Index, 1> in_dims;
657 in_dims[0] = return_dim;
658 return TensorTupleReducerOp<
659 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
660 const array<Index, 1>,
661 const Derived>(derived(), internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >(), return_dim, in_dims);
664 template <
typename Reducer,
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
665 const TensorReductionOp<Reducer, const Dims, const Derived>
666 reduce(
const Dims& dims,
const Reducer& reducer)
const {
667 return TensorReductionOp<Reducer, const Dims, const Derived>(derived(), dims, reducer);
670 template <
typename Broadcast> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
671 const TensorBroadcastingOp<const Broadcast, const Derived>
672 broadcast(
const Broadcast& broadcast)
const {
673 return TensorBroadcastingOp<const Broadcast, const Derived>(derived(), broadcast);
676 template <
typename Axis,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
677 const TensorConcatenationOp<Axis, const Derived, const OtherDerived>
678 concatenate(
const OtherDerived& other, Axis axis)
const {
679 return TensorConcatenationOp<Axis, const Derived, const OtherDerived>(derived(), other.derived(), axis);
682 template <
typename PatchDims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
683 const TensorPatchOp<const PatchDims, const Derived>
684 extract_patches(
const PatchDims& patch_dims)
const {
685 return TensorPatchOp<const PatchDims, const Derived>(derived(), patch_dims);
688 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
689 const TensorImagePatchOp<Dynamic, Dynamic, const Derived>
690 extract_image_patches(
const Index patch_rows = 1,
const Index patch_cols = 1,
691 const Index row_stride = 1,
const Index col_stride = 1,
692 const Index in_row_stride = 1,
const Index in_col_stride = 1,
693 const PaddingType padding_type = PADDING_SAME,
const Scalar padding_value = Scalar(0))
const {
694 return TensorImagePatchOp<Dynamic, Dynamic, const Derived>(derived(), patch_rows, patch_cols, row_stride, col_stride,
695 in_row_stride, in_col_stride, 1, 1, padding_type, padding_value);
698 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
699 const TensorImagePatchOp<Dynamic, Dynamic, const Derived>
700 extract_image_patches(
const Index patch_rows,
const Index patch_cols,
701 const Index row_stride,
const Index col_stride,
702 const Index in_row_stride,
const Index in_col_stride,
703 const Index row_inflate_stride,
const Index col_inflate_stride,
704 const Index padding_top,
const Index padding_bottom,
705 const Index padding_left,
const Index padding_right,
706 const Scalar padding_value)
const {
707 return TensorImagePatchOp<Dynamic, Dynamic, const Derived>(derived(), patch_rows, patch_cols, row_stride, col_stride,
708 in_row_stride, in_col_stride, row_inflate_stride, col_inflate_stride,
709 padding_top, padding_bottom, padding_left, padding_right, padding_value);
712 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
713 const TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>
714 extract_volume_patches(
const Index patch_planes,
const Index patch_rows,
const Index patch_cols,
715 const Index plane_stride = 1,
const Index row_stride = 1,
const Index col_stride = 1,
716 const PaddingType padding_type = PADDING_SAME,
const Scalar padding_value = Scalar(0))
const {
717 return TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>(derived(), patch_planes, patch_rows, patch_cols, plane_stride, row_stride, col_stride, 1, 1, 1, 1, 1, 1, padding_type, padding_value);
721 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
722 const TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>
723 extract_volume_patches(
const Index patch_planes,
const Index patch_rows,
const Index patch_cols,
724 const Index plane_stride,
const Index row_stride,
const Index col_stride,
725 const Index plane_inflate_stride,
const Index row_inflate_stride,
const Index col_inflate_stride,
726 const Index padding_top_z,
const Index padding_bottom_z,
727 const Index padding_top,
const Index padding_bottom,
728 const Index padding_left,
const Index padding_right,
const Scalar padding_value = Scalar(0))
const {
729 return TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>(derived(), patch_planes, patch_rows, patch_cols, plane_stride, row_stride, col_stride, 1, 1, 1, plane_inflate_stride, row_inflate_stride, col_inflate_stride, padding_top_z, padding_bottom_z, padding_top, padding_bottom, padding_left, padding_right, padding_value);
733 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
734 const TensorLayoutSwapOp<const Derived>
735 swap_layout()
const {
736 return TensorLayoutSwapOp<const Derived>(derived());
738 template <
typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
739 const TensorReshapingOp<const NewDimensions, const Derived>
740 reshape(
const NewDimensions& newDimensions)
const {
741 return TensorReshapingOp<const NewDimensions, const Derived>(derived(), newDimensions);
743 template <
typename StartIndices,
typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
744 const TensorSlicingOp<const StartIndices, const Sizes, const Derived>
745 slice(
const StartIndices& startIndices,
const Sizes& sizes)
const {
746 return TensorSlicingOp<const StartIndices, const Sizes, const Derived>(derived(), startIndices, sizes);
748 template <
typename StartIndices,
typename StopIndices,
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
749 const TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, const Derived>
750 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides& strides)
const {
751 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
752 const Derived>(derived(), startIndices, stopIndices, strides);
754 template <Index DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
755 const TensorChippingOp<DimId, const Derived>
756 chip(
const Index offset)
const {
757 return TensorChippingOp<DimId, const Derived>(derived(), offset, DimId);
759 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
760 const TensorChippingOp<Dynamic, const Derived>
761 chip(
const Index offset,
const Index dim)
const {
762 return TensorChippingOp<Dynamic, const Derived>(derived(), offset, dim);
764 template <
typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
765 const TensorReverseOp<const ReverseDimensions, const Derived>
766 reverse(
const ReverseDimensions& rev)
const {
767 return TensorReverseOp<const ReverseDimensions, const Derived>(derived(), rev);
769 template <
typename PaddingDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
770 const TensorPaddingOp<const PaddingDimensions, const Derived>
771 pad(
const PaddingDimensions& padding)
const {
772 return TensorPaddingOp<const PaddingDimensions, const Derived>(derived(), padding, internal::scalar_cast_op<int, Scalar>()(0));
774 template <
typename PaddingDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
775 const TensorPaddingOp<const PaddingDimensions, const Derived>
776 pad(
const PaddingDimensions& padding,
const Scalar padding_value)
const {
777 return TensorPaddingOp<const PaddingDimensions, const Derived>(derived(), padding, padding_value);
779 template <
typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
780 const TensorShufflingOp<const Shuffle, const Derived>
781 shuffle(
const Shuffle& shuffle)
const {
782 return TensorShufflingOp<const Shuffle, const Derived>(derived(), shuffle);
784 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
785 const TensorStridingOp<const Strides, const Derived>
786 stride(
const Strides& strides)
const {
787 return TensorStridingOp<const Strides, const Derived>(derived(), strides);
789 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
790 const TensorInflationOp<const Strides, const Derived>
791 inflate(
const Strides& strides)
const {
792 return TensorInflationOp<const Strides, const Derived>(derived(), strides);
796 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
797 const TensorIndexTupleOp<const Derived>
798 index_tuples()
const {
799 return TensorIndexTupleOp<const Derived>(derived());
803 template <
typename CustomUnaryFunc>
804 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
805 const TensorCustomUnaryOp<const CustomUnaryFunc, const Derived> customOp(
const CustomUnaryFunc& op)
const {
806 return TensorCustomUnaryOp<const CustomUnaryFunc, const Derived>(derived(), op);
808 template <
typename OtherDerived,
typename CustomBinaryFunc>
809 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
810 const TensorCustomBinaryOp<const CustomBinaryFunc, const Derived, const OtherDerived> customOp(
const OtherDerived& other,
const CustomBinaryFunc& op)
const {
811 return TensorCustomBinaryOp<const CustomBinaryFunc, const Derived, const OtherDerived>(derived(), other, op);
815 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
816 const TensorForcedEvalOp<const Derived> eval()
const {
817 return TensorForcedEvalOp<const Derived>(derived());
821 template <
typename Scalar,
int NumIndices,
int Options,
typename IndexType>
friend class Tensor;
822 template <
typename Scalar,
typename Dimensions,
int Option,
typename IndexTypes>
friend class TensorFixedSize;
823 template <
typename OtherDerived,
int AccessLevel>
friend class TensorBase;
825 EIGEN_STRONG_INLINE
const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
828 template<typename Derived, int AccessLevel = internal::accessors_level<Derived>::value>
829 class TensorBase :
public TensorBase<Derived, ReadOnlyAccessors> {
831 typedef internal::traits<Derived> DerivedTraits;
832 typedef typename DerivedTraits::Scalar Scalar;
833 typedef typename DerivedTraits::Index
Index;
834 typedef Scalar CoeffReturnType;
835 static const int NumDimensions = DerivedTraits::NumDimensions;
837 template <
typename Scalar,
int NumIndices,
int Options,
typename IndexType>
friend class Tensor;
838 template <
typename Scalar,
typename Dimensions,
int Option,
typename IndexTypes>
friend class TensorFixedSize;
839 template <
typename OtherDerived,
int OtherAccessLevel>
friend class TensorBase;
842 EIGEN_STRONG_INLINE Derived& setZero() {
843 return setConstant(Scalar(0));
846 EIGEN_STRONG_INLINE Derived& setConstant(
const Scalar& val) {
847 return derived() = this->constant(val);
850 EIGEN_STRONG_INLINE Derived& setRandom() {
851 return derived() = this->random();
853 template <
typename RandomGenerator> EIGEN_DEVICE_FUNC
854 EIGEN_STRONG_INLINE Derived& setRandom() {
855 return derived() = this->
template random<RandomGenerator>();
858 #if EIGEN_HAS_VARIADIC_TEMPLATES
860 EIGEN_STRONG_INLINE Derived& setValues(
861 const typename internal::Initializer<Derived, NumDimensions>::InitList& vals) {
862 TensorEvaluator<Derived, DefaultDevice> eval(derived(), DefaultDevice());
863 internal::initialize_tensor<Derived, NumDimensions>(eval, vals);
868 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
869 Derived& operator+=(
const OtherDerived& other) {
870 return derived() = derived() + other.derived();
872 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
873 Derived& operator-=(
const OtherDerived& other) {
874 return derived() = derived() - other.derived();
876 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
877 Derived& operator*=(
const OtherDerived& other) {
878 return derived() = derived() * other.derived();
880 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
881 Derived& operator/=(
const OtherDerived& other) {
882 return derived() = derived() / other.derived();
885 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
886 const TensorLayoutSwapOp<const Derived>
887 swap_layout()
const {
888 return TensorLayoutSwapOp<const Derived>(derived());
890 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
891 TensorLayoutSwapOp<Derived>
893 return TensorLayoutSwapOp<Derived>(derived());
896 template <
typename Axis,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
897 const TensorConcatenationOp<const Axis, const Derived, const OtherDerived>
898 concatenate(
const OtherDerived& other,
const Axis& axis)
const {
899 return TensorConcatenationOp<const Axis, const Derived, const OtherDerived>(derived(), other, axis);
901 template <
typename Axis,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
902 TensorConcatenationOp<const Axis, Derived, OtherDerived>
903 concatenate(
const OtherDerived& other,
const Axis& axis) {
904 return TensorConcatenationOp<const Axis, Derived, OtherDerived>(derived(), other, axis);
907 template <
typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
908 const TensorReshapingOp<const NewDimensions, const Derived>
909 reshape(
const NewDimensions& newDimensions)
const {
910 return TensorReshapingOp<const NewDimensions, const Derived>(derived(), newDimensions);
912 template <
typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
913 TensorReshapingOp<const NewDimensions, Derived>
914 reshape(
const NewDimensions& newDimensions) {
915 return TensorReshapingOp<const NewDimensions, Derived>(derived(), newDimensions);
918 template <
typename StartIndices,
typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
919 const TensorSlicingOp<const StartIndices, const Sizes, const Derived>
920 slice(
const StartIndices& startIndices,
const Sizes& sizes)
const {
921 return TensorSlicingOp<const StartIndices, const Sizes, const Derived>(derived(), startIndices, sizes);
923 template <
typename StartIndices,
typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
924 TensorSlicingOp<const StartIndices, const Sizes, Derived>
925 slice(
const StartIndices& startIndices,
const Sizes& sizes) {
926 return TensorSlicingOp<const StartIndices, const Sizes, Derived>(derived(), startIndices, sizes);
929 template <
typename StartIndices,
typename StopIndices,
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
930 const TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, const Derived>
931 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides& strides)
const {
932 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
933 const Derived>(derived(), startIndices, stopIndices, strides);
935 template <
typename StartIndices,
typename StopIndices,
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
936 TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, Derived>
937 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides& strides) {
938 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
939 Derived>(derived(), startIndices, stopIndices, strides);
942 template <DenseIndex DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
943 const TensorChippingOp<DimId, const Derived>
944 chip(
const Index offset)
const {
945 return TensorChippingOp<DimId, const Derived>(derived(), offset, DimId);
947 template <Index DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
948 TensorChippingOp<DimId, Derived>
949 chip(
const Index offset) {
950 return TensorChippingOp<DimId, Derived>(derived(), offset, DimId);
953 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
954 const TensorChippingOp<Dynamic, const Derived>
955 chip(
const Index offset,
const Index dim)
const {
956 return TensorChippingOp<Dynamic, const Derived>(derived(), offset, dim);
958 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
959 TensorChippingOp<Dynamic, Derived>
961 return TensorChippingOp<Dynamic, Derived>(derived(), offset, dim);
964 template <
typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
965 const TensorReverseOp<const ReverseDimensions, const Derived>
966 reverse(
const ReverseDimensions& rev)
const {
967 return TensorReverseOp<const ReverseDimensions, const Derived>(derived(), rev);
969 template <
typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
970 TensorReverseOp<const ReverseDimensions, Derived>
971 reverse(
const ReverseDimensions& rev) {
972 return TensorReverseOp<const ReverseDimensions, Derived>(derived(), rev);
975 template <
typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
976 const TensorShufflingOp<const Shuffle, const Derived>
977 shuffle(
const Shuffle& shuffle)
const {
978 return TensorShufflingOp<const Shuffle, const Derived>(derived(), shuffle);
980 template <
typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
981 TensorShufflingOp<const Shuffle, Derived>
982 shuffle(
const Shuffle& shuffle) {
983 return TensorShufflingOp<const Shuffle, Derived>(derived(), shuffle);
986 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
987 const TensorStridingOp<const Strides, const Derived>
988 stride(
const Strides& strides)
const {
989 return TensorStridingOp<const Strides, const Derived>(derived(), strides);
991 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
992 TensorStridingOp<const Strides, Derived>
993 stride(
const Strides& strides) {
994 return TensorStridingOp<const Strides, Derived>(derived(), strides);
998 template <
typename DeviceType>
999 TensorDevice<Derived, DeviceType> device(
const DeviceType& device) {
1000 return TensorDevice<Derived, DeviceType>(device, derived());
1005 EIGEN_STRONG_INLINE Derived& derived() {
return *
static_cast<Derived*
>(
this); }
1007 EIGEN_STRONG_INLINE
const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
Namespace containing all symbols from the Eigen library.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_tanh_op< typename Derived::Scalar >, const Derived > tanh(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_imag_op< typename Derived::Scalar >, const Derived > imag(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_erfc_op< typename Derived::Scalar >, const Derived > erfc(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_isinf_op< typename Derived::Scalar >, const Derived > isinf(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igammac_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igammac(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
Definition: SpecialFunctionsArrayAPI.h:48
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_rsqrt_op< typename Derived::Scalar >, const Derived > rsqrt(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igamma_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igamma(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
Definition: SpecialFunctionsArrayAPI.h:28
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_polygamma_op< typename DerivedX::Scalar >, const DerivedN, const DerivedX > polygamma(const Eigen::ArrayBase< DerivedN > &n, const Eigen::ArrayBase< DerivedX > &x)
Definition: SpecialFunctionsArrayAPI.h:70
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sign_op< typename Derived::Scalar >, const Derived > sign(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_isnan_op< typename Derived::Scalar >, const Derived > isnan(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_ceil_op< typename Derived::Scalar >, const Derived > ceil(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_isfinite_op< typename Derived::Scalar >, const Derived > isfinite(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_floor_op< typename Derived::Scalar >, const Derived > floor(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_lgamma_op< typename Derived::Scalar >, const Derived > lgamma(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_erf_op< typename Derived::Scalar >, const Derived > erf(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_log1p_op< typename Derived::Scalar >, const Derived > log1p(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_real_op< typename Derived::Scalar >, const Derived > real(const Eigen::ArrayBase< Derived > &x)
const Product< Inverse< PermutationType >, SparseDerived, AliasFreeProduct > operator*(const InverseImpl< PermutationType, PermutationStorage > &tperm, const SparseMatrixBase< SparseDerived > &matrix)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_round_op< typename Derived::Scalar >, const Derived > round(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_zeta_op< typename DerivedX::Scalar >, const DerivedX, const DerivedQ > zeta(const Eigen::ArrayBase< DerivedX > &x, const Eigen::ArrayBase< DerivedQ > &q)
Definition: SpecialFunctionsArrayAPI.h:114
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_cube_op< typename Derived::Scalar >, const Derived > cube(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_exp_op< typename Derived::Scalar >, const Derived > exp(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_log_op< typename Derived::Scalar >, const Derived > log(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_op< typename Derived::Scalar >, const Derived > inverse(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_square_op< typename Derived::Scalar >, const Derived > square(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_digamma_op< typename Derived::Scalar >, const Derived > digamma(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)