10 #ifndef EIGEN_ITERSCALING_H
11 #define EIGEN_ITERSCALING_H
49 template<
typename MatrixType_>
54 typedef typename MatrixType::Scalar
Scalar;
55 typedef typename MatrixType::Index
Index;
89 double EpsRow = 1.0, EpsCol = 1.0;
95 for (
int k=0; k<
m_matrix.outerSize(); ++k)
97 for (
typename MatrixType::InnerIterator it(
m_matrix, k); it; ++it)
99 if ( Dr(it.row()) <
abs(it.value()) )
100 Dr(it.row()) =
abs(it.value());
102 if ( Dc(it.col()) <
abs(it.value()) )
103 Dc(it.col()) =
abs(it.value());
106 for (
int i = 0;
i <
m; ++
i)
110 for (
int i = 0;
i <
n; ++
i)
115 for (
int i = 0;
i <
m; ++
i)
119 for (
int i = 0;
i <
n; ++
i)
125 for (
int k=0; k<
m_matrix.outerSize(); ++k)
127 for (
typename MatrixType::InnerIterator it(
m_matrix, k); it; ++it)
129 it.valueRef() = it.value()/( Dr(it.row()) * Dc(it.col()) );
131 if ( DrRes(it.row()) <
abs(it.value()) )
132 DrRes(it.row()) =
abs(it.value());
134 if ( DcRes(it.col()) <
abs(it.value()) )
135 DcRes(it.col()) =
abs(it.value());
138 DrRes.array() = (1-DrRes.array()).
abs();
139 EpsRow = DrRes.maxCoeff();
140 DcRes.array() = (1-DcRes.array()).
abs();
141 EpsCol = DcRes.maxCoeff();
Array< double, 1, 3 > e(1./3., 0.5, 2.)
iterative scaling algorithm to equilibrate rows and column norms in matrices
void setTolerance(double tol)
void compute(const MatrixType &mat)
void computeRef(MatrixType &mat)
MatrixType::Scalar Scalar
VectorXd & RightScaling()
IterScaling(const MatrixType &matrix)
Derived & setZero(Index rows, Index cols)
Derived & setOnes(Index rows, Index cols)
constexpr void resize(Index rows, Index cols)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > sqrt(const Eigen::AutoDiffScalar< DerType > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
adouble abs(const adouble &x)