10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_BASE_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_BASE_H
27 #ifndef EIGEN_PARSED_BY_DOXYGEN
30 template<
typename Derived>
34 typedef internal::traits<Derived> DerivedTraits;
35 typedef typename DerivedTraits::Scalar Scalar;
36 typedef typename DerivedTraits::Index
Index;
37 typedef std::remove_const_t<Scalar> CoeffReturnType;
38 static constexpr
int NumDimensions = DerivedTraits::NumDimensions;
42 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<CustomNullaryOp, const Derived>
43 nullaryExpr(
const CustomNullaryOp& func)
const {
44 return TensorCwiseNullaryOp<CustomNullaryOp, const Derived>(derived(), func);
49 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived>
50 constant(
const Scalar& value)
const {
51 return nullaryExpr(internal::scalar_constant_op<Scalar>(value));
55 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<internal::UniformRandomGenerator<Scalar>,
const Derived>
57 return nullaryExpr(internal::UniformRandomGenerator<Scalar>());
60 EIGEN_STRONG_INLINE
const TensorCwiseNullaryOp<RandomGenerator, const Derived>
61 random(
const RandomGenerator& gen = RandomGenerator())
const {
62 return nullaryExpr(gen);
67 EIGEN_STRONG_INLINE
const TensorGeneratorOp<Generator, const Derived>
68 generate(
const Generator& generator)
const {
69 return TensorGeneratorOp<Generator, const Derived>(derived(), generator);
74 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<CustomUnaryOp, const Derived>
75 unaryExpr(
const CustomUnaryOp& func)
const {
76 return TensorCwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
81 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_opposite_op<Scalar>,
const Derived>
83 return unaryExpr(internal::scalar_opposite_op<Scalar>());
87 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_sqrt_op<Scalar>,
const Derived>
89 return unaryExpr(internal::scalar_sqrt_op<Scalar>());
93 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_sign_op<Scalar>,
const Derived>
95 return unaryExpr(internal::scalar_sign_op<Scalar>());
99 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_rsqrt_op<Scalar>,
const Derived>
101 return unaryExpr(internal::scalar_rsqrt_op<Scalar>());
105 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_square_op<Scalar>,
const Derived>
107 return unaryExpr(internal::scalar_square_op<Scalar>());
111 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_cube_op<Scalar>,
const Derived>
113 return unaryExpr(internal::scalar_cube_op<Scalar>());
117 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_inverse_op<Scalar>,
const Derived>
119 return unaryExpr(internal::scalar_inverse_op<Scalar>());
123 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_tanh_op<Scalar>,
const Derived>
125 return unaryExpr(internal::scalar_tanh_op<Scalar>());
129 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_lgamma_op<Scalar>,
const Derived>
131 return unaryExpr(internal::scalar_lgamma_op<Scalar>());
135 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_digamma_op<Scalar>,
const Derived>
137 return unaryExpr(internal::scalar_digamma_op<Scalar>());
141 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i0_op<Scalar>,
const Derived>
143 return unaryExpr(internal::scalar_bessel_i0_op<Scalar>());
147 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i0e_op<Scalar>,
const Derived>
149 return unaryExpr(internal::scalar_bessel_i0e_op<Scalar>());
153 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i1_op<Scalar>,
const Derived>
155 return unaryExpr(internal::scalar_bessel_i1_op<Scalar>());
159 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i1e_op<Scalar>,
const Derived>
161 return unaryExpr(internal::scalar_bessel_i1e_op<Scalar>());
165 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_j0_op<Scalar>,
const Derived>
167 return unaryExpr(internal::scalar_bessel_j0_op<Scalar>());
171 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_y0_op<Scalar>,
const Derived>
173 return unaryExpr(internal::scalar_bessel_y0_op<Scalar>());
177 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_j1_op<Scalar>,
const Derived>
179 return unaryExpr(internal::scalar_bessel_j1_op<Scalar>());
183 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_y1_op<Scalar>,
const Derived>
185 return unaryExpr(internal::scalar_bessel_y1_op<Scalar>());
189 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k0_op<Scalar>,
const Derived>
191 return unaryExpr(internal::scalar_bessel_k0_op<Scalar>());
195 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k0e_op<Scalar>,
const Derived>
197 return unaryExpr(internal::scalar_bessel_k0e_op<Scalar>());
201 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k1_op<Scalar>,
const Derived>
203 return unaryExpr(internal::scalar_bessel_k1_op<Scalar>());
207 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k1e_op<Scalar>,
const Derived>
209 return unaryExpr(internal::scalar_bessel_k1e_op<Scalar>());
214 const TensorCwiseBinaryOp<internal::scalar_igamma_op<Scalar>,
const Derived,
const OtherDerived>
215 igamma(
const OtherDerived& other)
const {
216 return binaryExpr(other.derived(), internal::scalar_igamma_op<Scalar>());
221 const TensorCwiseBinaryOp<internal::scalar_igamma_der_a_op<Scalar>,
const Derived,
const OtherDerived>
223 return binaryExpr(other.derived(), internal::scalar_igamma_der_a_op<Scalar>());
228 const TensorCwiseBinaryOp<internal::scalar_gamma_sample_der_alpha_op<Scalar>,
const Derived,
const OtherDerived>
230 return binaryExpr(other.derived(), internal::scalar_gamma_sample_der_alpha_op<Scalar>());
235 const TensorCwiseBinaryOp<internal::scalar_igammac_op<Scalar>,
const Derived,
const OtherDerived>
236 igammac(
const OtherDerived& other)
const {
237 return binaryExpr(other.derived(), internal::scalar_igammac_op<Scalar>());
242 const TensorCwiseBinaryOp<internal::scalar_zeta_op<Scalar>,
const Derived,
const OtherDerived>
243 zeta(
const OtherDerived& other)
const {
244 return binaryExpr(other.derived(), internal::scalar_zeta_op<Scalar>());
249 const TensorCwiseBinaryOp<internal::scalar_polygamma_op<Scalar>,
const Derived,
const OtherDerived>
250 polygamma(
const OtherDerived& other)
const {
251 return binaryExpr(other.derived(), internal::scalar_polygamma_op<Scalar>());
255 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_erf_op<Scalar>,
const Derived>
257 return unaryExpr(internal::scalar_erf_op<Scalar>());
261 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_erfc_op<Scalar>,
const Derived>
263 return unaryExpr(internal::scalar_erfc_op<Scalar>());
267 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_ndtri_op<Scalar>,
const Derived>
269 return unaryExpr(internal::scalar_ndtri_op<Scalar>());
273 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_logistic_op<Scalar>,
const Derived>
275 return unaryExpr(internal::scalar_logistic_op<Scalar>());
279 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_exp_op<Scalar>,
const Derived>
281 return unaryExpr(internal::scalar_exp_op<Scalar>());
285 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_expm1_op<Scalar>,
const Derived>
287 return unaryExpr(internal::scalar_expm1_op<Scalar>());
291 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log_op<Scalar>,
const Derived>
293 return unaryExpr(internal::scalar_log_op<Scalar>());
297 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log1p_op<Scalar>,
const Derived>
299 return unaryExpr(internal::scalar_log1p_op<Scalar>());
303 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log2_op<Scalar>,
const Derived>
305 return unaryExpr(internal::scalar_log2_op<Scalar>());
309 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_abs_op<Scalar>,
const Derived>
311 return unaryExpr(internal::scalar_abs_op<Scalar>());
315 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_arg_op<Scalar>,
const Derived>
317 return unaryExpr(internal::scalar_arg_op<Scalar>());
321 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_clamp_op<Scalar>,
const Derived>
322 clip(Scalar
min, Scalar
max)
const {
327 EIGEN_STRONG_INLINE
const std::conditional_t<NumTraits<CoeffReturnType>::IsComplex,
328 TensorCwiseUnaryOp<internal::scalar_conjugate_op<Scalar>,
const Derived>,
334 template<
typename ScalarExponent>
335 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const std::enable_if_t<internal::is_arithmetic<typename NumTraits<ScalarExponent>::Real>::value,
336 TensorCwiseUnaryOp<internal::scalar_unary_pow_op<Scalar, ScalarExponent>,
const Derived>>
337 pow(ScalarExponent exponent)
const
339 return unaryExpr(internal::scalar_unary_pow_op<Scalar, ScalarExponent>(exponent));
343 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_real_op<Scalar>,
const Derived>
345 return unaryExpr(internal::scalar_real_op<Scalar>());
349 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_imag_op<Scalar>,
const Derived>
351 return unaryExpr(internal::scalar_imag_op<Scalar>());
355 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_sum_op<Scalar,Scalar> >,
const Derived>
357 return unaryExpr(internal::bind2nd_op<internal::scalar_sum_op<Scalar,Scalar> >(rhs));
361 EIGEN_STRONG_INLINE
friend
362 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_sum_op<Scalar> >,
const Derived>
363 operator+ (Scalar lhs,
const Derived& rhs) {
364 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_sum_op<Scalar> >(lhs));
368 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_difference_op<Scalar,Scalar> >,
const Derived>
371 return unaryExpr(internal::bind2nd_op<internal::scalar_difference_op<Scalar,Scalar> >(rhs));
375 EIGEN_STRONG_INLINE
friend
376 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_difference_op<Scalar> >,
const Derived>
377 operator- (Scalar lhs,
const Derived& rhs) {
378 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_difference_op<Scalar> >(lhs));
382 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_product_op<Scalar,Scalar> >,
const Derived>
384 return unaryExpr(internal::bind2nd_op<internal::scalar_product_op<Scalar,Scalar> >(rhs));
388 EIGEN_STRONG_INLINE
friend
389 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_product_op<Scalar> >,
const Derived>
390 operator* (Scalar lhs,
const Derived& rhs) {
391 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_product_op<Scalar> >(lhs));
395 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_quotient_op<Scalar,Scalar> >,
const Derived>
397 return unaryExpr(internal::bind2nd_op<internal::scalar_quotient_op<Scalar,Scalar> >(rhs));
401 EIGEN_STRONG_INLINE
friend
402 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_quotient_op<Scalar> >,
const Derived>
403 operator/ (Scalar lhs,
const Derived& rhs) {
404 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_quotient_op<Scalar> >(lhs));
408 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_mod_op<Scalar>,
const Derived>
409 operator% (Scalar rhs)
const {
411 return unaryExpr(internal::scalar_mod_op<Scalar>(rhs));
414 template <
int NanPropagation=PropagateFast>
416 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar,NanPropagation>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
418 return cwiseMax<NanPropagation>(constant(threshold));
421 template <
int NanPropagation=PropagateFast>
423 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar,NanPropagation>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
425 return cwiseMin<NanPropagation>(constant(threshold));
428 template<
typename NewType>
430 EIGEN_STRONG_INLINE
const std::conditional_t<internal::is_same<NewType, CoeffReturnType>::value,
432 TensorConversionOp<NewType, const Derived> >
434 return choose(Cond<internal::is_same<NewType, CoeffReturnType>::value>(), derived(), TensorConversionOp<NewType, const Derived>(derived()));
438 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_round_op<Scalar>,
const Derived>
440 return unaryExpr(internal::scalar_round_op<Scalar>());
444 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_rint_op<Scalar>,
const Derived>
446 return unaryExpr(internal::scalar_rint_op<Scalar>());
450 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_ceil_op<Scalar>,
const Derived>
452 return unaryExpr(internal::scalar_ceil_op<Scalar>());
456 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_floor_op<Scalar>,
const Derived>
458 return unaryExpr(internal::scalar_floor_op<Scalar>());
463 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>
464 binaryExpr(
const OtherDerived& other,
const CustomBinaryOp& func)
const {
465 return TensorCwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>(derived(), other, func);
470 const TensorCwiseBinaryOp<internal::scalar_sum_op<Scalar>,
const Derived,
const OtherDerived>
471 operator+(
const OtherDerived& other)
const {
472 return binaryExpr(other.derived(), internal::scalar_sum_op<Scalar>());
476 const TensorCwiseBinaryOp<internal::scalar_difference_op<Scalar>,
const Derived,
const OtherDerived>
477 operator-(
const OtherDerived& other)
const {
478 return binaryExpr(other.derived(), internal::scalar_difference_op<Scalar>());
482 const TensorCwiseBinaryOp<internal::scalar_product_op<Scalar>,
const Derived,
const OtherDerived>
483 operator*(
const OtherDerived& other)
const {
484 return binaryExpr(other.derived(), internal::scalar_product_op<Scalar>());
488 const TensorCwiseBinaryOp<internal::scalar_quotient_op<Scalar>,
const Derived,
const OtherDerived>
489 operator/(
const OtherDerived& other)
const {
490 return binaryExpr(other.derived(), internal::scalar_quotient_op<Scalar>());
493 template<
int NaNPropagation=PropagateFast,
typename OtherDerived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
494 const TensorCwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar, NaNPropagation>,
const Derived,
const OtherDerived>
495 cwiseMax(
const OtherDerived& other)
const {
496 return binaryExpr(other.derived(), internal::scalar_max_op<Scalar,Scalar, NaNPropagation>());
499 template<
int NaNPropagation=PropagateFast,
typename OtherDerived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
500 const TensorCwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar, NaNPropagation>,
const Derived,
const OtherDerived>
501 cwiseMin(
const OtherDerived& other)
const {
502 return binaryExpr(other.derived(), internal::scalar_min_op<Scalar,Scalar, NaNPropagation>());
507 const TensorCwiseBinaryOp<internal::scalar_boolean_and_op<Scalar>,
const Derived,
const OtherDerived>
509 return binaryExpr(other.derived(), internal::scalar_boolean_and_op<Scalar>());
513 const TensorCwiseBinaryOp<internal::scalar_boolean_or_op<Scalar>,
const Derived,
const OtherDerived>
515 return binaryExpr(other.derived(), internal::scalar_boolean_or_op<Scalar>());
519 const TensorCwiseBinaryOp<internal::scalar_bitwise_and_op<Scalar>,
const Derived,
const OtherDerived>
520 operator&(
const OtherDerived& other)
const {
521 return binaryExpr(other.derived(), internal::scalar_bitwise_and_op<Scalar>());
525 const TensorCwiseBinaryOp<internal::scalar_bitwise_or_op<Scalar>,
const Derived,
const OtherDerived>
526 operator|(
const OtherDerived& other)
const {
527 return binaryExpr(other.derived(), internal::scalar_bitwise_or_op<Scalar>());
531 const TensorCwiseBinaryOp<internal::scalar_bitwise_xor_op<Scalar>,
const Derived,
const OtherDerived>
532 operator^(
const OtherDerived& other)
const {
533 return binaryExpr(other.derived(), internal::scalar_bitwise_xor_op<Scalar>());
537 const TensorCwiseUnaryOp<internal::scalar_boolean_not_op<Scalar>,
const Derived>
539 return unaryExpr(internal::scalar_boolean_not_op<Scalar>());
543 const TensorCwiseUnaryOp<internal::scalar_bitwise_not_op<Scalar>,
const Derived>
545 return unaryExpr(internal::scalar_bitwise_not_op<Scalar>());
550 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>,
const Derived,
const OtherDerived>
551 operator<(
const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
const {
552 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>());
555 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>,
const Derived,
const OtherDerived>
556 operator<=(
const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
const {
557 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>());
560 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>,
const Derived,
const OtherDerived>
561 operator>(
const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
const {
562 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>());
565 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>,
const Derived,
const OtherDerived>
566 operator>=(
const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
const {
567 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>());
571 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>,
const Derived,
const OtherDerived>
572 operator==(
const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
const {
573 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>());
577 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>,
const Derived,
const OtherDerived>
578 operator!=(
const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
const {
579 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>());
584 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> >
589 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> >
594 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> >
599 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> >
604 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> >
609 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> >
616 EIGEN_STRONG_INLINE
const TensorConversionOp<bool, const TensorCwiseUnaryOp<internal::scalar_isnan_op<Scalar, true>,
const Derived>>
618 return unaryExpr(internal::scalar_isnan_op<Scalar, true>()).template cast<bool>();
622 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isinf_op<Scalar>,
const Derived>
624 return unaryExpr(internal::scalar_isinf_op<Scalar>());
627 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isfinite_op<Scalar>,
const Derived>
629 return unaryExpr(internal::scalar_isfinite_op<Scalar>());
633 template<
typename ThenDerived,
typename ElseDerived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
634 const TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>
635 select(
const ThenDerived& thenTensor,
const ElseDerived& elseTensor)
const {
636 return TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>(derived(), thenTensor.derived(), elseTensor.derived());
642 template<
typename OtherDerived,
typename Dimensions>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
643 const TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const NoOpOutputKernel>
644 contract(
const OtherDerived& other,
const Dimensions& dims)
const {
645 return TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const NoOpOutputKernel>(derived(), other.derived(), dims);
648 template<
typename OtherDerived,
typename Dimensions,
typename OutputKernel>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
649 const TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const OutputKernel>
650 contract(
const OtherDerived& other,
const Dimensions& dims,
const OutputKernel& output_kernel)
const {
651 return TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const OutputKernel>(derived(), other.derived(), dims, output_kernel);
655 template<
typename KernelDerived,
typename Dimensions>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
656 const TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>
657 convolve(
const KernelDerived& kernel,
const Dimensions& dims)
const {
658 return TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>(derived(), kernel.derived(), dims);
662 template <
int FFTDataType,
int FFTDirection,
typename FFT>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
663 const TensorFFTOp<const FFT, const Derived, FFTDataType, FFTDirection>
664 fft(
const FFT& dims)
const {
665 return TensorFFTOp<const FFT, const Derived, FFTDataType, FFTDirection>(derived(), dims);
669 typedef TensorScanOp<internal::SumReducer<CoeffReturnType>,
const Derived> TensorScanSumOp;
671 const TensorScanSumOp
672 cumsum(
const Index& axis,
bool exclusive =
false)
const {
673 return TensorScanSumOp(derived(), axis, exclusive);
676 typedef TensorScanOp<internal::ProdReducer<CoeffReturnType>,
const Derived> TensorScanProdOp;
678 const TensorScanProdOp
679 cumprod(
const Index& axis,
bool exclusive =
false)
const {
680 return TensorScanProdOp(derived(), axis, exclusive);
683 template <
typename Reducer>
685 const TensorScanOp<Reducer, const Derived>
686 scan(
const Index& axis,
const Reducer& reducer,
bool exclusive =
false)
const {
687 return TensorScanOp<Reducer, const Derived>(derived(), axis, exclusive, reducer);
692 const TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const Dims,
const Derived>
693 sum(
const Dims& dims)
const {
694 return TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::SumReducer<CoeffReturnType>());
697 const TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
699 DimensionList<Index, NumDimensions> in_dims;
700 return TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::SumReducer<CoeffReturnType>());
704 const TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const Dims,
const Derived>
705 mean(
const Dims& dims)
const {
706 return TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::MeanReducer<CoeffReturnType>());
709 const TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
711 DimensionList<Index, NumDimensions> in_dims;
712 return TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MeanReducer<CoeffReturnType>());
716 const TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const Dims,
const Derived>
717 prod(
const Dims& dims)
const {
718 return TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::ProdReducer<CoeffReturnType>());
721 const TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
723 DimensionList<Index, NumDimensions> in_dims;
724 return TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::ProdReducer<CoeffReturnType>());
727 template <
typename Dims,
int NanPropagation=PropagateFast>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
728 const TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>
729 maximum(
const Dims& dims)
const {
730 return TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>(derived(), dims, internal::MaxReducer<CoeffReturnType,NanPropagation>());
733 template <
int NanPropagation=PropagateFast>
734 const TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>
736 DimensionList<Index, NumDimensions> in_dims;
737 return TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MaxReducer<CoeffReturnType,NanPropagation>());
740 template <
typename Dims,
int NanPropagation=PropagateFast>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
741 const TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>
742 minimum(
const Dims& dims)
const {
743 return TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>(derived(), dims, internal::MinReducer<CoeffReturnType,NanPropagation>());
746 template <
int NanPropagation=PropagateFast>
747 const TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>
749 DimensionList<Index, NumDimensions> in_dims;
750 return TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MinReducer<CoeffReturnType,NanPropagation>());
754 const TensorReductionOp<internal::AndReducer, const Dims, const std::conditional_t<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> > >
755 all(
const Dims& dims)
const {
756 return cast<bool>().reduce(dims, internal::AndReducer());
760 const TensorReductionOp<internal::AndReducer, const DimensionList<Index, NumDimensions>,
const std::conditional_t<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> > >
762 DimensionList<Index, NumDimensions> in_dims;
763 return cast<bool>().reduce(in_dims, internal::AndReducer());
767 const TensorReductionOp<internal::OrReducer, const Dims, const std::conditional_t<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> > >
768 any(
const Dims& dims)
const {
769 return cast<bool>().reduce(dims, internal::OrReducer());
773 const TensorReductionOp<internal::OrReducer, const DimensionList<Index, NumDimensions>,
const std::conditional_t<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> > >
775 DimensionList<Index, NumDimensions> in_dims;
776 return cast<bool>().reduce(in_dims, internal::OrReducer());
780 const TensorPairReducerOp<
781 internal::ArgMaxPairReducer<Pair<Index, CoeffReturnType> >,
785 for (
Index d = 0; d < NumDimensions; ++d) in_dims[d] = d;
786 return TensorPairReducerOp<
787 internal::ArgMaxPairReducer<Pair<Index, CoeffReturnType> >,
789 const Derived>(derived(), internal::ArgMaxPairReducer<Pair<Index, CoeffReturnType> >(), -1, in_dims);
793 const TensorPairReducerOp<
794 internal::ArgMinPairReducer<Pair<Index, CoeffReturnType> >,
798 for (
Index d = 0; d < NumDimensions; ++d) in_dims[d] = d;
799 return TensorPairReducerOp<
800 internal::ArgMinPairReducer<Pair<Index, CoeffReturnType> >,
802 const Derived>(derived(), internal::ArgMinPairReducer<Pair<Index, CoeffReturnType> >(), -1, in_dims);
806 const TensorPairReducerOp<
807 internal::ArgMaxPairReducer<Pair<Index, CoeffReturnType> >,
809 argmax(
const Index return_dim)
const {
811 in_dims[0] = return_dim;
812 return TensorPairReducerOp<
813 internal::ArgMaxPairReducer<Pair<Index, CoeffReturnType> >,
815 const Derived>(derived(), internal::ArgMaxPairReducer<Pair<Index, CoeffReturnType> >(), return_dim, in_dims);
819 const TensorPairReducerOp<
820 internal::ArgMinPairReducer<Pair<Index, CoeffReturnType> >,
822 argmin(
const Index return_dim)
const {
824 in_dims[0] = return_dim;
825 return TensorPairReducerOp<
826 internal::ArgMinPairReducer<Pair<Index, CoeffReturnType> >,
828 const Derived>(derived(), internal::ArgMinPairReducer<Pair<Index, CoeffReturnType> >(), return_dim, in_dims);
832 const TensorReductionOp<Reducer, const Dims, const Derived>
833 reduce(
const Dims& dims,
const Reducer& reducer)
const {
834 return TensorReductionOp<Reducer, const Dims, const Derived>(derived(), dims, reducer);
838 const TensorTraceOp<const Dims, const Derived>
839 trace(
const Dims& dims)
const {
840 return TensorTraceOp<const Dims, const Derived>(derived(), dims);
843 const TensorTraceOp<const DimensionList<Index, NumDimensions>,
const Derived>
845 DimensionList<Index, NumDimensions> in_dims;
846 return TensorTraceOp<const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims);
850 const TensorBroadcastingOp<const Broadcast, const Derived>
851 broadcast(
const Broadcast& bcast)
const {
852 return TensorBroadcastingOp<const Broadcast, const Derived>(derived(), bcast);
855 template <
typename Axis,
typename OtherDerived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
856 const TensorConcatenationOp<Axis, const Derived, const OtherDerived>
857 concatenate(
const OtherDerived& other, Axis axis)
const {
858 return TensorConcatenationOp<Axis, const Derived, const OtherDerived>(derived(), other.derived(), axis);
862 const TensorPatchOp<const PatchDims, const Derived>
863 extract_patches(
const PatchDims& patch_dims)
const {
864 return TensorPatchOp<const PatchDims, const Derived>(derived(), patch_dims);
868 const TensorImagePatchOp<Dynamic, Dynamic, const Derived>
869 extract_image_patches(
const Index patch_rows = 1,
const Index patch_cols = 1,
870 const Index row_stride = 1,
const Index col_stride = 1,
871 const Index in_row_stride = 1,
const Index in_col_stride = 1,
873 return TensorImagePatchOp<Dynamic, Dynamic, const Derived>(derived(), patch_rows, patch_cols, row_stride, col_stride,
874 in_row_stride, in_col_stride, 1, 1, padding_type, padding_value);
878 const TensorImagePatchOp<Dynamic, Dynamic, const Derived>
879 extract_image_patches(
const Index patch_rows,
const Index patch_cols,
880 const Index row_stride,
const Index col_stride,
881 const Index in_row_stride,
const Index in_col_stride,
882 const Index row_inflate_stride,
const Index col_inflate_stride,
883 const Index padding_top,
const Index padding_bottom,
884 const Index padding_left,
const Index padding_right,
885 const Scalar padding_value)
const {
886 return TensorImagePatchOp<Dynamic, Dynamic, const Derived>(derived(), patch_rows, patch_cols, row_stride, col_stride,
887 in_row_stride, in_col_stride, row_inflate_stride, col_inflate_stride,
888 padding_top, padding_bottom, padding_left, padding_right, padding_value);
892 const TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>
893 extract_volume_patches(
const Index patch_planes,
const Index patch_rows,
const Index patch_cols,
894 const Index plane_stride = 1,
const Index row_stride = 1,
const Index col_stride = 1,
896 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);
901 const TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>
902 extract_volume_patches(
const Index patch_planes,
const Index patch_rows,
const Index patch_cols,
903 const Index plane_stride,
const Index row_stride,
const Index col_stride,
904 const Index plane_inflate_stride,
const Index row_inflate_stride,
const Index col_inflate_stride,
905 const Index padding_top_z,
const Index padding_bottom_z,
906 const Index padding_top,
const Index padding_bottom,
907 const Index padding_left,
const Index padding_right,
const Scalar padding_value = Scalar(0))
const {
908 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);
913 const TensorLayoutSwapOp<const Derived>
914 swap_layout()
const {
915 return TensorLayoutSwapOp<const Derived>(derived());
918 const TensorReshapingOp<const NewDimensions, const Derived>
919 reshape(
const NewDimensions& newDimensions)
const {
920 return TensorReshapingOp<const NewDimensions, const Derived>(derived(), newDimensions);
922 template <
typename StartIndices,
typename Sizes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
923 const TensorSlicingOp<const StartIndices, const Sizes, const Derived>
924 slice(
const StartIndices& startIndices,
const Sizes& sizes)
const {
925 return TensorSlicingOp<const StartIndices, const Sizes, const Derived>(derived(), startIndices, sizes);
927 template <
typename StartIndices,
typename StopIndices,
typename Str
ides>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
928 const TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, const Derived>
929 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides&
strides)
const {
930 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
931 const Derived>(derived(), startIndices, stopIndices,
strides);
934 const TensorChippingOp<DimId, const Derived>
935 chip(
const Index offset)
const {
936 return TensorChippingOp<DimId, const Derived>(derived(), offset, DimId);
939 const TensorChippingOp<Dynamic, const Derived>
940 chip(
const Index offset,
const Index dim)
const {
941 return TensorChippingOp<Dynamic, const Derived>(derived(), offset, dim);
944 const TensorReverseOp<const ReverseDimensions, const Derived>
945 reverse(
const ReverseDimensions& rev)
const {
946 return TensorReverseOp<const ReverseDimensions, const Derived>(derived(), rev);
949 const TensorPaddingOp<const PaddingDimensions, const Derived>
950 pad(
const PaddingDimensions& padding)
const {
951 return TensorPaddingOp<const PaddingDimensions, const Derived>(derived(), padding, internal::scalar_cast_op<int, Scalar>()(0));
954 const TensorPaddingOp<const PaddingDimensions, const Derived>
955 pad(
const PaddingDimensions& padding,
const Scalar padding_value)
const {
956 return TensorPaddingOp<const PaddingDimensions, const Derived>(derived(), padding, padding_value);
959 const TensorShufflingOp<const Shuffle, const Derived>
960 shuffle(
const Shuffle& shfl)
const {
961 return TensorShufflingOp<const Shuffle, const Derived>(derived(), shfl);
964 const TensorStridingOp<const Strides, const Derived>
965 stride(
const Strides&
strides)
const {
966 return TensorStridingOp<const Strides, const Derived>(derived(),
strides);
969 const TensorInflationOp<const Strides, const Derived>
970 inflate(
const Strides&
strides)
const {
971 return TensorInflationOp<const Strides, const Derived>(derived(),
strides);
976 const TensorIndexPairOp<const Derived>
977 index_pairs()
const {
978 return TensorIndexPairOp<const Derived>(derived());
982 template <
typename CustomUnaryFunc>
984 const TensorCustomUnaryOp<const CustomUnaryFunc, const Derived> customOp(
const CustomUnaryFunc& op)
const {
985 return TensorCustomUnaryOp<const CustomUnaryFunc, const Derived>(derived(), op);
987 template <
typename OtherDerived,
typename CustomBinaryFunc>
989 const TensorCustomBinaryOp<const CustomBinaryFunc, const Derived, const OtherDerived> customOp(
const OtherDerived& other,
const CustomBinaryFunc& op)
const {
990 return TensorCustomBinaryOp<const CustomBinaryFunc, const Derived, const OtherDerived>(derived(), other, op);
995 const TensorForcedEvalOp<const Derived> eval()
const {
996 return TensorForcedEvalOp<const Derived>(derived());
1000 inline const TensorWithFormat<Derived,DerivedTraits::Layout,DerivedTraits::NumDimensions> format(
const TensorIOFormat& fmt)
const {
1001 return TensorWithFormat<Derived,DerivedTraits::Layout,DerivedTraits::NumDimensions>(derived(), fmt);
1004 #ifdef EIGEN_READONLY_TENSORBASE_PLUGIN
1005 #include EIGEN_READONLY_TENSORBASE_PLUGIN
1009 template <
typename Scalar,
int NumIndices,
int Options,
typename IndexType>
friend class Tensor;
1010 template <
typename Scalar,
typename Dimensions,
int Option,
typename IndexTypes>
friend class TensorFixedSize;
1012 template <
typename OtherDerived,
int AccessLevel>
friend class Eigen::TensorBase;
1014 EIGEN_STRONG_INLINE
const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
1017 template<typename Derived, int AccessLevel = internal::accessors_level<Derived>::value>
1018 class TensorBase :
public TensorBase<Derived, ReadOnlyAccessors> {
1020 typedef TensorBase<Derived, ReadOnlyAccessors> Base;
1021 typedef internal::traits<Derived> DerivedTraits;
1022 typedef typename DerivedTraits::Scalar Scalar;
1023 typedef typename DerivedTraits::Index
Index;
1024 typedef Scalar CoeffReturnType;
1025 static constexpr
int NumDimensions = DerivedTraits::NumDimensions;
1027 template <
typename Scalar,
int NumIndices,
int Options,
typename IndexType>
friend class Tensor;
1028 template <
typename Scalar,
typename Dimensions,
int Option,
typename IndexTypes>
friend class TensorFixedSize;
1030 template <
typename OtherDerived,
int OtherAccessLevel>
friend class Eigen::TensorBase;
1033 EIGEN_STRONG_INLINE Derived&
setZero() {
1037 EIGEN_STRONG_INLINE Derived&
setConstant(
const Scalar& val) {
1038 return derived() = this->constant(val);
1041 EIGEN_STRONG_INLINE Derived&
setRandom() {
1042 return derived() = this->random();
1045 EIGEN_STRONG_INLINE Derived&
setRandom() {
1046 return derived() = this->
template random<RandomGenerator>();
1050 EIGEN_STRONG_INLINE Derived& setValues(
1051 const typename internal::Initializer<Derived, NumDimensions>::InitList& vals) {
1052 TensorEvaluator<Derived, DefaultDevice> eval(derived(), DefaultDevice());
1053 internal::initialize_tensor<Derived, NumDimensions>(eval, vals);
1058 Derived&
operator+=(
const OtherDerived& other) {
1059 return derived() = derived() + other.derived();
1062 Derived&
operator-=(
const OtherDerived& other) {
1063 return derived() = derived() - other.derived();
1066 Derived&
operator*=(
const OtherDerived& other) {
1067 return derived() = derived() * other.derived();
1070 Derived&
operator/=(
const OtherDerived& other) {
1071 return derived() = derived() / other.derived();
1075 const TensorLayoutSwapOp<const Derived>
1076 swap_layout()
const {
1077 return TensorLayoutSwapOp<const Derived>(derived());
1080 TensorLayoutSwapOp<Derived>
1082 return TensorLayoutSwapOp<Derived>(derived());
1085 template <
typename Axis,
typename OtherDerived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1086 const TensorConcatenationOp<const Axis, const Derived, const OtherDerived>
1087 concatenate(
const OtherDerived& other,
const Axis& axis)
const {
1088 return TensorConcatenationOp<const Axis, const Derived, const OtherDerived>(derived(), other, axis);
1090 template <
typename Axis,
typename OtherDerived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1091 TensorConcatenationOp<const Axis, Derived, OtherDerived>
1092 concatenate(
const OtherDerived& other,
const Axis& axis) {
1093 return TensorConcatenationOp<const Axis, Derived, OtherDerived>(derived(), other, axis);
1097 const TensorReshapingOp<const NewDimensions, const Derived>
1098 reshape(
const NewDimensions& newDimensions)
const {
1099 return TensorReshapingOp<const NewDimensions, const Derived>(derived(), newDimensions);
1102 TensorReshapingOp<const NewDimensions, Derived>
1103 reshape(
const NewDimensions& newDimensions) {
1104 return TensorReshapingOp<const NewDimensions, Derived>(derived(), newDimensions);
1107 template <
typename StartIndices,
typename Sizes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1108 const TensorSlicingOp<const StartIndices, const Sizes, const Derived>
1109 slice(
const StartIndices& startIndices,
const Sizes& sizes)
const {
1110 return TensorSlicingOp<const StartIndices, const Sizes, const Derived>(derived(), startIndices, sizes);
1112 template <
typename StartIndices,
typename Sizes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1113 TensorSlicingOp<const StartIndices, const Sizes, Derived>
1114 slice(
const StartIndices& startIndices,
const Sizes& sizes) {
1115 return TensorSlicingOp<const StartIndices, const Sizes, Derived>(derived(), startIndices, sizes);
1118 template <
typename StartIndices,
typename StopIndices,
typename Str
ides>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1119 const TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, const Derived>
1120 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides&
strides)
const {
1121 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
1122 const Derived>(derived(), startIndices, stopIndices,
strides);
1124 template <
typename StartIndices,
typename StopIndices,
typename Str
ides>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1125 TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, Derived>
1126 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides&
strides) {
1127 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
1128 Derived>(derived(), startIndices, stopIndices,
strides);
1132 const TensorChippingOp<DimId, const Derived>
1133 chip(
const Index offset)
const {
1134 return TensorChippingOp<DimId, const Derived>(derived(), offset, DimId);
1137 TensorChippingOp<DimId, Derived>
1138 chip(
const Index offset) {
1139 return TensorChippingOp<DimId, Derived>(derived(), offset, DimId);
1143 const TensorChippingOp<Dynamic, const Derived>
1144 chip(
const Index offset,
const Index dim)
const {
1145 return TensorChippingOp<Dynamic, const Derived>(derived(), offset, dim);
1148 TensorChippingOp<Dynamic, Derived>
1150 return TensorChippingOp<Dynamic, Derived>(derived(), offset, dim);
1154 const TensorReverseOp<const ReverseDimensions, const Derived>
1155 reverse(
const ReverseDimensions& rev)
const {
1156 return TensorReverseOp<const ReverseDimensions, const Derived>(derived(), rev);
1159 TensorReverseOp<const ReverseDimensions, Derived>
1160 reverse(
const ReverseDimensions& rev) {
1161 return TensorReverseOp<const ReverseDimensions, Derived>(derived(), rev);
1165 const TensorShufflingOp<const Shuffle, const Derived>
1166 shuffle(
const Shuffle& shfl)
const {
1167 return TensorShufflingOp<const Shuffle, const Derived>(derived(), shfl);
1170 TensorShufflingOp<const Shuffle, Derived>
1171 shuffle(
const Shuffle& shfl) {
1172 return TensorShufflingOp<const Shuffle, Derived>(derived(), shfl);
1176 const TensorStridingOp<const Strides, const Derived>
1177 stride(
const Strides&
strides)
const {
1178 return TensorStridingOp<const Strides, const Derived>(derived(),
strides);
1181 TensorStridingOp<const Strides, Derived>
1182 stride(
const Strides&
strides) {
1183 return TensorStridingOp<const Strides, Derived>(derived(),
strides);
1187 template <
typename DeviceType>
1188 TensorDevice<Derived, DeviceType> device(
const DeviceType& dev) {
1189 return TensorDevice<Derived, DeviceType>(dev, derived());
1193 template <
typename DeviceType,
typename DoneCallback>
1194 TensorAsyncDevice<Derived, DeviceType, DoneCallback> device(
const DeviceType& dev, DoneCallback done) {
1195 return TensorAsyncDevice<Derived, DeviceType, DoneCallback>(dev, derived(), std::move(done));
1198 #ifdef EIGEN_TENSORBASE_PLUGIN
1199 #include EIGEN_TENSORBASE_PLUGIN
1207 EIGEN_STRONG_INLINE Derived& operator=(
const OtherDerived& other)
1209 typedef TensorAssignOp<Derived, const OtherDerived> Assign;
1210 Assign assign(derived(), other.derived());
1211 internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
1215 EIGEN_STRONG_INLINE Derived& derived() {
return *
static_cast<Derived*
>(
this); }
1217 EIGEN_STRONG_INLINE
const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
const BooleanNotReturnType operator!() const
const BitwiseNotReturnType operator~() const
const CwiseBinaryOp< internal::scalar_boolean_or_op< Scalar >, const Derived, const OtherDerived > operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< internal::scalar_boolean_and_op< Scalar >, const Derived, const OtherDerived > operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< internal::scalar_bitwise_xor_op< Scalar >, const Derived, const OtherDerived > operator^(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< CustomBinaryOp, const Derived, const OtherDerived > binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other, const CustomBinaryOp &func=CustomBinaryOp()) const
const CwiseBinaryOp< internal::scalar_bitwise_or_op< Scalar >, const Derived, const OtherDerived > operator|(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< internal::scalar_bitwise_and_op< Scalar >, const Derived, const OtherDerived > operator&(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
CastXpr< NewType >::Type cast() const
const CwiseUnaryOp< CustomUnaryOp, const Derived > unaryExpr(const CustomUnaryOp &func=CustomUnaryOp()) const
ConjugateReturnType conjugate() const
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived)
#define EIGEN_DEVICE_FUNC
const CwiseBinaryOp< internal::scalar_min_op< Scalar, Scalar, NaNPropagation >, const Derived, const OtherDerived > cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< internal::scalar_max_op< Scalar, Scalar, NaNPropagation >, const Derived, const OtherDerived > cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
#define EIGEN_STATIC_ASSERT(X, MSG)
static const Eigen::internal::all_t all
bfloat16 & operator/=(bfloat16 &a, const bfloat16 &b)
bfloat16 & operator*=(bfloat16 &a, const bfloat16 &b)
bool operator>(const bfloat16 &a, const bfloat16 &b)
bfloat16 & operator+=(bfloat16 &a, const bfloat16 &b)
bfloat16 & operator-=(bfloat16 &a, const bfloat16 &b)
bool operator<=(const bfloat16 &a, const bfloat16 &b)
T operator/(const T &numerator, const TensorIntDivisor< T, div_gt_one > &divisor)
EIGEN_ALWAYS_INLINE bool operator<(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
EIGEN_ALWAYS_INLINE DSizes< IndexType, NumDims > strides(const DSizes< IndexType, NumDims > &dimensions)
EIGEN_ALWAYS_INLINE bool operator>=(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
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_rint_op< typename Derived::Scalar >, const Derived > rint(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_imag_op< typename Derived::Scalar >, const Derived > imag(const Eigen::ArrayBase< Derived > &x)
EIGEN_CONSTEXPR bool operator==(const Pair< U, V > &x, const Pair< U, V > &y)
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)
const CwiseBinaryOp< internal::scalar_difference_op< typename DenseDerived::Scalar, typename SparseDerived::Scalar >, const DenseDerived, const SparseDerived > operator-(const MatrixBase< DenseDerived > &a, const SparseMatrixBase< SparseDerived > &b)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_j1_op< typename Derived::Scalar >, const Derived > bessel_j1(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k0_op< typename Derived::Scalar >, const Derived > bessel_k0(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_y1_op< typename Derived::Scalar >, const Derived > bessel_y1(const Eigen::ArrayBase< Derived > &x)
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)
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
CleanedUpDerType< DerType >::type() max(const AutoDiffScalar< DerType > &x, const T &y)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_j0_op< typename Derived::Scalar >, const Derived > bessel_j0(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)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k1_op< typename Derived::Scalar >, const Derived > bessel_k1(const Eigen::ArrayBase< Derived > &x)
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)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sign_op< typename Derived::Scalar >, const Derived > sign(const Eigen::ArrayBase< Derived > &x)
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(internal::remove_all_t< DerType >, typename internal::traits< internal::remove_all_t< DerType >>::Scalar, product) > pow(const Eigen::AutoDiffScalar< DerType > &x, const typename internal::traits< internal::remove_all_t< DerType >>::Scalar &y)
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_bessel_k0e_op< typename Derived::Scalar >, const Derived > bessel_k0e(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_arg_op< typename Derived::Scalar >, const Derived > arg(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_bessel_y0_op< typename Derived::Scalar >, const Derived > bessel_y0(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i0_op< typename Derived::Scalar >, const Derived > bessel_i0(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_ndtri_op< typename Derived::Scalar >, const Derived > ndtri(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 CwiseBinaryOp< internal::scalar_sum_op< typename DenseDerived::Scalar, typename SparseDerived::Scalar >, const DenseDerived, const SparseDerived > operator+(const MatrixBase< DenseDerived > &a, const SparseMatrixBase< SparseDerived > &b)
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 Eigen::CwiseBinaryOp< Eigen::internal::scalar_igamma_der_a_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igamma_der_a(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
const Product< Inverse< PermutationType >, SparseDerived, AliasFreeProduct > operator*(const InverseImpl< PermutationType, PermutationStorage > &tperm, const SparseMatrixBase< SparseDerived > &matrix)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_log2_op< typename Derived::Scalar >, const Derived > log2(const Eigen::ArrayBase< Derived > &x)
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)
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_bessel_i1_op< typename Derived::Scalar >, const Derived > bessel_i1(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_bessel_i1e_op< typename Derived::Scalar >, const Derived > bessel_i1e(const Eigen::ArrayBase< Derived > &x)
EIGEN_CONSTEXPR bool operator!=(const Pair< U, V > &x, const Pair< U, V > &y)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_expm1_op< typename Derived::Scalar >, const Derived > expm1(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_log_op< typename Derived::Scalar >, const Derived > log(const Eigen::ArrayBase< Derived > &x)
EIGEN_ALWAYS_INLINE const T1 & choose(Cond< true >, const T1 &first, const T2 &)
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_bessel_i0e_op< typename Derived::Scalar >, const Derived > bessel_i0e(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)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k1e_op< typename Derived::Scalar >, const Derived > bessel_k1e(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_gamma_sample_der_alpha_op< typename AlphaDerived::Scalar >, const AlphaDerived, const SampleDerived > gamma_sample_der_alpha(const Eigen::ArrayBase< AlphaDerived > &alpha, const Eigen::ArrayBase< SampleDerived > &sample)