mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-02 16:54:10 +08:00
fix compilation and segfault issues
This commit is contained in:
parent
b9b17ea5a5
commit
fa55cf5ce7
@ -217,6 +217,9 @@ struct ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
|
|||||||
: m_lhs(lhs), m_rhs(rhs)
|
: m_lhs(lhs), m_rhs(rhs)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
inline int rows() const { m_lhs.rows(); }
|
||||||
|
inline int cols() const { m_rhs.cols(); }
|
||||||
|
|
||||||
template<typename Dest> void evalTo(Dest& dst) const
|
template<typename Dest> void evalTo(Dest& dst) const
|
||||||
{
|
{
|
||||||
// FIXME investigate how to allow lazy evaluation of this product when possible
|
// FIXME investigate how to allow lazy evaluation of this product when possible
|
||||||
@ -243,6 +246,9 @@ struct ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>
|
|||||||
: m_lhs(lhs), m_rhs(rhs)
|
: m_lhs(lhs), m_rhs(rhs)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
inline int rows() const { m_lhs.rows(); }
|
||||||
|
inline int cols() const { m_rhs.cols(); }
|
||||||
|
|
||||||
template<typename Dest> void evalTo(Dest& dst) const
|
template<typename Dest> void evalTo(Dest& dst) const
|
||||||
{
|
{
|
||||||
// FIXME investigate how to allow lazy evaluation of this product when possible
|
// FIXME investigate how to allow lazy evaluation of this product when possible
|
||||||
|
@ -120,6 +120,7 @@ void HouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
|||||||
int rows = matrix.rows();
|
int rows = matrix.rows();
|
||||||
int cols = matrix.cols();
|
int cols = matrix.cols();
|
||||||
RealScalar eps2 = precision<RealScalar>()*precision<RealScalar>();
|
RealScalar eps2 = precision<RealScalar>()*precision<RealScalar>();
|
||||||
|
Matrix<Scalar,1,MatrixType::ColsAtCompileTime> temp(cols);
|
||||||
|
|
||||||
for (int k = 0; k < cols; ++k)
|
for (int k = 0; k < cols; ++k)
|
||||||
{
|
{
|
||||||
@ -161,8 +162,10 @@ void HouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
|||||||
if (remainingCols>0)
|
if (remainingCols>0)
|
||||||
{
|
{
|
||||||
m_qr.coeffRef(k,k) = Scalar(1);
|
m_qr.coeffRef(k,k) = Scalar(1);
|
||||||
m_qr.corner(BottomRight, remainingSize, remainingCols) -= ei_conj(h) * m_qr.col(k).end(remainingSize)
|
temp.end(remainingCols) = (m_qr.col(k).end(remainingSize).adjoint()
|
||||||
* (m_qr.col(k).end(remainingSize).adjoint() * m_qr.corner(BottomRight, remainingSize, remainingCols));
|
* m_qr.corner(BottomRight, remainingSize, remainingCols)).lazy();
|
||||||
|
m_qr.corner(BottomRight, remainingSize, remainingCols) -= (ei_conj(h) * m_qr.col(k).end(remainingSize)
|
||||||
|
* temp.end(remainingCols)).lazy();
|
||||||
m_qr.coeffRef(k,k) = beta;
|
m_qr.coeffRef(k,k) = beta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,6 +210,7 @@ MatrixType HouseholderQR<MatrixType>::matrixQ() const
|
|||||||
int rows = m_qr.rows();
|
int rows = m_qr.rows();
|
||||||
int cols = m_qr.cols();
|
int cols = m_qr.cols();
|
||||||
MatrixType res = MatrixType::Identity(rows, cols);
|
MatrixType res = MatrixType::Identity(rows, cols);
|
||||||
|
Matrix<Scalar,1,MatrixType::ColsAtCompileTime> temp(cols);
|
||||||
for (int k = cols-1; k >= 0; k--)
|
for (int k = cols-1; k >= 0; k--)
|
||||||
{
|
{
|
||||||
// to make easier the computation of the transformation, let's temporarily
|
// to make easier the computation of the transformation, let's temporarily
|
||||||
@ -214,8 +218,9 @@ MatrixType HouseholderQR<MatrixType>::matrixQ() const
|
|||||||
Scalar beta = m_qr.coeff(k,k);
|
Scalar beta = m_qr.coeff(k,k);
|
||||||
m_qr.const_cast_derived().coeffRef(k,k) = 1;
|
m_qr.const_cast_derived().coeffRef(k,k) = 1;
|
||||||
int endLength = rows-k;
|
int endLength = rows-k;
|
||||||
res.corner(BottomRight,endLength, cols-k) -= ((m_hCoeffs.coeff(k) * m_qr.col(k).end(endLength))
|
|
||||||
* (m_qr.col(k).end(endLength).adjoint() * res.corner(BottomRight,endLength, cols-k)).lazy()).lazy();
|
temp.end(cols-k) = (m_qr.col(k).end(endLength).adjoint() * res.corner(BottomRight,endLength, cols-k)).lazy();
|
||||||
|
res.corner(BottomRight,endLength, cols-k) -= ((m_hCoeffs.coeff(k) * m_qr.col(k).end(endLength)) * temp.end(cols-k)).lazy();
|
||||||
m_qr.const_cast_derived().coeffRef(k,k) = beta;
|
m_qr.const_cast_derived().coeffRef(k,k) = beta;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user