CwiseTernaryOp.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 // Copyright (C) 2016 Eugene Brevdo <ebrevdo@gmail.com>
7 //
8 // This Source Code Form is subject to the terms of the Mozilla
9 // Public License v. 2.0. If a copy of the MPL was not distributed
10 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 
12 #ifndef EIGEN_CWISE_TERNARY_OP_H
13 #define EIGEN_CWISE_TERNARY_OP_H
14 
15 namespace Eigen {
16 
17 namespace internal {
18 template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
19 struct traits<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > {
20  // we must not inherit from traits<Arg1> since it has
21  // the potential to cause problems with MSVC
22  typedef typename remove_all<Arg1>::type Ancestor;
24  enum {
29  };
30 
31  // even though we require Arg1, Arg2, and Arg3 to have the same scalar type
32  // (see CwiseTernaryOp constructor),
33  // we still want to handle the case when the result type is different.
34  typedef typename result_of<TernaryOp(
35  const typename Arg1::Scalar&, const typename Arg2::Scalar&,
36  const typename Arg3::Scalar&)>::type Scalar;
37 
40 
41  typedef typename Arg1::Nested Arg1Nested;
42  typedef typename Arg2::Nested Arg2Nested;
43  typedef typename Arg3::Nested Arg3Nested;
47  enum { Flags = _Arg1Nested::Flags & RowMajorBit };
48 };
49 } // end namespace internal
50 
51 template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3,
52  typename StorageKind>
54 
82 template <typename TernaryOp, typename Arg1Type, typename Arg2Type,
83  typename Arg3Type>
85  TernaryOp, Arg1Type, Arg2Type, Arg3Type,
86  typename internal::traits<Arg1Type>::StorageKind>,
88 {
89  public:
93 
94  typedef typename CwiseTernaryOpImpl<
95  TernaryOp, Arg1Type, Arg2Type, Arg3Type,
98 
99  typedef typename internal::ref_selector<Arg1Type>::type Arg1Nested;
100  typedef typename internal::ref_selector<Arg2Type>::type Arg2Nested;
101  typedef typename internal::ref_selector<Arg3Type>::type Arg3Nested;
102  typedef typename internal::remove_reference<Arg1Nested>::type _Arg1Nested;
103  typedef typename internal::remove_reference<Arg2Nested>::type _Arg2Nested;
104  typedef typename internal::remove_reference<Arg3Nested>::type _Arg3Nested;
105 
108  const Arg3& a3,
109  const TernaryOp& func = TernaryOp())
110  : m_arg1(a1), m_arg2(a2), m_arg3(a3), m_functor(func) {
111  // require the sizes to match
114 
115  // The index types should match
119  STORAGE_KIND_MUST_MATCH)
123  STORAGE_KIND_MUST_MATCH)
124 
125  eigen_assert(a1.rows() == a2.rows() && a1.cols() == a2.cols() &&
126  a1.rows() == a3.rows() && a1.cols() == a3.cols());
127  }
128 
131  // return the fixed size type if available to enable compile time
132  // optimizations
134  RowsAtCompileTime == Dynamic &&
136  RowsAtCompileTime == Dynamic)
137  return m_arg3.rows();
139  RowsAtCompileTime == Dynamic &&
141  RowsAtCompileTime == Dynamic)
142  return m_arg2.rows();
143  else
144  return m_arg1.rows();
145  }
148  // return the fixed size type if available to enable compile time
149  // optimizations
151  ColsAtCompileTime == Dynamic &&
153  ColsAtCompileTime == Dynamic)
154  return m_arg3.cols();
156  ColsAtCompileTime == Dynamic &&
158  ColsAtCompileTime == Dynamic)
159  return m_arg2.cols();
160  else
161  return m_arg1.cols();
162  }
163 
166  const _Arg1Nested& arg1() const { return m_arg1; }
169  const _Arg2Nested& arg2() const { return m_arg2; }
172  const _Arg3Nested& arg3() const { return m_arg3; }
175  const TernaryOp& functor() const { return m_functor; }
176 
177  protected:
181  const TernaryOp m_functor;
182 };
183 
184 // Generic API dispatcher
185 template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3,
186  typename StorageKind>
187 class CwiseTernaryOpImpl
189  CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >::type {
190  public:
191  typedef typename internal::generic_xpr_base<
193 };
194 
195 } // end namespace Eigen
196 
197 #endif // EIGEN_CWISE_TERNARY_OP_H
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::_Arg3Nested
remove_reference< Arg3Nested >::type _Arg3Nested
Definition: CwiseTernaryOp.h:46
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::CwiseTernaryOp::m_arg2
Arg2Nested m_arg2
Definition: CwiseTernaryOp.h:179
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::Arg3Nested
Arg3::Nested Arg3Nested
Definition: CwiseTernaryOp.h:43
eigen_assert
#define eigen_assert(x)
Definition: Macros.h:1037
Eigen::CwiseTernaryOp::Arg1
internal::remove_all< Arg1Type >::type Arg1
Definition: CwiseTernaryOp.h:90
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::Arg1Nested
Arg1::Nested Arg1Nested
Definition: CwiseTernaryOp.h:41
Eigen::RowMajorBit
const unsigned int RowMajorBit
Definition: Constants.h:66
type
Definition: pytypes.h:1525
Eigen::CwiseTernaryOp::functor
const EIGEN_DEVICE_FUNC TernaryOp & functor() const
Definition: CwiseTernaryOp.h:175
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::_Arg2Nested
remove_reference< Arg2Nested >::type _Arg2Nested
Definition: CwiseTernaryOp.h:45
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::StorageIndex
internal::traits< Arg1 >::StorageIndex StorageIndex
Definition: CwiseTernaryOp.h:39
align_3::a1
Point2 a1
Definition: testPose2.cpp:769
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::Ancestor
remove_all< Arg1 >::type Ancestor
Definition: CwiseTernaryOp.h:22
Eigen::internal::true_type
Definition: Meta.h:96
Eigen::CwiseTernaryOp::Arg3
internal::remove_all< Arg3Type >::type Arg3
Definition: CwiseTernaryOp.h:92
align_3::a3
Point2 a3
Definition: testPose2.cpp:771
EIGEN_GENERIC_PUBLIC_INTERFACE
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1264
Eigen::CwiseTernaryOp::arg1
const EIGEN_DEVICE_FUNC _Arg1Nested & arg1() const
Definition: CwiseTernaryOp.h:166
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
Eigen::CwiseTernaryOpImpl::Base
internal::generic_xpr_base< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::type Base
Definition: CwiseTernaryOp.h:192
Eigen::internal::generic_xpr_base
Definition: XprHelper.h:501
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE
#define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:192
Eigen::Triplet< double >
Eigen::CwiseTernaryOp::Arg2
internal::remove_all< Arg2Type >::type Arg2
Definition: CwiseTernaryOp.h:91
Eigen::CwiseTernaryOp::arg2
const EIGEN_DEVICE_FUNC _Arg2Nested & arg2() const
Definition: CwiseTernaryOp.h:169
Eigen::CwiseTernaryOp::m_functor
const TernaryOp m_functor
Definition: CwiseTernaryOp.h:181
Eigen::CwiseTernaryOp::cols
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const
Definition: CwiseTernaryOp.h:147
Eigen::CwiseTernaryOp::arg3
const EIGEN_DEVICE_FUNC _Arg3Nested & arg3() const
Definition: CwiseTernaryOp.h:172
Eigen::CwiseTernaryOp
Generic expression where a coefficient-wise ternary operator is applied to two expressions.
Definition: CwiseTernaryOp.h:84
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::Scalar
result_of< TernaryOp(const typename Arg1::Scalar &, const typename Arg2::Scalar &, const typename Arg3::Scalar &)>::type Scalar
Definition: CwiseTernaryOp.h:36
Eigen::CwiseTernaryOp::rows
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const
Definition: CwiseTernaryOp.h:130
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::StorageKind
internal::traits< Arg1 >::StorageKind StorageKind
Definition: CwiseTernaryOp.h:38
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::_Arg1Nested
remove_reference< Arg1Nested >::type _Arg1Nested
Definition: CwiseTernaryOp.h:44
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::CwiseTernaryOp::m_arg3
Arg3Nested m_arg3
Definition: CwiseTernaryOp.h:180
EIGEN_STATIC_ASSERT
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:127
Eigen::CwiseTernaryOp::m_arg1
Arg1Nested m_arg1
Definition: CwiseTernaryOp.h:178
align_3::a2
Point2 a2
Definition: testPose2.cpp:770
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::XprKind
traits< Ancestor >::XprKind XprKind
Definition: CwiseTernaryOp.h:23
Eigen::internal::result_of
Definition: Meta.h:513
Eigen::internal::traits< CwiseTernaryOp< TernaryOp, Arg1, Arg2, Arg3 > >::Arg2Nested
Arg2::Nested Arg2Nested
Definition: CwiseTernaryOp.h:42
Eigen::CwiseTernaryOp::Base
CwiseTernaryOpImpl< TernaryOp, Arg1Type, Arg2Type, Arg3Type, typename internal::traits< Arg1Type >::StorageKind >::Base Base
Definition: CwiseTernaryOp.h:96
Eigen::internal::is_same
Definition: Meta.h:148
Eigen::internal::no_assignment_operator
Definition: XprHelper.h:109
internal
Definition: BandTriangularSolver.h:13
func
Definition: benchGeometry.cpp:23
test_callbacks.value
value
Definition: test_callbacks.py:160
Eigen::CwiseTernaryOpImpl
Definition: CwiseTernaryOp.h:53
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:18