WPILibC++ 2023.4.3-108-ge5452e3
Eigen::ScalarBinaryOpTraits< ScalarA, ScalarB, BinaryOp > Class Template Reference

Determines whether the given binary operation of two numeric types is allowed and what the scalar return type is. More...

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/util/XprHelper.h>

Inheritance diagram for Eigen::ScalarBinaryOpTraits< ScalarA, ScalarB, BinaryOp >:
Eigen::internal::scalar_product_traits< ScalarA, ScalarB >

Additional Inherited Members

- Public Types inherited from Eigen::internal::scalar_product_traits< ScalarA, ScalarB >
enum  
 

Detailed Description

template<typename ScalarA, typename ScalarB, typename BinaryOp = internal::scalar_product_op<ScalarA,ScalarB>>
class Eigen::ScalarBinaryOpTraits< ScalarA, ScalarB, BinaryOp >

Determines whether the given binary operation of two numeric types is allowed and what the scalar return type is.

This class permits to control the scalar return type of any binary operation performed on two different scalar types through (partial) template specializations.

For instance, let U1, U2 and U3 be three user defined scalar types for which most operations between instances of U1 and U2 returns an U3. You can let Eigen knows that by defining:

template<typename BinaryOp>
struct ScalarBinaryOpTraits<U1,U2,BinaryOp> { typedef U3 ReturnType; };
template<typename BinaryOp>
struct ScalarBinaryOpTraits<U2,U1,BinaryOp> { typedef U3 ReturnType; };
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:806

You can then explicitly disable some particular operations to get more explicit error messages:

template<>
struct ScalarBinaryOpTraits<U1,U2,internal::scalar_max_op<U1,U2> > {};
Definition: Eigen_Colamd.h:50

Or customize the return type for individual operation:

template<>
struct ScalarBinaryOpTraits<U1,U2,internal::scalar_sum_op<U1,U2> > { typedef U1 ReturnType; };

By default, the following generic combinations are supported:

ScalarAScalarBBinaryOpReturnTypeNote
T T * T
NumTraits<T>::Real T * T Only if NumTraits<T>::IsComplex
T NumTraits<T>::Real * T Only if NumTraits<T>::IsComplex
See also
CwiseBinaryOp

The documentation for this class was generated from the following file: