Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
MatrixCwiseBinaryOps.inc
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2009 Gael Guennebaud <[email protected]>
5// Copyright (C) 2006-2008 Benoit Jacob <[email protected]>
6//
7// This Source Code Form is subject to the terms of the Mozilla
8// Public License v. 2.0. If a copy of the MPL was not distributed
9// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
11// This file is a base class plugin containing matrix specifics coefficient wise functions.
12
20template <typename OtherDerived>
21EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product)
22 cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
23 return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product)(derived(), other.derived());
24}
25
26template <typename OtherDerived>
27using CwiseBinaryEqualReturnType =
28 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>, const Derived, const OtherDerived>;
29template <typename OtherDerived>
30using CwiseBinaryNotEqualReturnType =
31 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>, const Derived, const OtherDerived>;
32template <typename OtherDerived>
33using CwiseBinaryLessReturnType =
34 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>, const Derived, const OtherDerived>;
35template <typename OtherDerived>
36using CwiseBinaryGreaterReturnType =
37 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>, const Derived, const OtherDerived>;
38template <typename OtherDerived>
39using CwiseBinaryLessOrEqualReturnType =
40 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>, const Derived, const OtherDerived>;
41template <typename OtherDerived>
42using CwiseBinaryGreaterOrEqualReturnType =
43 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>, const Derived, const OtherDerived>;
44
57template <typename OtherDerived>
58EIGEN_DEVICE_FUNC inline const CwiseBinaryEqualReturnType<OtherDerived> cwiseEqual(
59 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
60 return CwiseBinaryEqualReturnType<OtherDerived>(derived(), other.derived());
61}
62
75template <typename OtherDerived>
76EIGEN_DEVICE_FUNC inline const CwiseBinaryNotEqualReturnType<OtherDerived> cwiseNotEqual(
77 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
78 return CwiseBinaryNotEqualReturnType<OtherDerived>(derived(), other.derived());
79}
80
82template <typename OtherDerived>
83EIGEN_DEVICE_FUNC inline const CwiseBinaryLessReturnType<OtherDerived> cwiseLess(
84 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
85 return CwiseBinaryLessReturnType<OtherDerived>(derived(), other.derived());
86}
87
89template <typename OtherDerived>
90EIGEN_DEVICE_FUNC inline const CwiseBinaryGreaterReturnType<OtherDerived> cwiseGreater(
91 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
92 return CwiseBinaryGreaterReturnType<OtherDerived>(derived(), other.derived());
93}
94
96template <typename OtherDerived>
97EIGEN_DEVICE_FUNC inline const CwiseBinaryLessOrEqualReturnType<OtherDerived> cwiseLessOrEqual(
98 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
99 return CwiseBinaryLessOrEqualReturnType<OtherDerived>(derived(), other.derived());
100}
101
103template <typename OtherDerived>
104EIGEN_DEVICE_FUNC inline const CwiseBinaryGreaterOrEqualReturnType<OtherDerived> cwiseGreaterOrEqual(
105 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
106 return CwiseBinaryGreaterOrEqualReturnType<OtherDerived>(derived(), other.derived());
107}
108
116template <int NaNPropagation = PropagateFast, typename OtherDerived>
117EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const
118 CwiseBinaryOp<internal::scalar_min_op<Scalar, Scalar, NaNPropagation>, const Derived, const OtherDerived>
119 cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
120 return CwiseBinaryOp<internal::scalar_min_op<Scalar, Scalar, NaNPropagation>, const Derived, const OtherDerived>(
121 derived(), other.derived());
122}
123
128template <int NaNPropagation = PropagateFast>
129EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const
130 CwiseBinaryOp<internal::scalar_min_op<Scalar, Scalar, NaNPropagation>, const Derived, const ConstantReturnType>
131 cwiseMin(const Scalar& other) const {
132 return cwiseMin<NaNPropagation>(Derived::Constant(rows(), cols(), other));
133}
134
142template <int NaNPropagation = PropagateFast, typename OtherDerived>
143EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const
144 CwiseBinaryOp<internal::scalar_max_op<Scalar, Scalar, NaNPropagation>, const Derived, const OtherDerived>
145 cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
146 return CwiseBinaryOp<internal::scalar_max_op<Scalar, Scalar, NaNPropagation>, const Derived, const OtherDerived>(
147 derived(), other.derived());
148}
149
154template <int NaNPropagation = PropagateFast>
155EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const
156 CwiseBinaryOp<internal::scalar_max_op<Scalar, Scalar, NaNPropagation>, const Derived, const ConstantReturnType>
157 cwiseMax(const Scalar& other) const {
158 return cwiseMax<NaNPropagation>(Derived::Constant(rows(), cols(), other));
159}
160
168template <typename OtherDerived>
169EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const
170 CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>
171 cwiseQuotient(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
172 return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(),
173 other.derived());
174}
175
176using CwiseScalarEqualReturnType =
177 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ>, const Derived, const ConstantReturnType>;
178using CwiseScalarNotEqualReturnType =
179 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ>, const Derived, const ConstantReturnType>;
180using CwiseScalarLessReturnType =
181 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT>, const Derived, const ConstantReturnType>;
182using CwiseScalarGreaterReturnType =
183 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT>, const Derived, const ConstantReturnType>;
184using CwiseScalarLessOrEqualReturnType =
185 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE>, const Derived, const ConstantReturnType>;
186using CwiseScalarGreaterOrEqualReturnType =
187 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE>, const Derived, const ConstantReturnType>;
188
198EIGEN_DEVICE_FUNC inline const CwiseScalarEqualReturnType cwiseEqual(const Scalar& s) const {
199 return CwiseScalarEqualReturnType(derived(), Derived::Constant(rows(), cols(), s));
200}
201
211EIGEN_DEVICE_FUNC inline const CwiseScalarNotEqualReturnType cwiseNotEqual(const Scalar& s) const {
212 return CwiseScalarNotEqualReturnType(derived(), Derived::Constant(rows(), cols(), s));
213}
214
216EIGEN_DEVICE_FUNC inline const CwiseScalarLessReturnType cwiseLess(const Scalar& s) const {
217 return CwiseScalarLessReturnType(derived(), Derived::Constant(rows(), cols(), s));
218}
219
221EIGEN_DEVICE_FUNC inline const CwiseScalarGreaterReturnType cwiseGreater(const Scalar& s) const {
222 return CwiseScalarGreaterReturnType(derived(), Derived::Constant(rows(), cols(), s));
223}
224
226EIGEN_DEVICE_FUNC inline const CwiseScalarLessOrEqualReturnType cwiseLessOrEqual(const Scalar& s) const {
227 return CwiseScalarLessOrEqualReturnType(derived(), Derived::Constant(rows(), cols(), s));
228}
229
231EIGEN_DEVICE_FUNC inline const CwiseScalarGreaterOrEqualReturnType cwiseGreaterOrEqual(const Scalar& s) const {
232 return CwiseScalarGreaterOrEqualReturnType(derived(), Derived::Constant(rows(), cols(), s));
233}
234
235template <typename OtherDerived>
236using CwiseBinaryTypedEqualReturnType =
237 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ, true>, const Derived, const OtherDerived>;
238template <typename OtherDerived>
239using CwiseBinaryTypedNotEqualReturnType =
240 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ, true>, const Derived, const OtherDerived>;
241template <typename OtherDerived>
242using CwiseBinaryTypedLessReturnType =
243 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT, true>, const Derived, const OtherDerived>;
244template <typename OtherDerived>
245using CwiseBinaryTypedGreaterReturnType =
246 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT, true>, const Derived, const OtherDerived>;
247template <typename OtherDerived>
248using CwiseBinaryTypedLessOrEqualReturnType =
249 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE, true>, const Derived, const OtherDerived>;
250template <typename OtherDerived>
251using CwiseBinaryTypedGreaterOrEqualReturnType =
252 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE, true>, const Derived, const OtherDerived>;
253
254template <typename OtherDerived>
255EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedEqualReturnType<OtherDerived> cwiseTypedEqual(
256 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
257 return CwiseBinaryTypedEqualReturnType<OtherDerived>(derived(), other.derived());
258}
259
260template <typename OtherDerived>
261EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedNotEqualReturnType<OtherDerived> cwiseTypedNotEqual(
262 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
263 return CwiseBinaryTypedNotEqualReturnType<OtherDerived>(derived(), other.derived());
264}
265
266template <typename OtherDerived>
267EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedLessReturnType<OtherDerived> cwiseTypedLess(
268 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
269 return CwiseBinaryTypedLessReturnType<OtherDerived>(derived(), other.derived());
270}
271
272template <typename OtherDerived>
273EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedGreaterReturnType<OtherDerived> cwiseTypedGreater(
274 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
275 return CwiseBinaryTypedGreaterReturnType<OtherDerived>(derived(), other.derived());
276}
277
278template <typename OtherDerived>
279EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedLessOrEqualReturnType<OtherDerived> cwiseTypedLessOrEqual(
280 const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
281 return CwiseBinaryTypedLessOrEqualReturnType<OtherDerived>(derived(), other.derived());
282}
283
284template <typename OtherDerived>
285EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedGreaterOrEqualReturnType<OtherDerived>
286cwiseTypedGreaterOrEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived>& other) const {
287 return CwiseBinaryTypedGreaterOrEqualReturnType<OtherDerived>(derived(), other.derived());
288}
289
290using CwiseScalarTypedEqualReturnType = CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ, true>,
291 const Derived, const ConstantReturnType>;
292using CwiseScalarTypedNotEqualReturnType =
293 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ, true>, const Derived,
294 const ConstantReturnType>;
295using CwiseScalarTypedLessReturnType = CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LT, true>,
296 const Derived, const ConstantReturnType>;
297using CwiseScalarTypedGreaterReturnType = CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GT, true>,
298 const Derived, const ConstantReturnType>;
299using CwiseScalarTypedLessOrEqualReturnType =
300 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_LE, true>, const Derived,
301 const ConstantReturnType>;
302using CwiseScalarTypedGreaterOrEqualReturnType =
303 CwiseBinaryOp<internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE, true>, const Derived,
304 const ConstantReturnType>;
305
306EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedEqualReturnType cwiseTypedEqual(const Scalar& s) const {
307 return CwiseScalarTypedEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s));
308}
309
310EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedNotEqualReturnType
311cwiseTypedNotEqual(const Scalar& s) const {
312 return CwiseScalarTypedNotEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s));
313}
314
315EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedLessReturnType cwiseTypedLess(const Scalar& s) const {
316 return CwiseScalarTypedLessReturnType(derived(), ConstantReturnType(rows(), cols(), s));
317}
318
319EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedGreaterReturnType cwiseTypedGreater(const Scalar& s) const {
320 return CwiseScalarTypedGreaterReturnType(derived(), ConstantReturnType(rows(), cols(), s));
321}
322
323EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedLessOrEqualReturnType
324cwiseTypedLessOrEqual(const Scalar& s) const {
325 return CwiseScalarTypedLessOrEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s));
326}
327
328EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedGreaterOrEqualReturnType
329cwiseTypedGreaterOrEqual(const Scalar& s) const {
330 return CwiseScalarTypedGreaterOrEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s));
331}