mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-14 20:56:00 +08:00
oops, didn't want to commit that
This commit is contained in:
parent
c8a22dbc08
commit
47fc3858b9
@ -103,7 +103,7 @@ inline bool ei_isApproxOrLessThan(int a, int b, int = precision<int>())
|
|||||||
*** float ***
|
*** float ***
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
template<> inline float precision<float>() { return 1e-4f; }
|
template<> inline float precision<float>() { return 1e-5f; }
|
||||||
template<> inline float machine_epsilon<float>() { return 1.192e-07f; }
|
template<> inline float machine_epsilon<float>() { return 1.192e-07f; }
|
||||||
inline float ei_real(float x) { return x; }
|
inline float ei_real(float x) { return x; }
|
||||||
inline float ei_imag(float) { return 0.f; }
|
inline float ei_imag(float) { return 0.f; }
|
||||||
@ -149,7 +149,7 @@ inline bool ei_isApproxOrLessThan(float a, float b, float prec = precision<float
|
|||||||
*** double ***
|
*** double ***
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
template<> inline double precision<double>() { return 1e-13; }
|
template<> inline double precision<double>() { return 1e-11; }
|
||||||
template<> inline double machine_epsilon<double>() { return 2.220e-16; }
|
template<> inline double machine_epsilon<double>() { return 2.220e-16; }
|
||||||
|
|
||||||
inline double ei_real(double x) { return x; }
|
inline double ei_real(double x) { return x; }
|
||||||
|
@ -96,7 +96,7 @@ template<typename MatrixType> class LU
|
|||||||
*
|
*
|
||||||
* \param matrix the matrix of which to compute the LU decomposition.
|
* \param matrix the matrix of which to compute the LU decomposition.
|
||||||
*/
|
*/
|
||||||
LU(const MatrixType& matrix, const RealScalar& precision = precision<Scalar>());
|
LU(const MatrixType& matrix);
|
||||||
|
|
||||||
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
|
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
|
||||||
* unit-lower-triangular part is L (at least for square matrices; in the non-square
|
* unit-lower-triangular part is L (at least for square matrices; in the non-square
|
||||||
@ -323,16 +323,14 @@ template<typename MatrixType> class LU
|
|||||||
IntRowVectorType m_q;
|
IntRowVectorType m_q;
|
||||||
int m_det_pq;
|
int m_det_pq;
|
||||||
int m_rank;
|
int m_rank;
|
||||||
RealScalar m_precision;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
LU<MatrixType>::LU(const MatrixType& matrix, const RealScalar& precision)
|
LU<MatrixType>::LU(const MatrixType& matrix)
|
||||||
: m_originalMatrix(matrix),
|
: m_originalMatrix(matrix),
|
||||||
m_lu(matrix),
|
m_lu(matrix),
|
||||||
m_p(matrix.rows()),
|
m_p(matrix.rows()),
|
||||||
m_q(matrix.cols()),
|
m_q(matrix.cols())
|
||||||
m_precision(precision)
|
|
||||||
{
|
{
|
||||||
const int size = matrix.diagonal().size();
|
const int size = matrix.diagonal().size();
|
||||||
const int rows = matrix.rows();
|
const int rows = matrix.rows();
|
||||||
@ -357,7 +355,7 @@ LU<MatrixType>::LU(const MatrixType& matrix, const RealScalar& precision)
|
|||||||
if(k==0) biggest = biggest_in_corner;
|
if(k==0) biggest = biggest_in_corner;
|
||||||
|
|
||||||
// if the corner is negligible, then we have less than full rank, and we can finish early
|
// if the corner is negligible, then we have less than full rank, and we can finish early
|
||||||
if(ei_isMuchSmallerThan(biggest_in_corner, biggest, m_precision))
|
if(ei_isMuchSmallerThan(biggest_in_corner, biggest))
|
||||||
{
|
{
|
||||||
m_rank = k;
|
m_rank = k;
|
||||||
for(int i = k; i < size; i++)
|
for(int i = k; i < size; i++)
|
||||||
@ -508,7 +506,7 @@ bool LU<MatrixType>::solve(
|
|||||||
RealScalar biggest_in_c = c.corner(TopLeft, m_rank, c.cols()).cwise().abs().maxCoeff();
|
RealScalar biggest_in_c = c.corner(TopLeft, m_rank, c.cols()).cwise().abs().maxCoeff();
|
||||||
for(int col = 0; col < c.cols(); ++col)
|
for(int col = 0; col < c.cols(); ++col)
|
||||||
for(int row = m_rank; row < c.rows(); ++row)
|
for(int row = m_rank; row < c.rows(); ++row)
|
||||||
if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c, m_precision))
|
if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_lu.corner(TopLeft, m_rank, m_rank)
|
m_lu.corner(TopLeft, m_rank, m_rank)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user