mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-18 14:45:55 +08:00
Make select CUDA compatible (comparison operators aren't yet, so no test case yet)
This commit is contained in:
parent
e5f134006b
commit
883168ed94
@ -859,7 +859,7 @@ struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
|
|||||||
Flags = (unsigned int)evaluator<ThenMatrixType>::Flags & evaluator<ElseMatrixType>::Flags & HereditaryBits
|
Flags = (unsigned int)evaluator<ThenMatrixType>::Flags & evaluator<ElseMatrixType>::Flags & HereditaryBits
|
||||||
};
|
};
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& select)
|
inline EIGEN_DEVICE_FUNC explicit evaluator(const XprType& select)
|
||||||
: m_conditionImpl(select.conditionMatrix()),
|
: m_conditionImpl(select.conditionMatrix()),
|
||||||
m_thenImpl(select.thenMatrix()),
|
m_thenImpl(select.thenMatrix()),
|
||||||
m_elseImpl(select.elseMatrix())
|
m_elseImpl(select.elseMatrix())
|
||||||
@ -868,7 +868,7 @@ struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
|
|||||||
typedef typename XprType::Index Index;
|
typedef typename XprType::Index Index;
|
||||||
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const
|
inline EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const
|
||||||
{
|
{
|
||||||
if (m_conditionImpl.coeff(row, col))
|
if (m_conditionImpl.coeff(row, col))
|
||||||
return m_thenImpl.coeff(row, col);
|
return m_thenImpl.coeff(row, col);
|
||||||
@ -876,7 +876,7 @@ struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
|
|||||||
return m_elseImpl.coeff(row, col);
|
return m_elseImpl.coeff(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index index) const
|
inline EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index index) const
|
||||||
{
|
{
|
||||||
if (m_conditionImpl.coeff(index))
|
if (m_conditionImpl.coeff(index))
|
||||||
return m_thenImpl.coeff(index);
|
return m_thenImpl.coeff(index);
|
||||||
|
@ -57,6 +57,7 @@ class Select : internal::no_assignment_operator,
|
|||||||
typedef typename internal::dense_xpr_base<Select>::type Base;
|
typedef typename internal::dense_xpr_base<Select>::type Base;
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Select)
|
EIGEN_DENSE_PUBLIC_INTERFACE(Select)
|
||||||
|
|
||||||
|
inline EIGEN_DEVICE_FUNC
|
||||||
Select(const ConditionMatrixType& a_conditionMatrix,
|
Select(const ConditionMatrixType& a_conditionMatrix,
|
||||||
const ThenMatrixType& a_thenMatrix,
|
const ThenMatrixType& a_thenMatrix,
|
||||||
const ElseMatrixType& a_elseMatrix)
|
const ElseMatrixType& a_elseMatrix)
|
||||||
@ -66,9 +67,10 @@ class Select : internal::no_assignment_operator,
|
|||||||
eigen_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());
|
eigen_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());
|
||||||
}
|
}
|
||||||
|
|
||||||
Index rows() const { return m_condition.rows(); }
|
inline EIGEN_DEVICE_FUNC Index rows() const { return m_condition.rows(); }
|
||||||
Index cols() const { return m_condition.cols(); }
|
inline EIGEN_DEVICE_FUNC Index cols() const { return m_condition.cols(); }
|
||||||
|
|
||||||
|
inline EIGEN_DEVICE_FUNC
|
||||||
const Scalar coeff(Index i, Index j) const
|
const Scalar coeff(Index i, Index j) const
|
||||||
{
|
{
|
||||||
if (m_condition.coeff(i,j))
|
if (m_condition.coeff(i,j))
|
||||||
@ -77,6 +79,7 @@ class Select : internal::no_assignment_operator,
|
|||||||
return m_else.coeff(i,j);
|
return m_else.coeff(i,j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline EIGEN_DEVICE_FUNC
|
||||||
const Scalar coeff(Index i) const
|
const Scalar coeff(Index i) const
|
||||||
{
|
{
|
||||||
if (m_condition.coeff(i))
|
if (m_condition.coeff(i))
|
||||||
@ -85,17 +88,17 @@ class Select : internal::no_assignment_operator,
|
|||||||
return m_else.coeff(i);
|
return m_else.coeff(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConditionMatrixType& conditionMatrix() const
|
inline EIGEN_DEVICE_FUNC const ConditionMatrixType& conditionMatrix() const
|
||||||
{
|
{
|
||||||
return m_condition;
|
return m_condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ThenMatrixType& thenMatrix() const
|
inline EIGEN_DEVICE_FUNC const ThenMatrixType& thenMatrix() const
|
||||||
{
|
{
|
||||||
return m_then;
|
return m_then;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ElseMatrixType& elseMatrix() const
|
inline EIGEN_DEVICE_FUNC const ElseMatrixType& elseMatrix() const
|
||||||
{
|
{
|
||||||
return m_else;
|
return m_else;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user