10#ifndef EIGEN_CXX11_TENSOR_TENSOR_BASE_H
11#define EIGEN_CXX11_TENSOR_TENSOR_BASE_H
25#ifndef EIGEN_PARSED_BY_DOXYGEN
28template<
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 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i0_op<Scalar>,
const Derived>
141 return unaryExpr(internal::scalar_bessel_i0_op<Scalar>());
145 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i0e_op<Scalar>,
const Derived>
147 return unaryExpr(internal::scalar_bessel_i0e_op<Scalar>());
151 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i1_op<Scalar>,
const Derived>
153 return unaryExpr(internal::scalar_bessel_i1_op<Scalar>());
157 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_i1e_op<Scalar>,
const Derived>
159 return unaryExpr(internal::scalar_bessel_i1e_op<Scalar>());
163 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_j0_op<Scalar>,
const Derived>
165 return unaryExpr(internal::scalar_bessel_j0_op<Scalar>());
169 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_y0_op<Scalar>,
const Derived>
171 return unaryExpr(internal::scalar_bessel_y0_op<Scalar>());
175 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_j1_op<Scalar>,
const Derived>
177 return unaryExpr(internal::scalar_bessel_j1_op<Scalar>());
181 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_y1_op<Scalar>,
const Derived>
183 return unaryExpr(internal::scalar_bessel_y1_op<Scalar>());
187 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k0_op<Scalar>,
const Derived>
189 return unaryExpr(internal::scalar_bessel_k0_op<Scalar>());
193 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k0e_op<Scalar>,
const Derived>
195 return unaryExpr(internal::scalar_bessel_k0e_op<Scalar>());
199 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k1_op<Scalar>,
const Derived>
201 return unaryExpr(internal::scalar_bessel_k1_op<Scalar>());
205 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_bessel_k1e_op<Scalar>,
const Derived>
207 return unaryExpr(internal::scalar_bessel_k1e_op<Scalar>());
211 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
212 const TensorCwiseBinaryOp<internal::scalar_igamma_op<Scalar>,
const Derived,
const OtherDerived>
213 igamma(
const OtherDerived& other)
const {
214 return binaryExpr(other.derived(), internal::scalar_igamma_op<Scalar>());
218 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
219 const TensorCwiseBinaryOp<internal::scalar_igamma_der_a_op<Scalar>,
const Derived,
const OtherDerived>
221 return binaryExpr(other.derived(), internal::scalar_igamma_der_a_op<Scalar>());
225 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
226 const TensorCwiseBinaryOp<internal::scalar_gamma_sample_der_alpha_op<Scalar>,
const Derived,
const OtherDerived>
228 return binaryExpr(other.derived(), internal::scalar_gamma_sample_der_alpha_op<Scalar>());
232 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
233 const TensorCwiseBinaryOp<internal::scalar_igammac_op<Scalar>,
const Derived,
const OtherDerived>
234 igammac(
const OtherDerived& other)
const {
235 return binaryExpr(other.derived(), internal::scalar_igammac_op<Scalar>());
239 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
240 const TensorCwiseBinaryOp<internal::scalar_zeta_op<Scalar>,
const Derived,
const OtherDerived>
241 zeta(
const OtherDerived& other)
const {
242 return binaryExpr(other.derived(), internal::scalar_zeta_op<Scalar>());
246 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
247 const TensorCwiseBinaryOp<internal::scalar_polygamma_op<Scalar>,
const Derived,
const OtherDerived>
248 polygamma(
const OtherDerived& other)
const {
249 return binaryExpr(other.derived(), internal::scalar_polygamma_op<Scalar>());
253 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_erf_op<Scalar>,
const Derived>
255 return unaryExpr(internal::scalar_erf_op<Scalar>());
259 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_erfc_op<Scalar>,
const Derived>
261 return unaryExpr(internal::scalar_erfc_op<Scalar>());
265 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_ndtri_op<Scalar>,
const Derived>
267 return unaryExpr(internal::scalar_ndtri_op<Scalar>());
271 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_logistic_op<Scalar>,
const Derived>
273 return unaryExpr(internal::scalar_logistic_op<Scalar>());
277 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_exp_op<Scalar>,
const Derived>
279 return unaryExpr(internal::scalar_exp_op<Scalar>());
283 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_expm1_op<Scalar>,
const Derived>
285 return unaryExpr(internal::scalar_expm1_op<Scalar>());
289 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log_op<Scalar>,
const Derived>
291 return unaryExpr(internal::scalar_log_op<Scalar>());
295 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log1p_op<Scalar>,
const Derived>
297 return unaryExpr(internal::scalar_log1p_op<Scalar>());
301 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_log2_op<Scalar>,
const Derived>
303 return unaryExpr(internal::scalar_log2_op<Scalar>());
307 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_abs_op<Scalar>,
const Derived>
309 return unaryExpr(internal::scalar_abs_op<Scalar>());
313 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_clamp_op<Scalar>,
const Derived>
314 clip(Scalar min, Scalar max)
const {
315 return unaryExpr(internal::scalar_clamp_op<Scalar>(min, max));
319 EIGEN_STRONG_INLINE
const typename internal::conditional<NumTraits<CoeffReturnType>::IsComplex,
320 TensorCwiseUnaryOp<internal::scalar_conjugate_op<Scalar>,
const Derived>,
323 return choose(Cond<NumTraits<CoeffReturnType>::IsComplex>(), unaryExpr(internal::scalar_conjugate_op<Scalar>()), derived());
327 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_pow_op<Scalar,Scalar> >,
const Derived>
328 pow(Scalar exponent)
const {
329 return unaryExpr(internal::bind2nd_op<internal::scalar_pow_op<Scalar,Scalar> >(exponent));
333 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_real_op<Scalar>,
const Derived>
335 return unaryExpr(internal::scalar_real_op<Scalar>());
339 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_imag_op<Scalar>,
const Derived>
341 return unaryExpr(internal::scalar_imag_op<Scalar>());
345 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_sum_op<Scalar,Scalar> >,
const Derived>
346 operator+ (Scalar rhs)
const {
347 return unaryExpr(internal::bind2nd_op<internal::scalar_sum_op<Scalar,Scalar> >(rhs));
351 EIGEN_STRONG_INLINE
friend
352 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_sum_op<Scalar> >,
const Derived>
353 operator+ (Scalar lhs,
const Derived& rhs) {
354 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_sum_op<Scalar> >(lhs));
358 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_difference_op<Scalar,Scalar> >,
const Derived>
359 operator- (Scalar rhs)
const {
360 EIGEN_STATIC_ASSERT((NumTraits<Scalar>::IsSigned || internal::is_same<Scalar,
const std::complex<float> >::value), YOU_MADE_A_PROGRAMMING_MISTAKE);
361 return unaryExpr(internal::bind2nd_op<internal::scalar_difference_op<Scalar,Scalar> >(rhs));
365 EIGEN_STRONG_INLINE
friend
366 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_difference_op<Scalar> >,
const Derived>
367 operator- (Scalar lhs,
const Derived& rhs) {
368 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_difference_op<Scalar> >(lhs));
372 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_product_op<Scalar,Scalar> >,
const Derived>
374 return unaryExpr(internal::bind2nd_op<internal::scalar_product_op<Scalar,Scalar> >(rhs));
378 EIGEN_STRONG_INLINE
friend
379 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_product_op<Scalar> >,
const Derived>
380 operator* (Scalar lhs,
const Derived& rhs) {
381 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_product_op<Scalar> >(lhs));
385 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::bind2nd_op<internal::scalar_quotient_op<Scalar,Scalar> >,
const Derived>
386 operator/ (Scalar rhs)
const {
387 return unaryExpr(internal::bind2nd_op<internal::scalar_quotient_op<Scalar,Scalar> >(rhs));
391 EIGEN_STRONG_INLINE
friend
392 const TensorCwiseUnaryOp<internal::bind1st_op<internal::scalar_quotient_op<Scalar> >,
const Derived>
393 operator/ (Scalar lhs,
const Derived& rhs) {
394 return rhs.unaryExpr(internal::bind1st_op<internal::scalar_quotient_op<Scalar> >(lhs));
398 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_mod_op<Scalar>,
const Derived>
399 operator% (Scalar rhs)
const {
400 EIGEN_STATIC_ASSERT(NumTraits<Scalar>::IsInteger, YOU_MADE_A_PROGRAMMING_MISTAKE_TRY_MOD);
401 return unaryExpr(internal::scalar_mod_op<Scalar>(rhs));
404 template <
int NanPropagation=PropagateFast>
406 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar,NanPropagation>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
407 cwiseMax(Scalar threshold)
const {
408 return cwiseMax<NanPropagation>(constant(threshold));
411 template <
int NanPropagation=PropagateFast>
413 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar,NanPropagation>,
const Derived,
const TensorCwiseNullaryOp<internal::scalar_constant_op<Scalar>,
const Derived> >
414 cwiseMin(Scalar threshold)
const {
415 return cwiseMin<NanPropagation>(constant(threshold));
418 template<
typename NewType>
420 EIGEN_STRONG_INLINE
const typename internal::conditional<internal::is_same<NewType, CoeffReturnType>::value,
422 TensorConversionOp<NewType, const Derived> >::type
424 return choose(Cond<internal::is_same<NewType, CoeffReturnType>::value>(), derived(), TensorConversionOp<NewType, const Derived>(derived()));
428 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_round_op<Scalar>,
const Derived>
430 return unaryExpr(internal::scalar_round_op<Scalar>());
434 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_rint_op<Scalar>,
const Derived>
436 return unaryExpr(internal::scalar_rint_op<Scalar>());
440 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_ceil_op<Scalar>,
const Derived>
442 return unaryExpr(internal::scalar_ceil_op<Scalar>());
446 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_floor_op<Scalar>,
const Derived>
448 return unaryExpr(internal::scalar_floor_op<Scalar>());
452 template <
typename CustomBinaryOp,
typename OtherDerived> EIGEN_DEVICE_FUNC
453 EIGEN_STRONG_INLINE
const TensorCwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>
454 binaryExpr(
const OtherDerived& other,
const CustomBinaryOp& func)
const {
455 return TensorCwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>(derived(), other, func);
459 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
460 const TensorCwiseBinaryOp<internal::scalar_sum_op<Scalar>,
const Derived,
const OtherDerived>
461 operator+(
const OtherDerived& other)
const {
462 return binaryExpr(other.derived(), internal::scalar_sum_op<Scalar>());
465 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
466 const TensorCwiseBinaryOp<internal::scalar_difference_op<Scalar>,
const Derived,
const OtherDerived>
467 operator-(
const OtherDerived& other)
const {
468 return binaryExpr(other.derived(), internal::scalar_difference_op<Scalar>());
471 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
472 const TensorCwiseBinaryOp<internal::scalar_product_op<Scalar>,
const Derived,
const OtherDerived>
473 operator*(
const OtherDerived& other)
const {
474 return binaryExpr(other.derived(), internal::scalar_product_op<Scalar>());
477 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
478 const TensorCwiseBinaryOp<internal::scalar_quotient_op<Scalar>,
const Derived,
const OtherDerived>
479 operator/(
const OtherDerived& other)
const {
480 return binaryExpr(other.derived(), internal::scalar_quotient_op<Scalar>());
483 template<
int NaNPropagation=PropagateFast,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
484 const TensorCwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar, NaNPropagation>,
const Derived,
const OtherDerived>
485 cwiseMax(
const OtherDerived& other)
const {
486 return binaryExpr(other.derived(), internal::scalar_max_op<Scalar,Scalar, NaNPropagation>());
489 template<
int NaNPropagation=PropagateFast,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
490 const TensorCwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar, NaNPropagation>,
const Derived,
const OtherDerived>
491 cwiseMin(
const OtherDerived& other)
const {
492 return binaryExpr(other.derived(), internal::scalar_min_op<Scalar,Scalar, NaNPropagation>());
495 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
496 const TensorCwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
497 operator&&(
const OtherDerived& other)
const {
498 return binaryExpr(other.derived(), internal::scalar_boolean_and_op());
501 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
502 const TensorCwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
503 operator||(
const OtherDerived& other)
const {
504 return binaryExpr(other.derived(), internal::scalar_boolean_or_op());
507 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
508 const TensorCwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>
509 operator^(
const OtherDerived& other)
const {
510 return binaryExpr(other.derived(), internal::scalar_boolean_xor_op());
514 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
515 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>,
const Derived,
const OtherDerived>
516 operator<(
const OtherDerived& other)
const {
517 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>());
519 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
520 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>,
const Derived,
const OtherDerived>
521 operator<=(
const OtherDerived& other)
const {
522 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>());
524 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
525 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>,
const Derived,
const OtherDerived>
526 operator>(
const OtherDerived& other)
const {
527 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>());
529 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
530 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>,
const Derived,
const OtherDerived>
531 operator>=(
const OtherDerived& other)
const {
532 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>());
535 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
536 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>,
const Derived,
const OtherDerived>
537 operator==(
const OtherDerived& other)
const {
538 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>());
541 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
542 const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>,
const Derived,
const OtherDerived>
543 operator!=(
const OtherDerived& other)
const {
544 return binaryExpr(other.derived(), internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>());
549 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> >
550 operator<(Scalar threshold)
const {
551 return operator<(constant(threshold));
554 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> >
555 operator<=(Scalar threshold)
const {
556 return operator<=(constant(threshold));
559 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> >
560 operator>(Scalar threshold)
const {
561 return operator>(constant(threshold));
564 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> >
565 operator>=(Scalar threshold)
const {
566 return operator>=(constant(threshold));
569 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> >
570 operator==(Scalar threshold)
const {
571 return operator==(constant(threshold));
574 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> >
575 operator!=(Scalar threshold)
const {
576 return operator!=(constant(threshold));
581 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isnan_op<Scalar>,
const Derived>
583 return unaryExpr(internal::scalar_isnan_op<Scalar>());
586 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isinf_op<Scalar>,
const Derived>
588 return unaryExpr(internal::scalar_isinf_op<Scalar>());
591 EIGEN_STRONG_INLINE
const TensorCwiseUnaryOp<internal::scalar_isfinite_op<Scalar>,
const Derived>
593 return unaryExpr(internal::scalar_isfinite_op<Scalar>());
597 template<
typename ThenDerived,
typename ElseDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
598 const TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>
599 select(
const ThenDerived& thenTensor,
const ElseDerived& elseTensor)
const {
600 return TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>(derived(), thenTensor.derived(), elseTensor.derived());
604 typedef Eigen::IndexPair<Index> DimensionPair;
606 template<
typename OtherDerived,
typename Dimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
607 const TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const NoOpOutputKernel>
608 contract(
const OtherDerived& other,
const Dimensions& dims)
const {
609 return TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const NoOpOutputKernel>(derived(), other.derived(), dims);
612 template<
typename OtherDerived,
typename Dimensions,
typename OutputKernel> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
613 const TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const OutputKernel>
614 contract(
const OtherDerived& other,
const Dimensions& dims,
const OutputKernel& output_kernel)
const {
615 return TensorContractionOp<const Dimensions, const Derived, const OtherDerived, const OutputKernel>(derived(), other.derived(), dims, output_kernel);
619 template<
typename KernelDerived,
typename Dimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
620 const TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>
621 convolve(
const KernelDerived& kernel,
const Dimensions& dims)
const {
622 return TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>(derived(), kernel.derived(), dims);
626 template <
int FFTDataType,
int FFTDirection,
typename FFT> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
627 const TensorFFTOp<const FFT, const Derived, FFTDataType, FFTDirection>
628 fft(
const FFT& dims)
const {
629 return TensorFFTOp<const FFT, const Derived, FFTDataType, FFTDirection>(derived(), dims);
633 typedef TensorScanOp<internal::SumReducer<CoeffReturnType>,
const Derived> TensorScanSumOp;
634 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
635 const TensorScanSumOp
636 cumsum(
const Index& axis,
bool exclusive =
false)
const {
637 return TensorScanSumOp(derived(), axis, exclusive);
640 typedef TensorScanOp<internal::ProdReducer<CoeffReturnType>,
const Derived> TensorScanProdOp;
641 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
642 const TensorScanProdOp
643 cumprod(
const Index& axis,
bool exclusive =
false)
const {
644 return TensorScanProdOp(derived(), axis, exclusive);
647 template <
typename Reducer>
648 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
649 const TensorScanOp<Reducer, const Derived>
650 scan(
const Index& axis,
const Reducer& reducer,
bool exclusive =
false)
const {
651 return TensorScanOp<Reducer, const Derived>(derived(), axis, exclusive, reducer);
655 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
656 const TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const Dims,
const Derived>
657 sum(
const Dims& dims)
const {
658 return TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::SumReducer<CoeffReturnType>());
661 const TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
663 DimensionList<Index, NumDimensions> in_dims;
664 return TensorReductionOp<internal::SumReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::SumReducer<CoeffReturnType>());
667 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
668 const TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const Dims,
const Derived>
669 mean(
const Dims& dims)
const {
670 return TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::MeanReducer<CoeffReturnType>());
673 const TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
675 DimensionList<Index, NumDimensions> in_dims;
676 return TensorReductionOp<internal::MeanReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MeanReducer<CoeffReturnType>());
679 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
680 const TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const Dims,
const Derived>
681 prod(
const Dims& dims)
const {
682 return TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const Dims,
const Derived>(derived(), dims, internal::ProdReducer<CoeffReturnType>());
685 const TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>
687 DimensionList<Index, NumDimensions> in_dims;
688 return TensorReductionOp<internal::ProdReducer<CoeffReturnType>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::ProdReducer<CoeffReturnType>());
691 template <
typename Dims,
int NanPropagation=PropagateFast> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
692 const TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>
693 maximum(
const Dims& dims)
const {
694 return TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>(derived(), dims, internal::MaxReducer<CoeffReturnType,NanPropagation>());
697 template <
int NanPropagation=PropagateFast>
698 const TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>
700 DimensionList<Index, NumDimensions> in_dims;
701 return TensorReductionOp<internal::MaxReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MaxReducer<CoeffReturnType,NanPropagation>());
704 template <
typename Dims,
int NanPropagation=PropagateFast> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
705 const TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>
706 minimum(
const Dims& dims)
const {
707 return TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const Dims,
const Derived>(derived(), dims, internal::MinReducer<CoeffReturnType,NanPropagation>());
710 template <
int NanPropagation=PropagateFast>
711 const TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>
713 DimensionList<Index, NumDimensions> in_dims;
714 return TensorReductionOp<internal::MinReducer<CoeffReturnType,NanPropagation>,
const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims, internal::MinReducer<CoeffReturnType,NanPropagation>());
717 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
718 const TensorReductionOp<internal::AndReducer, const Dims, const typename internal::conditional<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> >::type >
719 all(
const Dims& dims)
const {
720 return cast<bool>().reduce(dims, internal::AndReducer());
723 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
724 const TensorReductionOp<internal::AndReducer, const DimensionList<Index, NumDimensions>,
const typename internal::conditional<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> >::type >
726 DimensionList<Index, NumDimensions> in_dims;
727 return cast<bool>().reduce(in_dims, internal::AndReducer());
730 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
731 const TensorReductionOp<internal::OrReducer, const Dims, const typename internal::conditional<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> >::type >
732 any(
const Dims& dims)
const {
733 return cast<bool>().reduce(dims, internal::OrReducer());
736 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
737 const TensorReductionOp<internal::OrReducer, const DimensionList<Index, NumDimensions>,
const typename internal::conditional<internal::is_same<bool, CoeffReturnType>::value, Derived, TensorConversionOp<bool, const Derived> >::type >
739 DimensionList<Index, NumDimensions> in_dims;
740 return cast<bool>().reduce(in_dims, internal::OrReducer());
743 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
744 const TensorTupleReducerOp<
745 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
746 const array<Index, NumDimensions>,
const Derived>
748 array<Index, NumDimensions> in_dims;
749 for (
Index d = 0; d < NumDimensions; ++d) in_dims[d] = d;
750 return TensorTupleReducerOp<
751 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
752 const array<Index, NumDimensions>,
753 const Derived>(derived(), internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >(), -1, in_dims);
756 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
757 const TensorTupleReducerOp<
758 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
759 const array<Index, NumDimensions>,
const Derived>
761 array<Index, NumDimensions> in_dims;
762 for (
Index d = 0; d < NumDimensions; ++d) in_dims[d] = d;
763 return TensorTupleReducerOp<
764 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
765 const array<Index, NumDimensions>,
766 const Derived>(derived(), internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >(), -1, in_dims);
769 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
770 const TensorTupleReducerOp<
771 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
772 const array<Index, 1>,
const Derived>
773 argmax(
const Index return_dim)
const {
774 array<Index, 1> in_dims;
775 in_dims[0] = return_dim;
776 return TensorTupleReducerOp<
777 internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >,
778 const array<Index, 1>,
779 const Derived>(derived(), internal::ArgMaxTupleReducer<Tuple<Index, CoeffReturnType> >(), return_dim, in_dims);
782 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
783 const TensorTupleReducerOp<
784 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
785 const array<Index, 1>,
const Derived>
786 argmin(
const Index return_dim)
const {
787 array<Index, 1> in_dims;
788 in_dims[0] = return_dim;
789 return TensorTupleReducerOp<
790 internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >,
791 const array<Index, 1>,
792 const Derived>(derived(), internal::ArgMinTupleReducer<Tuple<Index, CoeffReturnType> >(), return_dim, in_dims);
795 template <
typename Reducer,
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
796 const TensorReductionOp<Reducer, const Dims, const Derived>
797 reduce(
const Dims& dims,
const Reducer& reducer)
const {
798 return TensorReductionOp<Reducer, const Dims, const Derived>(derived(), dims, reducer);
801 template <
typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
802 const TensorTraceOp<const Dims, const Derived>
803 trace(
const Dims& dims)
const {
804 return TensorTraceOp<const Dims, const Derived>(derived(), dims);
807 const TensorTraceOp<const DimensionList<Index, NumDimensions>,
const Derived>
809 DimensionList<Index, NumDimensions> in_dims;
810 return TensorTraceOp<const DimensionList<Index, NumDimensions>,
const Derived>(derived(), in_dims);
813 template <
typename Broadcast> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
814 const TensorBroadcastingOp<const Broadcast, const Derived>
815 broadcast(
const Broadcast& bcast)
const {
816 return TensorBroadcastingOp<const Broadcast, const Derived>(derived(), bcast);
819 template <
typename Axis,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
820 const TensorConcatenationOp<Axis, const Derived, const OtherDerived>
821 concatenate(
const OtherDerived& other, Axis axis)
const {
822 return TensorConcatenationOp<Axis, const Derived, const OtherDerived>(derived(), other.derived(), axis);
825 template <
typename PatchDims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
826 const TensorPatchOp<const PatchDims, const Derived>
827 extract_patches(
const PatchDims& patch_dims)
const {
828 return TensorPatchOp<const PatchDims, const Derived>(derived(), patch_dims);
831 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
832 const TensorImagePatchOp<Dynamic, Dynamic, const Derived>
833 extract_image_patches(
const Index patch_rows = 1,
const Index patch_cols = 1,
834 const Index row_stride = 1,
const Index col_stride = 1,
835 const Index in_row_stride = 1,
const Index in_col_stride = 1,
836 const PaddingType padding_type = PADDING_SAME,
const Scalar padding_value = Scalar(0))
const {
837 return TensorImagePatchOp<Dynamic, Dynamic, const Derived>(derived(), patch_rows, patch_cols, row_stride, col_stride,
838 in_row_stride, in_col_stride, 1, 1, padding_type, padding_value);
841 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
842 const TensorImagePatchOp<Dynamic, Dynamic, const Derived>
843 extract_image_patches(
const Index patch_rows,
const Index patch_cols,
844 const Index row_stride,
const Index col_stride,
845 const Index in_row_stride,
const Index in_col_stride,
846 const Index row_inflate_stride,
const Index col_inflate_stride,
847 const Index padding_top,
const Index padding_bottom,
848 const Index padding_left,
const Index padding_right,
849 const Scalar padding_value)
const {
850 return TensorImagePatchOp<Dynamic, Dynamic, const Derived>(derived(), patch_rows, patch_cols, row_stride, col_stride,
851 in_row_stride, in_col_stride, row_inflate_stride, col_inflate_stride,
852 padding_top, padding_bottom, padding_left, padding_right, padding_value);
855 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
856 const TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>
857 extract_volume_patches(
const Index patch_planes,
const Index patch_rows,
const Index patch_cols,
858 const Index plane_stride = 1,
const Index row_stride = 1,
const Index col_stride = 1,
859 const PaddingType padding_type = PADDING_SAME,
const Scalar padding_value = Scalar(0))
const {
860 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);
864 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
865 const TensorVolumePatchOp<Dynamic, Dynamic, Dynamic, const Derived>
866 extract_volume_patches(
const Index patch_planes,
const Index patch_rows,
const Index patch_cols,
867 const Index plane_stride,
const Index row_stride,
const Index col_stride,
868 const Index plane_inflate_stride,
const Index row_inflate_stride,
const Index col_inflate_stride,
869 const Index padding_top_z,
const Index padding_bottom_z,
870 const Index padding_top,
const Index padding_bottom,
871 const Index padding_left,
const Index padding_right,
const Scalar padding_value = Scalar(0))
const {
872 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);
876 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
877 const TensorLayoutSwapOp<const Derived>
878 swap_layout()
const {
879 return TensorLayoutSwapOp<const Derived>(derived());
881 template <
typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
882 const TensorReshapingOp<const NewDimensions, const Derived>
883 reshape(
const NewDimensions& newDimensions)
const {
884 return TensorReshapingOp<const NewDimensions, const Derived>(derived(), newDimensions);
886 template <
typename StartIndices,
typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
887 const TensorSlicingOp<const StartIndices, const Sizes, const Derived>
888 slice(
const StartIndices& startIndices,
const Sizes& sizes)
const {
889 return TensorSlicingOp<const StartIndices, const Sizes, const Derived>(derived(), startIndices, sizes);
891 template <
typename StartIndices,
typename StopIndices,
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
892 const TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, const Derived>
893 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides& strides)
const {
894 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
895 const Derived>(derived(), startIndices, stopIndices, strides);
897 template <Index DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
898 const TensorChippingOp<DimId, const Derived>
899 chip(
const Index offset)
const {
900 return TensorChippingOp<DimId, const Derived>(derived(), offset, DimId);
902 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
903 const TensorChippingOp<Dynamic, const Derived>
904 chip(
const Index offset,
const Index dim)
const {
905 return TensorChippingOp<Dynamic, const Derived>(derived(), offset, dim);
907 template <
typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
908 const TensorReverseOp<const ReverseDimensions, const Derived>
909 reverse(
const ReverseDimensions& rev)
const {
910 return TensorReverseOp<const ReverseDimensions, const Derived>(derived(), rev);
912 template <
typename PaddingDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
913 const TensorPaddingOp<const PaddingDimensions, const Derived>
914 pad(
const PaddingDimensions& padding)
const {
915 return TensorPaddingOp<const PaddingDimensions, const Derived>(derived(), padding, internal::scalar_cast_op<int, Scalar>()(0));
917 template <
typename PaddingDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
918 const TensorPaddingOp<const PaddingDimensions, const Derived>
919 pad(
const PaddingDimensions& padding,
const Scalar padding_value)
const {
920 return TensorPaddingOp<const PaddingDimensions, const Derived>(derived(), padding, padding_value);
922 template <
typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
923 const TensorShufflingOp<const Shuffle, const Derived>
924 shuffle(
const Shuffle& shfl)
const {
925 return TensorShufflingOp<const Shuffle, const Derived>(derived(), shfl);
927 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
928 const TensorStridingOp<const Strides, const Derived>
929 stride(
const Strides& strides)
const {
930 return TensorStridingOp<const Strides, const Derived>(derived(), strides);
932 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
933 const TensorInflationOp<const Strides, const Derived>
934 inflate(
const Strides& strides)
const {
935 return TensorInflationOp<const Strides, const Derived>(derived(), strides);
939 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
940 const TensorIndexTupleOp<const Derived>
941 index_tuples()
const {
942 return TensorIndexTupleOp<const Derived>(derived());
946 template <
typename CustomUnaryFunc>
947 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
948 const TensorCustomUnaryOp<const CustomUnaryFunc, const Derived> customOp(
const CustomUnaryFunc& op)
const {
949 return TensorCustomUnaryOp<const CustomUnaryFunc, const Derived>(derived(), op);
951 template <
typename OtherDerived,
typename CustomBinaryFunc>
952 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
953 const TensorCustomBinaryOp<const CustomBinaryFunc, const Derived, const OtherDerived> customOp(
const OtherDerived& other,
const CustomBinaryFunc& op)
const {
954 return TensorCustomBinaryOp<const CustomBinaryFunc, const Derived, const OtherDerived>(derived(), other, op);
958 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
959 const TensorForcedEvalOp<const Derived> eval()
const {
960 return TensorForcedEvalOp<const Derived>(derived());
964 template <
typename Scalar,
int NumIndices,
int Options,
typename IndexType>
friend class Tensor;
965 template <
typename Scalar,
typename Dimensions,
int Option,
typename IndexTypes>
friend class TensorFixedSize;
967 template <
typename OtherDerived,
int AccessLevel>
friend class Eigen::TensorBase;
969 EIGEN_STRONG_INLINE
const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
972template<typename Derived, int AccessLevel = internal::accessors_level<Derived>::value>
973class TensorBase :
public TensorBase<Derived, ReadOnlyAccessors> {
975 typedef TensorBase<Derived, ReadOnlyAccessors> Base;
976 typedef internal::traits<Derived> DerivedTraits;
977 typedef typename DerivedTraits::Scalar Scalar;
978 typedef typename DerivedTraits::Index
Index;
979 typedef Scalar CoeffReturnType;
980 static const int NumDimensions = DerivedTraits::NumDimensions;
982 template <
typename Scalar,
int NumIndices,
int Options,
typename IndexType>
friend class Tensor;
983 template <
typename Scalar,
typename Dimensions,
int Option,
typename IndexTypes>
friend class TensorFixedSize;
985 template <
typename OtherDerived,
int OtherAccessLevel>
friend class Eigen::TensorBase;
988 EIGEN_STRONG_INLINE Derived& setZero() {
989 return setConstant(Scalar(0));
992 EIGEN_STRONG_INLINE Derived& setConstant(
const Scalar& val) {
993 return derived() = this->constant(val);
996 EIGEN_STRONG_INLINE Derived& setRandom() {
997 return derived() = this->random();
999 template <
typename RandomGenerator> EIGEN_DEVICE_FUNC
1000 EIGEN_STRONG_INLINE Derived& setRandom() {
1001 return derived() = this->
template random<RandomGenerator>();
1004#if EIGEN_HAS_VARIADIC_TEMPLATES
1006 EIGEN_STRONG_INLINE Derived& setValues(
1007 const typename internal::Initializer<Derived, NumDimensions>::InitList& vals) {
1008 TensorEvaluator<Derived, DefaultDevice> eval(derived(), DefaultDevice());
1009 internal::initialize_tensor<Derived, NumDimensions>(eval, vals);
1014 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1015 Derived& operator+=(
const OtherDerived& other) {
1016 return derived() = derived() + other.derived();
1018 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1019 Derived& operator-=(
const OtherDerived& other) {
1020 return derived() = derived() - other.derived();
1022 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1023 Derived& operator*=(
const OtherDerived& other) {
1024 return derived() = derived() * other.derived();
1026 template<
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1027 Derived& operator/=(
const OtherDerived& other) {
1028 return derived() = derived() / other.derived();
1031 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1032 const TensorLayoutSwapOp<const Derived>
1033 swap_layout()
const {
1034 return TensorLayoutSwapOp<const Derived>(derived());
1036 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1037 TensorLayoutSwapOp<Derived>
1039 return TensorLayoutSwapOp<Derived>(derived());
1042 template <
typename Axis,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1043 const TensorConcatenationOp<const Axis, const Derived, const OtherDerived>
1044 concatenate(
const OtherDerived& other,
const Axis& axis)
const {
1045 return TensorConcatenationOp<const Axis, const Derived, const OtherDerived>(derived(), other, axis);
1047 template <
typename Axis,
typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1048 TensorConcatenationOp<const Axis, Derived, OtherDerived>
1049 concatenate(
const OtherDerived& other,
const Axis& axis) {
1050 return TensorConcatenationOp<const Axis, Derived, OtherDerived>(derived(), other, axis);
1053 template <
typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1054 const TensorReshapingOp<const NewDimensions, const Derived>
1055 reshape(
const NewDimensions& newDimensions)
const {
1056 return TensorReshapingOp<const NewDimensions, const Derived>(derived(), newDimensions);
1058 template <
typename NewDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1059 TensorReshapingOp<const NewDimensions, Derived>
1060 reshape(
const NewDimensions& newDimensions) {
1061 return TensorReshapingOp<const NewDimensions, Derived>(derived(), newDimensions);
1064 template <
typename StartIndices,
typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1065 const TensorSlicingOp<const StartIndices, const Sizes, const Derived>
1066 slice(
const StartIndices& startIndices,
const Sizes& sizes)
const {
1067 return TensorSlicingOp<const StartIndices, const Sizes, const Derived>(derived(), startIndices, sizes);
1069 template <
typename StartIndices,
typename Sizes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1070 TensorSlicingOp<const StartIndices, const Sizes, Derived>
1071 slice(
const StartIndices& startIndices,
const Sizes& sizes) {
1072 return TensorSlicingOp<const StartIndices, const Sizes, Derived>(derived(), startIndices, sizes);
1075 template <
typename StartIndices,
typename StopIndices,
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1076 const TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, const Derived>
1077 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides& strides)
const {
1078 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
1079 const Derived>(derived(), startIndices, stopIndices, strides);
1081 template <
typename StartIndices,
typename StopIndices,
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1082 TensorStridingSlicingOp<const StartIndices, const StopIndices, const Strides, Derived>
1083 stridedSlice(
const StartIndices& startIndices,
const StopIndices& stopIndices,
const Strides& strides) {
1084 return TensorStridingSlicingOp<
const StartIndices,
const StopIndices,
const Strides,
1085 Derived>(derived(), startIndices, stopIndices, strides);
1088 template <DenseIndex DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1089 const TensorChippingOp<DimId, const Derived>
1090 chip(
const Index offset)
const {
1091 return TensorChippingOp<DimId, const Derived>(derived(), offset, DimId);
1093 template <Index DimId> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1094 TensorChippingOp<DimId, Derived>
1095 chip(
const Index offset) {
1096 return TensorChippingOp<DimId, Derived>(derived(), offset, DimId);
1099 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1100 const TensorChippingOp<Dynamic, const Derived>
1101 chip(
const Index offset,
const Index dim)
const {
1102 return TensorChippingOp<Dynamic, const Derived>(derived(), offset, dim);
1104 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1105 TensorChippingOp<Dynamic, Derived>
1107 return TensorChippingOp<Dynamic, Derived>(derived(), offset, dim);
1110 template <
typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1111 const TensorReverseOp<const ReverseDimensions, const Derived>
1112 reverse(
const ReverseDimensions& rev)
const {
1113 return TensorReverseOp<const ReverseDimensions, const Derived>(derived(), rev);
1115 template <
typename ReverseDimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1116 TensorReverseOp<const ReverseDimensions, Derived>
1117 reverse(
const ReverseDimensions& rev) {
1118 return TensorReverseOp<const ReverseDimensions, Derived>(derived(), rev);
1121 template <
typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1122 const TensorShufflingOp<const Shuffle, const Derived>
1123 shuffle(
const Shuffle& shfl)
const {
1124 return TensorShufflingOp<const Shuffle, const Derived>(derived(), shfl);
1126 template <
typename Shuffle> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1127 TensorShufflingOp<const Shuffle, Derived>
1128 shuffle(
const Shuffle& shfl) {
1129 return TensorShufflingOp<const Shuffle, Derived>(derived(), shfl);
1132 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1133 const TensorStridingOp<const Strides, const Derived>
1134 stride(
const Strides& strides)
const {
1135 return TensorStridingOp<const Strides, const Derived>(derived(), strides);
1137 template <
typename Str
ides> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1138 TensorStridingOp<const Strides, Derived>
1139 stride(
const Strides& strides) {
1140 return TensorStridingOp<const Strides, Derived>(derived(), strides);
1144 template <
typename DeviceType>
1145 TensorDevice<Derived, DeviceType> device(
const DeviceType& dev) {
1146 return TensorDevice<Derived, DeviceType>(dev, derived());
1150 template <
typename DeviceType,
typename DoneCallback>
1151 TensorAsyncDevice<Derived, DeviceType, DoneCallback> device(
const DeviceType& dev, DoneCallback done) {
1152 return TensorAsyncDevice<Derived, DeviceType, DoneCallback>(dev, derived(), std::move(done));
1156 EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(TensorBase)
1157 EIGEN_DEFAULT_COPY_CONSTRUCTOR(TensorBase)
1159 template<
typename OtherDerived> EIGEN_DEVICE_FUNC
1160 EIGEN_STRONG_INLINE Derived& operator=(
const OtherDerived& other)
1162 typedef TensorAssignOp<Derived, const OtherDerived> Assign;
1163 Assign assign(derived(), other.derived());
1164 internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
1169 EIGEN_STRONG_INLINE Derived& derived() {
return *
static_cast<Derived*
>(
this); }
1171 EIGEN_STRONG_INLINE
const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
The tensor base class.
Definition: TensorForwardDeclarations.h:56
static const Eigen::internal::all_t all
Namespace containing all symbols from the Eigen library.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_y1_op< typename Derived::Scalar >, const Derived > bessel_y1(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:278
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k0e_op< typename Derived::Scalar >, const Derived > bessel_k0e(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:145
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k0_op< typename Derived::Scalar >, const Derived > bessel_k0(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:122
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_real_op< typename Derived::Scalar >, const Derived > real(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::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:90
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_op< typename Derived::Scalar >, const Derived > inverse(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)
Definition: SpecialFunctionsArrayAPI.h:51
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_exp_op< typename Derived::Scalar >, const Derived > exp(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_rsqrt_op< typename Derived::Scalar >, const Derived > rsqrt(const Eigen::ArrayBase< Derived > &x)
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_log2_op< typename Derived::Scalar >, const Derived > log2(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_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
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_bessel_k1_op< typename Derived::Scalar >, const Derived > bessel_k1(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:167
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i1_op< typename Derived::Scalar >, const Derived > bessel_i1(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:77
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i0e_op< typename Derived::Scalar >, const Derived > bessel_i0e(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:55
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_bessel_i1e_op< typename Derived::Scalar >, const Derived > bessel_i1e(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:100
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_j1_op< typename Derived::Scalar >, const Derived > bessel_j1(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:256
const Product< Inverse< PermutationType >, SparseDerived, AliasFreeProduct > operator*(const InverseImpl< PermutationType, PermutationStorage > &tperm, const SparseMatrixBase< SparseDerived > &matrix)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_y0_op< typename Derived::Scalar >, const Derived > bessel_y0(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:234
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i0_op< typename Derived::Scalar >, const Derived > bessel_i0(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:32
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_round_op< typename Derived::Scalar >, const Derived > round(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::CwiseUnaryOp< Eigen::internal::scalar_log1p_op< typename Derived::Scalar >, const Derived > log1p(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_imag_op< typename Derived::Scalar >, const Derived > imag(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_isfinite_op< typename Derived::Scalar >, const Derived > isfinite(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)
Definition: BesselFunctionsArrayAPI.h:190
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)
Definition: SpecialFunctionsArrayAPI.h:72
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_ndtri_op< typename Derived::Scalar >, const Derived > ndtri(const Eigen::ArrayBase< Derived > &x)
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_isnan_op< typename Derived::Scalar >, const Derived > isnan(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_floor_op< typename Derived::Scalar >, const Derived > floor(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)
Definition: SpecialFunctionsArrayAPI.h:112
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_j0_op< typename Derived::Scalar >, const Derived > bessel_j0(const Eigen::ArrayBase< Derived > &x)
Definition: BesselFunctionsArrayAPI.h:212
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_zeta_op< typename DerivedX::Scalar >, const DerivedX, const DerivedQ > zeta(const Eigen::ArrayBase< DerivedX > &x, const Eigen::ArrayBase< DerivedQ > &q)
Definition: SpecialFunctionsArrayAPI.h:156
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_ceil_op< typename Derived::Scalar >, const Derived > ceil(const Eigen::ArrayBase< Derived > &x)