10 #ifndef EIGEN_ITERSCALING_H
11 #define EIGEN_ITERSCALING_H
47 template<
typename _MatrixType>
78 eigen_assert((m>0 && m ==
n) &&
"Please give a non - empty matrix");
84 VectorXd Dr, Dc, DrRes, DcRes;
85 Dr.resize(m); Dc.resize(
n);
86 DrRes.resize(m); DcRes.resize(
n);
87 double EpsRow = 1.0, EpsCol = 1.0;
92 Dr.setZero(); Dc.setZero();
93 for (
int k=0; k<
m_matrix.outerSize(); ++k)
95 for (
typename MatrixType::InnerIterator it(
m_matrix, k); it; ++it)
97 if ( Dr(it.row()) <
abs(it.value()) )
98 Dr(it.row()) =
abs(it.value());
100 if ( Dc(it.col()) <
abs(it.value()) )
101 Dc(it.col()) =
abs(it.value());
104 for (
int i = 0; i < m; ++i)
110 for (
int i = 0; i < m; ++i)
116 DrRes.setZero(); DcRes.setZero();
117 for (
int k=0; k<
m_matrix.outerSize(); ++k)
119 for (
typename MatrixType::InnerIterator it(
m_matrix, k); it; ++it)
121 it.valueRef() = it.value()/( Dr(it.row()) * Dc(it.col()) );
123 if ( DrRes(it.row()) <
abs(it.value()) )
124 DrRes(it.row()) =
abs(it.value());
126 if ( DcRes(it.col()) <
abs(it.value()) )
127 DcRes(it.col()) =
abs(it.value());
130 DrRes.array() = (1-DrRes.array()).
abs();
131 EpsRow = DrRes.maxCoeff();
132 DcRes.array() = (1-DcRes.array()).
abs();
133 EpsCol = DcRes.maxCoeff();