mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-04 04:05:19 +08:00
Try to avoid modulo operations in Replicate if possible.
This commit is contained in:
parent
b9644f3323
commit
fc20e6fd55
@ -90,6 +90,13 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
|
|||||||
|
|
||||||
inline Scalar coeff(int row, int col) const
|
inline Scalar coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
|
// try to avoid using modulo; this is a pure optimization strategy
|
||||||
|
// - it is assumed unlikely that RowFactor==1 && ColFactor==1
|
||||||
|
if (RowFactor==1)
|
||||||
|
return m_matrix.coeff(m_matrix.rows(), col%m_matrix.cols());
|
||||||
|
else if (ColFactor==1)
|
||||||
|
return m_matrix.coeff(row%m_matrix.rows(), m_matrix.cols());
|
||||||
|
else
|
||||||
return m_matrix.coeff(row%m_matrix.rows(), col%m_matrix.cols());
|
return m_matrix.coeff(row%m_matrix.rows(), col%m_matrix.cols());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user