Eigen  5.0.1
 
Loading...
Searching...
No Matches
Select.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_SELECT_H
12#define EIGEN_SELECT_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
33template <typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
37 ThenMatrixType, ElseMatrixType, ConditionMatrixType>;
38
47template <typename Derived>
48template <typename ThenDerived, typename ElseDerived>
49inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp<
50 internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar, typename DenseBase<ElseDerived>::Scalar,
52 ThenDerived, ElseDerived, Derived>
53DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix, const DenseBase<ElseDerived>& elseMatrix) const {
54 return Select<Derived, ThenDerived, ElseDerived>(thenMatrix.derived(), elseMatrix.derived(), derived());
55}
56
61template <typename Derived>
62template <typename ThenDerived>
63inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp<
64 internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar, typename DenseBase<ThenDerived>::Scalar,
66 ThenDerived, typename DenseBase<ThenDerived>::ConstantReturnType, Derived>
67DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
68 const typename DenseBase<ThenDerived>::Scalar& elseScalar) const {
69 using ElseConstantType = typename DenseBase<ThenDerived>::ConstantReturnType;
70 return Select<Derived, ThenDerived, ElseConstantType>(thenMatrix.derived(),
71 ElseConstantType(rows(), cols(), elseScalar), derived());
72}
73
78template <typename Derived>
79template <typename ElseDerived>
80inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp<
81 internal::scalar_boolean_select_op<typename DenseBase<ElseDerived>::Scalar, typename DenseBase<ElseDerived>::Scalar,
83 typename DenseBase<ElseDerived>::ConstantReturnType, ElseDerived, Derived>
84DenseBase<Derived>::select(const typename DenseBase<ElseDerived>::Scalar& thenScalar,
85 const DenseBase<ElseDerived>& elseMatrix) const {
86 using ThenConstantType = typename DenseBase<ElseDerived>::ConstantReturnType;
87 return Select<Derived, ThenConstantType, ElseDerived>(ThenConstantType(rows(), cols(), thenScalar),
88 elseMatrix.derived(), derived());
89}
90
91} // end namespace Eigen
92
93#endif // EIGEN_SELECT_H
Generic expression where a coefficient-wise ternary operator is applied to three expressions.
Definition CwiseTernaryOp.h:87
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:45
typename internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:63
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ThenMatrixType >::Scalar, typename DenseBase< ElseMatrixType >::Scalar, typename DenseBase< ConditionMatrixType >::Scalar >, ThenMatrixType, ElseMatrixType, ConditionMatrixType > Select
Expression of a coefficient wise version of the C++ ternary operator ?:
Definition Select.h:34