Fixed 64bit/Index related warnings in the matrix functions module.

This commit is contained in:
Hauke Heibel 2010-06-15 09:57:41 +02:00
parent 0afb1e80c7
commit e5aa6a466b
3 changed files with 13 additions and 11 deletions

View File

@ -39,7 +39,8 @@ class MatrixFunction
{
private:
typedef typename ei_traits<MatrixType>::Scalar Scalar;
typedef typename ei_traits<MatrixType>::Index Index;
typedef typename ei_traits<MatrixType>::Scalar Scalar;
typedef typename ei_stem_function<Scalar>::type StemFunction;
public:
@ -141,6 +142,7 @@ class MatrixFunction<MatrixType, 1>
typedef typename ei_stem_function<Scalar>::type StemFunction;
typedef Matrix<Scalar, Traits::RowsAtCompileTime, 1> VectorType;
typedef Matrix<Index, Traits::RowsAtCompileTime, 1> IntVectorType;
typedef Matrix<Index, Traits::RowsAtCompileTime, 1> DynamicIntVectorType;
typedef std::list<Scalar> Cluster;
typedef std::list<Cluster> ListOfClusters;
typedef Matrix<Scalar, Dynamic, Dynamic, Options, RowsAtCompileTime, ColsAtCompileTime> DynMatrixType;
@ -171,9 +173,9 @@ class MatrixFunction<MatrixType, 1>
MatrixType m_U; /**< \brief Unitary part of Schur decomposition */
MatrixType m_fT; /**< \brief %Matrix function applied to #m_T */
ListOfClusters m_clusters; /**< \brief Partition of eigenvalues into clusters of ei'vals "close" to each other */
VectorXi m_eivalToCluster; /**< \brief m_eivalToCluster[i] = j means i-th ei'val is in j-th cluster */
VectorXi m_clusterSize; /**< \brief Number of eigenvalues in each clusters */
VectorXi m_blockStart; /**< \brief Row index at which block corresponding to i-th cluster starts */
DynamicIntVectorType m_eivalToCluster; /**< \brief m_eivalToCluster[i] = j means i-th ei'val is in j-th cluster */
DynamicIntVectorType m_clusterSize; /**< \brief Number of eigenvalues in each clusters */
DynamicIntVectorType m_blockStart; /**< \brief Row index at which block corresponding to i-th cluster starts */
IntVectorType m_permutation; /**< \brief Permutation which groups ei'vals in the same cluster together */
/** \brief Maximum distance allowed between eigenvalues to be considered "close".
@ -302,8 +304,8 @@ void MatrixFunction<MatrixType,1>::computeClusterSize()
for (typename ListOfClusters::const_iterator cluster = m_clusters.begin(); cluster != m_clusters.end(); ++cluster) {
for (Index i = 0; i < diag.rows(); ++i) {
if (std::find(cluster->begin(), cluster->end(), diag(i)) != cluster->end()) {
++m_clusterSize[clusterIndex];
m_eivalToCluster[i] = clusterIndex;
++m_clusterSize[clusterIndex];
m_eivalToCluster[i] = clusterIndex;
}
}
++clusterIndex;
@ -325,7 +327,7 @@ void MatrixFunction<MatrixType,1>::computeBlockStart()
template <typename MatrixType>
void MatrixFunction<MatrixType,1>::constructPermutation()
{
VectorXi indexNextEntry = m_blockStart;
DynamicIntVectorType indexNextEntry = m_blockStart;
m_permutation.resize(m_T.rows());
for (Index i = 0; i < m_T.rows(); i++) {
Index cluster = m_eivalToCluster[i];

View File

@ -92,7 +92,7 @@ MatrixType MatrixFunctionAtomic<MatrixType>::compute(const MatrixType& A)
MatrixType P = m_Ashifted;
MatrixType Fincr;
for (Index s = 1; s < 1.1 * m_Arows + 10; s++) { // upper limit is fairly arbitrary
Fincr = m_f(m_avgEival, s) * P;
Fincr = m_f(m_avgEival, static_cast<int>(s)) * P;
F += Fincr;
P = Scalar(RealScalar(1.0/(s + 1))) * P * m_Ashifted;
if (taylorConverged(s, F, Fincr, P)) {
@ -127,7 +127,7 @@ bool MatrixFunctionAtomic<MatrixType>::taylorConverged(Index s, const MatrixType
for (Index r = 0; r < n; r++) {
RealScalar mx = 0;
for (Index i = 0; i < n; i++)
mx = std::max(mx, std::abs(m_f(m_Ashifted(i, i) + m_avgEival, s+r)));
mx = std::max(mx, std::abs(m_f(m_Ashifted(i, i) + m_avgEival, static_cast<int>(s+r))));
if (r != 0)
rfactorial *= RealScalar(r);
delta = std::max(delta, mx / rfactorial);

View File

@ -122,8 +122,8 @@ void randomTest(const MatrixType& m, double tol)
/* this test covers the following files:
Inverse.h
*/
int rows = m.rows();
int cols = m.cols();
MatrixType::Index rows = m.rows();
MatrixType::Index cols = m.cols();
MatrixType m1(rows, cols), m2(rows, cols), m3(rows, cols),
identity = MatrixType::Identity(rows, rows);