mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-08 22:21:49 +08:00
backport bugfix in visitor (didn't work on rowvectors, fixed by splitting the vector case away from the matrix case)
This commit is contained in:
parent
aaf1826384
commit
8097487b9d
@ -532,8 +532,11 @@ template<typename Derived> class MatrixBase
|
|||||||
typename ei_traits<Derived>::Scalar minCoeff() const;
|
typename ei_traits<Derived>::Scalar minCoeff() const;
|
||||||
typename ei_traits<Derived>::Scalar maxCoeff() const;
|
typename ei_traits<Derived>::Scalar maxCoeff() const;
|
||||||
|
|
||||||
typename ei_traits<Derived>::Scalar minCoeff(int* row, int* col = 0) const;
|
typename ei_traits<Derived>::Scalar minCoeff(int* row, int* col) const;
|
||||||
typename ei_traits<Derived>::Scalar maxCoeff(int* row, int* col = 0) const;
|
typename ei_traits<Derived>::Scalar maxCoeff(int* row, int* col) const;
|
||||||
|
|
||||||
|
typename ei_traits<Derived>::Scalar minCoeff(int* index) const;
|
||||||
|
typename ei_traits<Derived>::Scalar maxCoeff(int* index) const;
|
||||||
|
|
||||||
template<typename BinaryOp>
|
template<typename BinaryOp>
|
||||||
typename ei_result_of<BinaryOp(typename ei_traits<Derived>::Scalar)>::type
|
typename ei_result_of<BinaryOp(typename ei_traits<Derived>::Scalar)>::type
|
||||||
|
@ -164,7 +164,7 @@ struct ei_functor_traits<ei_max_coeff_visitor<Scalar> > {
|
|||||||
/** \returns the minimum of all coefficients of *this
|
/** \returns the minimum of all coefficients of *this
|
||||||
* and puts in *row and *col its location.
|
* and puts in *row and *col its location.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
|
* \sa MatrixBase::minCoeff(int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
typename ei_traits<Derived>::Scalar
|
typename ei_traits<Derived>::Scalar
|
||||||
@ -177,6 +177,22 @@ MatrixBase<Derived>::minCoeff(int* row, int* col) const
|
|||||||
return minVisitor.res;
|
return minVisitor.res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** \returns the minimum of all coefficients of *this
|
||||||
|
* and puts in *index its location.
|
||||||
|
*
|
||||||
|
* \sa MatrixBase::minCoeff(int*,int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
typename ei_traits<Derived>::Scalar
|
||||||
|
MatrixBase<Derived>::minCoeff(int* index) const
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||||
|
ei_min_coeff_visitor<Scalar> minVisitor;
|
||||||
|
this->visit(minVisitor);
|
||||||
|
*index = (RowsAtCompileTime==1) ? minVisitor.col : minVisitor.row;
|
||||||
|
return minVisitor.res;
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the maximum of all coefficients of *this
|
/** \returns the maximum of all coefficients of *this
|
||||||
* and puts in *row and *col its location.
|
* and puts in *row and *col its location.
|
||||||
*
|
*
|
||||||
@ -193,5 +209,20 @@ MatrixBase<Derived>::maxCoeff(int* row, int* col) const
|
|||||||
return maxVisitor.res;
|
return maxVisitor.res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** \returns the maximum of all coefficients of *this
|
||||||
|
* and puts in *index its location.
|
||||||
|
*
|
||||||
|
* \sa MatrixBase::maxCoeff(int*,int*), MatrixBase::minCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::maxCoeff()
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
typename ei_traits<Derived>::Scalar
|
||||||
|
MatrixBase<Derived>::maxCoeff(int* index) const
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||||
|
ei_max_coeff_visitor<Scalar> maxVisitor;
|
||||||
|
this->visit(maxVisitor);
|
||||||
|
*index = (RowsAtCompileTime==1) ? maxVisitor.col : maxVisitor.row;
|
||||||
|
return maxVisitor.res;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EIGEN_VISITOR_H
|
#endif // EIGEN_VISITOR_H
|
||||||
|
@ -220,6 +220,7 @@ ei_add_test(sparse_basic)
|
|||||||
ei_add_test(sparse_solvers " " "${SPARSE_LIBS}")
|
ei_add_test(sparse_solvers " " "${SPARSE_LIBS}")
|
||||||
ei_add_test(sparse_product)
|
ei_add_test(sparse_product)
|
||||||
ei_add_test(swap)
|
ei_add_test(swap)
|
||||||
|
ei_add_test(visitor)
|
||||||
|
|
||||||
# print a summary of the different options
|
# print a summary of the different options
|
||||||
message("************************************************************")
|
message("************************************************************")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user