aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen
diff options
context:
space:
mode:
Diffstat (limited to 'unsupported/Eigen')
-rw-r--r--unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h7
-rw-r--r--unsupported/Eigen/src/AutoDiff/AutoDiffVector.h15
-rw-r--r--unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h14
-rw-r--r--unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h5
-rw-r--r--unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h62
-rw-r--r--unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h20
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h30
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h38
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/chkder.h10
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/covar.h8
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/dogleg.h6
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/fdjac1.h16
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/lmpar.h24
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/qrsolv.h8
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h12
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/r1updt.h8
-rw-r--r--unsupported/Eigen/src/NonLinearOptimization/rwupdt.h8
-rw-r--r--unsupported/Eigen/src/Polynomials/Companion.h18
-rw-r--r--unsupported/Eigen/src/Polynomials/PolynomialSolver.h16
-rw-r--r--unsupported/Eigen/src/Polynomials/PolynomialUtils.h14
-rw-r--r--unsupported/Eigen/src/Skyline/SkylineInplaceLU.h46
-rw-r--r--unsupported/Eigen/src/Skyline/SkylineMatrix.h277
-rw-r--r--unsupported/Eigen/src/Skyline/SkylineMatrixBase.h22
-rw-r--r--unsupported/Eigen/src/Skyline/SkylineProduct.h44
-rw-r--r--unsupported/Eigen/src/Skyline/SkylineStorage.h87
-rw-r--r--unsupported/Eigen/src/Skyline/SkylineUtil.h22
26 files changed, 440 insertions, 397 deletions
diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h b/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
index b3983f8a6..6a6516c82 100644
--- a/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
+++ b/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
@@ -51,6 +51,7 @@ public:
typedef typename Functor::ValueType ValueType;
typedef typename Functor::JacobianType JacobianType;
typedef typename JacobianType::Scalar Scalar;
+ typedef typename JacobianType::Index Index;
typedef Matrix<Scalar,InputsAtCompileTime,1> DerivativeType;
typedef AutoDiffScalar<DerivativeType> ActiveScalar;
@@ -74,15 +75,15 @@ public:
ActiveValue av(jac.rows());
if(InputsAtCompileTime==Dynamic)
- for (int j=0; j<jac.rows(); j++)
+ for (Index j=0; j<jac.rows(); j++)
av[j].derivatives().resize(this->inputs());
- for (int i=0; i<jac.cols(); i++)
+ for (Index i=0; i<jac.cols(); i++)
ax[i].derivatives() = DerivativeType::Unit(this->inputs(),i);
Functor::operator()(ax, &av);
- for (int i=0; i<jac.rows(); i++)
+ for (Index i=0; i<jac.rows(); i++)
{
(*v)[i] = av[i].value();
jac.row(i) = av[i].derivatives();
diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h b/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
index c0765d494..9b9dbcc88 100644
--- a/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
+++ b/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
@@ -53,6 +53,7 @@ class AutoDiffVector
typedef AutoDiffScalar<Matrix<BaseScalar,JacobianType::RowsAtCompileTime,1> > ActiveScalar;
typedef ActiveScalar Scalar;
typedef AutoDiffScalar<typename JacobianType::ColXpr> CoeffType;
+ typedef typename JacobianType::Index Index;
inline AutoDiffVector() {}
@@ -63,16 +64,16 @@ class AutoDiffVector
}
- CoeffType operator[] (int i) { return CoeffType(m_values[i], m_jacobian.col(i)); }
- const CoeffType operator[] (int i) const { return CoeffType(m_values[i], m_jacobian.col(i)); }
+ CoeffType operator[] (Index i) { return CoeffType(m_values[i], m_jacobian.col(i)); }
+ const CoeffType operator[] (Index i) const { return CoeffType(m_values[i], m_jacobian.col(i)); }
- CoeffType operator() (int i) { return CoeffType(m_values[i], m_jacobian.col(i)); }
- const CoeffType operator() (int i) const { return CoeffType(m_values[i], m_jacobian.col(i)); }
+ CoeffType operator() (Index i) { return CoeffType(m_values[i], m_jacobian.col(i)); }
+ const CoeffType operator() (Index i) const { return CoeffType(m_values[i], m_jacobian.col(i)); }
- CoeffType coeffRef(int i) { return CoeffType(m_values[i], m_jacobian.col(i)); }
- const CoeffType coeffRef(int i) const { return CoeffType(m_values[i], m_jacobian.col(i)); }
+ CoeffType coeffRef(Index i) { return CoeffType(m_values[i], m_jacobian.col(i)); }
+ const CoeffType coeffRef(Index i) const { return CoeffType(m_values[i], m_jacobian.col(i)); }
- int size() const { return m_values.size(); }
+ Index size() const { return m_values.size(); }
// FIXME here we could return an expression of the sum
Scalar sum() const { /*std::cerr << "sum \n\n";*/ /*std::cerr << m_jacobian.rowwise().sum() << "\n\n";*/ return Scalar(m_values.sum(), m_jacobian.rowwise().sum()); }
diff --git a/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h b/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
index c2b77636c..8f2a35319 100644
--- a/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
+++ b/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
@@ -61,17 +61,18 @@ void ei_pseudo_inverse(const CMatrix &C, CINVMatrix &CINV)
{
// optimisable : copie de la ligne, precalcul de C * trans(C).
typedef typename CMatrix::Scalar Scalar;
+ typedef typename CMatrix::Index Index;
// FIXME use sparse vectors ?
typedef Matrix<Scalar,Dynamic,1> TmpVec;
- int rows = C.rows(), cols = C.cols();
+ Index rows = C.rows(), cols = C.cols();
TmpVec d(rows), e(rows), l(cols), p(rows), q(rows), r(rows);
Scalar rho, rho_1, alpha;
d.setZero();
CINV.startFill(); // FIXME estimate the number of non-zeros
- for (int i = 0; i < rows; ++i)
+ for (Index i = 0; i < rows; ++i)
{
d[i] = 1.0;
rho = 1.0;
@@ -94,7 +95,7 @@ void ei_pseudo_inverse(const CMatrix &C, CINVMatrix &CINV)
l = C.transpose() * e; // l is the i-th row of CINV
// FIXME add a generic "prune/filter" expression for both dense and sparse object to sparse
- for (int j=0; j<l.size(); ++j)
+ for (Index j=0; j<l.size(); ++j)
if (l[j]<1e-15)
CINV.fill(i,j) = l[j];
@@ -116,10 +117,11 @@ void ei_constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x,
const VectorB& b, const VectorF& f, IterationController &iter)
{
typedef typename TMatrix::Scalar Scalar;
+ typedef typename TMatrix::Index Index;
typedef Matrix<Scalar,Dynamic,1> TmpVec;
Scalar rho = 1.0, rho_1, lambda, gamma;
- int xSize = x.size();
+ Index xSize = x.size();
TmpVec p(xSize), q(xSize), q2(xSize),
r(xSize), old_z(xSize), z(xSize),
memox(xSize);
@@ -140,7 +142,7 @@ void ei_constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x,
r += A * -x;
z = r;
bool transition = false;
- for (int i = 0; i < C.rows(); ++i)
+ for (Index i = 0; i < C.rows(); ++i)
{
Scalar al = C.row(i).dot(x) - f.coeff(i);
if (al >= -1.0E-15)
@@ -175,7 +177,7 @@ void ei_constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x,
// one dimensionnal optimization
q = A * p;
lambda = rho / q.dot(p);
- for (int i = 0; i < C.rows(); ++i)
+ for (Index i = 0; i < C.rows(); ++i)
{
if (!satured[i])
{
diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
index d7eb1b2fe..5d47f2cec 100644
--- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
+++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
@@ -296,6 +296,7 @@ void MatrixExponential<MatrixType>::computeUV(double)
template<typename Derived> struct MatrixExponentialReturnValue
: public ReturnByValue<MatrixExponentialReturnValue<Derived> >
{
+ typedef typename Derived::Index Index;
public:
/** \brief Constructor.
*
@@ -317,8 +318,8 @@ template<typename Derived> struct MatrixExponentialReturnValue
me.compute(result);
}
- int rows() const { return m_src.rows(); }
- int cols() const { return m_src.cols(); }
+ Index rows() const { return m_src.rows(); }
+ Index cols() const { return m_src.cols(); }
protected:
const Derived& m_src;
diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h b/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
index 8ed856770..be27c5037 100644
--- a/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
+++ b/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
@@ -131,14 +131,15 @@ class MatrixFunction<MatrixType, 1>
private:
typedef ei_traits<MatrixType> Traits;
- typedef typename Traits::Scalar Scalar;
+ typedef typename MatrixType::Scalar Scalar;
+ typedef typename MatrixType::Index Index;
static const int RowsAtCompileTime = Traits::RowsAtCompileTime;
static const int ColsAtCompileTime = Traits::ColsAtCompileTime;
static const int Options = MatrixType::Options;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef typename ei_stem_function<Scalar>::type StemFunction;
typedef Matrix<Scalar, Traits::RowsAtCompileTime, 1> VectorType;
- typedef Matrix<int, Traits::RowsAtCompileTime, 1> IntVectorType;
+ typedef Matrix<Index, Traits::RowsAtCompileTime, 1> IntVectorType;
typedef std::list<Scalar> Cluster;
typedef std::list<Cluster> ListOfClusters;
typedef Matrix<Scalar, Dynamic, Dynamic, Options, RowsAtCompileTime, ColsAtCompileTime> DynMatrixType;
@@ -157,9 +158,9 @@ class MatrixFunction<MatrixType, 1>
void computeBlockStart();
void constructPermutation();
void permuteSchur();
- void swapEntriesInSchur(int index);
+ void swapEntriesInSchur(Index index);
void computeBlockAtomic();
- Block<MatrixType> block(const MatrixType& A, int i, int j);
+ Block<MatrixType> block(const MatrixType& A, Index i, Index j);
void computeOffDiagonal();
DynMatrixType solveTriangularSylvester(const DynMatrixType& A, const DynMatrixType& B, const DynMatrixType& C);
@@ -238,10 +239,10 @@ void MatrixFunction<MatrixType,1>::computeSchurDecomposition()
template <typename MatrixType>
void MatrixFunction<MatrixType,1>::partitionEigenvalues()
{
- const int rows = m_T.rows();
+ const Index rows = m_T.rows();
VectorType diag = m_T.diagonal(); // contains eigenvalues of A
- for (int i=0; i<rows; ++i) {
+ for (Index i=0; i<rows; ++i) {
// Find set containing diag(i), adding a new set if necessary
typename ListOfClusters::iterator qi = findCluster(diag(i));
if (qi == m_clusters.end()) {
@@ -253,7 +254,7 @@ void MatrixFunction<MatrixType,1>::partitionEigenvalues()
}
// Look for other element to add to the set
- for (int j=i+1; j<rows; ++j) {
+ for (Index j=i+1; j<rows; ++j) {
if (ei_abs(diag(j) - diag(i)) <= separation() && std::find(qi->begin(), qi->end(), diag(j)) == qi->end()) {
typename ListOfClusters::iterator qj = findCluster(diag(j));
if (qj == m_clusters.end()) {
@@ -288,15 +289,15 @@ typename MatrixFunction<MatrixType,1>::ListOfClusters::iterator MatrixFunction<M
template <typename MatrixType>
void MatrixFunction<MatrixType,1>::computeClusterSize()
{
- const int rows = m_T.rows();
+ const Index rows = m_T.rows();
VectorType diag = m_T.diagonal();
- const int numClusters = static_cast<int>(m_clusters.size());
+ const Index numClusters = static_cast<Index>(m_clusters.size());
m_clusterSize.setZero(numClusters);
m_eivalToCluster.resize(rows);
- int clusterIndex = 0;
+ Index clusterIndex = 0;
for (typename ListOfClusters::const_iterator cluster = m_clusters.begin(); cluster != m_clusters.end(); ++cluster) {
- for (int i = 0; i < diag.rows(); ++i) {
+ 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;
@@ -312,7 +313,7 @@ void MatrixFunction<MatrixType,1>::computeBlockStart()
{
m_blockStart.resize(m_clusterSize.rows());
m_blockStart(0) = 0;
- for (int i = 1; i < m_clusterSize.rows(); i++) {
+ for (Index i = 1; i < m_clusterSize.rows(); i++) {
m_blockStart(i) = m_blockStart(i-1) + m_clusterSize(i-1);
}
}
@@ -323,8 +324,8 @@ void MatrixFunction<MatrixType,1>::constructPermutation()
{
VectorXi indexNextEntry = m_blockStart;
m_permutation.resize(m_T.rows());
- for (int i = 0; i < m_T.rows(); i++) {
- int cluster = m_eivalToCluster[i];
+ for (Index i = 0; i < m_T.rows(); i++) {
+ Index cluster = m_eivalToCluster[i];
m_permutation[i] = indexNextEntry[cluster];
++indexNextEntry[cluster];
}
@@ -335,13 +336,13 @@ template <typename MatrixType>
void MatrixFunction<MatrixType,1>::permuteSchur()
{
IntVectorType p = m_permutation;
- for (int i = 0; i < p.rows() - 1; i++) {
- int j;
+ for (Index i = 0; i < p.rows() - 1; i++) {
+ Index j;
for (j = i; j < p.rows(); j++) {
if (p(j) == i) break;
}
ei_assert(p(j) == i);
- for (int k = j-1; k >= i; k--) {
+ for (Index k = j-1; k >= i; k--) {
swapEntriesInSchur(k);
std::swap(p.coeffRef(k), p.coeffRef(k+1));
}
@@ -350,7 +351,7 @@ void MatrixFunction<MatrixType,1>::permuteSchur()
/** \brief Swap rows \a index and \a index+1 in Schur decomposition in #m_U and #m_T */
template <typename MatrixType>
-void MatrixFunction<MatrixType,1>::swapEntriesInSchur(int index)
+void MatrixFunction<MatrixType,1>::swapEntriesInSchur(Index index)
{
PlanarRotation<Scalar> rotation;
rotation.makeGivens(m_T(index, index+1), m_T(index+1, index+1) - m_T(index, index));
@@ -372,14 +373,14 @@ void MatrixFunction<MatrixType,1>::computeBlockAtomic()
m_fT.resize(m_T.rows(), m_T.cols());
m_fT.setZero();
MatrixFunctionAtomic<DynMatrixType> mfa(m_f);
- for (int i = 0; i < m_clusterSize.rows(); ++i) {
+ for (Index i = 0; i < m_clusterSize.rows(); ++i) {
block(m_fT, i, i) = mfa.compute(block(m_T, i, i));
}
}
/** \brief Return block of matrix according to blocking given by #m_blockStart */
template <typename MatrixType>
-Block<MatrixType> MatrixFunction<MatrixType,1>::block(const MatrixType& A, int i, int j)
+Block<MatrixType> MatrixFunction<MatrixType,1>::block(const MatrixType& A, Index i, Index j)
{
return A.block(m_blockStart(i), m_blockStart(j), m_clusterSize(i), m_clusterSize(j));
}
@@ -394,14 +395,14 @@ Block<MatrixType> MatrixFunction<MatrixType,1>::block(const MatrixType& A, int i
template <typename MatrixType>
void MatrixFunction<MatrixType,1>::computeOffDiagonal()
{
- for (int diagIndex = 1; diagIndex < m_clusterSize.rows(); diagIndex++) {
- for (int blockIndex = 0; blockIndex < m_clusterSize.rows() - diagIndex; blockIndex++) {
+ for (Index diagIndex = 1; diagIndex < m_clusterSize.rows(); diagIndex++) {
+ for (Index blockIndex = 0; blockIndex < m_clusterSize.rows() - diagIndex; blockIndex++) {
// compute (blockIndex, blockIndex+diagIndex) block
DynMatrixType A = block(m_T, blockIndex, blockIndex);
DynMatrixType B = -block(m_T, blockIndex+diagIndex, blockIndex+diagIndex);
DynMatrixType C = block(m_fT, blockIndex, blockIndex) * block(m_T, blockIndex, blockIndex+diagIndex);
C -= block(m_T, blockIndex, blockIndex+diagIndex) * block(m_fT, blockIndex+diagIndex, blockIndex+diagIndex);
- for (int k = blockIndex + 1; k < blockIndex + diagIndex; k++) {
+ for (Index k = blockIndex + 1; k < blockIndex + diagIndex; k++) {
C += block(m_fT, blockIndex, k) * block(m_T, k, blockIndex+diagIndex);
C -= block(m_T, blockIndex, k) * block(m_fT, k, blockIndex+diagIndex);
}
@@ -446,12 +447,12 @@ typename MatrixFunction<MatrixType,1>::DynMatrixType MatrixFunction<MatrixType,1
ei_assert(C.rows() == A.rows());
ei_assert(C.cols() == B.rows());
- int m = A.rows();
- int n = B.rows();
+ Index m = A.rows();
+ Index n = B.rows();
DynMatrixType X(m, n);
- for (int i = m - 1; i >= 0; --i) {
- for (int j = 0; j < n; ++j) {
+ for (Index i = m - 1; i >= 0; --i) {
+ for (Index j = 0; j < n; ++j) {
// Compute AX = \sum_{k=i+1}^m A_{ik} X_{kj}
Scalar AX;
@@ -494,7 +495,8 @@ template<typename Derived> class MatrixFunctionReturnValue
{
public:
- typedef typename ei_traits<Derived>::Scalar Scalar;
+ typedef typename Derived::Scalar Scalar;
+ typedef typename Derived::Index Index;
typedef typename ei_stem_function<Scalar>::type StemFunction;
/** \brief Constructor.
@@ -518,8 +520,8 @@ template<typename Derived> class MatrixFunctionReturnValue
mf.compute(result);
}
- int rows() const { return m_A.rows(); }
- int cols() const { return m_A.cols(); }
+ Index rows() const { return m_A.rows(); }
+ Index cols() const { return m_A.cols(); }
private:
const Derived& m_A;
diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h b/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h
index 4bcae47c0..b578c1301 100644
--- a/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h
+++ b/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h
@@ -38,11 +38,11 @@ class MatrixFunctionAtomic
{
public:
- typedef ei_traits<MatrixType> Traits;
- typedef typename Traits::Scalar Scalar;
+ typedef typename MatrixType::Scalar Scalar;
+ typedef typename MatrixType::Index Index;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef typename ei_stem_function<Scalar>::type StemFunction;
- typedef Matrix<Scalar, Traits::RowsAtCompileTime, 1> VectorType;
+ typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
/** \brief Constructor
* \param[in] f matrix function to compute.
@@ -62,13 +62,13 @@ class MatrixFunctionAtomic
MatrixFunctionAtomic& operator=(const MatrixFunctionAtomic&);
void computeMu();
- bool taylorConverged(int s, const MatrixType& F, const MatrixType& Fincr, const MatrixType& P);
+ bool taylorConverged(Index s, const MatrixType& F, const MatrixType& Fincr, const MatrixType& P);
/** \brief Pointer to scalar function */
StemFunction* m_f;
/** \brief Size of matrix function */
- int m_Arows;
+ Index m_Arows;
/** \brief Mean of eigenvalues */
Scalar m_avgEival;
@@ -91,7 +91,7 @@ MatrixType MatrixFunctionAtomic<MatrixType>::compute(const MatrixType& A)
MatrixType F = m_f(m_avgEival, 0) * MatrixType::Identity(m_Arows, m_Arows);
MatrixType P = m_Ashifted;
MatrixType Fincr;
- for (int s = 1; s < 1.1 * m_Arows + 10; s++) { // upper limit is fairly arbitrary
+ for (Index s = 1; s < 1.1 * m_Arows + 10; s++) { // upper limit is fairly arbitrary
Fincr = m_f(m_avgEival, s) * P;
F += Fincr;
P = Scalar(RealScalar(1.0/(s + 1))) * P * m_Ashifted;
@@ -115,18 +115,18 @@ void MatrixFunctionAtomic<MatrixType>::computeMu()
/** \brief Determine whether Taylor series has converged */
template <typename MatrixType>
-bool MatrixFunctionAtomic<MatrixType>::taylorConverged(int s, const MatrixType& F,
+bool MatrixFunctionAtomic<MatrixType>::taylorConverged(Index s, const MatrixType& F,
const MatrixType& Fincr, const MatrixType& P)
{
- const int n = F.rows();
+ const Index n = F.rows();
const RealScalar F_norm = F.cwiseAbs().rowwise().sum().maxCoeff();
const RealScalar Fincr_norm = Fincr.cwiseAbs().rowwise().sum().maxCoeff();
if (Fincr_norm < NumTraits<Scalar>::epsilon() * F_norm) {
RealScalar delta = 0;
RealScalar rfactorial = 1;
- for (int r = 0; r < n; r++) {
+ for (Index r = 0; r < n; r++) {
RealScalar mx = 0;
- for (int i = 0; i < n; i++)
+ for (Index i = 0; i < n; i++)
mx = std::max(mx, std::abs(m_f(m_Ashifted(i, i) + m_avgEival, s+r)));
if (r != 0)
rfactorial *= RealScalar(r);
diff --git a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
index d75b1407c..aba31b238 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
@@ -56,6 +56,8 @@ template<typename FunctorType, typename Scalar=double>
class HybridNonLinearSolver
{
public:
+ typedef DenseIndex Index;
+
HybridNonLinearSolver(FunctorType &_functor)
: functor(_functor) { nfev=njev=iter = 0; fnorm= 0.; useExternalScaling=false;}
@@ -68,10 +70,10 @@ public:
, nb_of_superdiagonals(-1)
, epsfcn(Scalar(0.)) {}
Scalar factor;
- int maxfev; // maximum number of function evaluation
+ Index maxfev; // maximum number of function evaluation
Scalar xtol;
- int nb_of_subdiagonals;
- int nb_of_superdiagonals;
+ Index nb_of_subdiagonals;
+ Index nb_of_superdiagonals;
Scalar epsfcn;
};
typedef Matrix< Scalar, Dynamic, 1 > FVectorType;
@@ -102,24 +104,24 @@ public:
FVectorType fvec, qtf, diag;
JacobianType fjac;
UpperTriangularType R;
- int nfev;
- int njev;
- int iter;
+ Index nfev;
+ Index njev;
+ Index iter;
Scalar fnorm;
bool useExternalScaling;
private:
FunctorType &functor;
- int n;
+ Index n;
Scalar sum;
bool sing;
Scalar temp;
Scalar delta;
bool jeval;
- int ncsuc;
+ Index ncsuc;
Scalar ratio;
Scalar pnorm, xnorm, fnorm1;
- int nslow1, nslow2;
- int ncfail;
+ Index nslow1, nslow2;
+ Index ncfail;
Scalar actred, prered;
FVectorType wa1, wa2, wa3, wa4;
};
@@ -169,7 +171,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveInit(FVectorType &x)
if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || parameters.factor <= 0. )
return HybridNonLinearSolverSpace::ImproperInputParameters;
if (useExternalScaling)
- for (int j = 0; j < n; ++j)
+ for (Index j = 0; j < n; ++j)
if (diag[j] <= 0.)
return HybridNonLinearSolverSpace::ImproperInputParameters;
@@ -196,7 +198,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(FVectorType &x)
{
assert(x.size()==n); // check the caller is not cheating us
- int j;
+ Index j;
std::vector<PlanarRotation<Scalar> > v_givens(n), w_givens(n);
jeval = true;
@@ -408,7 +410,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffInit(FVectorType &
if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || parameters.nb_of_subdiagonals< 0 || parameters.nb_of_superdiagonals< 0 || parameters.factor <= 0. )
return HybridNonLinearSolverSpace::ImproperInputParameters;
if (useExternalScaling)
- for (int j = 0; j < n; ++j)
+ for (Index j = 0; j < n; ++j)
if (diag[j] <= 0.)
return HybridNonLinearSolverSpace::ImproperInputParameters;
@@ -435,7 +437,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType
{
assert(x.size()==n); // check the caller is not cheating us
- int j;
+ Index j;
std::vector<PlanarRotation<Scalar> > v_givens(n), w_givens(n);
jeval = true;
diff --git a/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h b/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
index 3d5b6ea70..63eb66738 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
@@ -63,6 +63,8 @@ public:
LevenbergMarquardt(FunctorType &_functor)
: functor(_functor) { nfev = njev = iter = 0; fnorm = gnorm = 0.; useExternalScaling=false; }
+ typedef DenseIndex Index;
+
struct Parameters {
Parameters()
: factor(Scalar(100.))
@@ -72,7 +74,7 @@ public:
, gtol(Scalar(0.))
, epsfcn(Scalar(0.)) {}
Scalar factor;
- int maxfev; // maximum number of function evaluation
+ Index maxfev; // maximum number of function evaluation
Scalar ftol;
Scalar xtol;
Scalar gtol;
@@ -94,7 +96,7 @@ public:
static LevenbergMarquardtSpace::Status lmdif1(
FunctorType &functor,
FVectorType &x,
- int *nfev,
+ Index *nfev,
const Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon())
);
@@ -113,17 +115,17 @@ public:
FVectorType fvec, qtf, diag;
JacobianType fjac;
PermutationMatrix<Dynamic,Dynamic> permutation;
- int nfev;
- int njev;
- int iter;
+ Index nfev;
+ Index njev;
+ Index iter;
Scalar fnorm, gnorm;
bool useExternalScaling;
Scalar lm_param(void) { return par; }
private:
FunctorType &functor;
- int n;
- int m;
+ Index n;
+ Index m;
FVectorType wa1, wa2, wa3, wa4;
Scalar par, sum;
@@ -194,7 +196,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeInit(FVectorType &x)
return LevenbergMarquardtSpace::ImproperInputParameters;
if (useExternalScaling)
- for (int j = 0; j < n; ++j)
+ for (Index j = 0; j < n; ++j)
if (diag[j] <= 0.)
return LevenbergMarquardtSpace::ImproperInputParameters;
@@ -219,7 +221,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
assert(x.size()==n); // check the caller is not cheating us
/* calculate the jacobian matrix. */
- int df_ret = functor.df(x, fjac);
+ Index df_ret = functor.df(x, fjac);
if (df_ret<0)
return LevenbergMarquardtSpace::UserAsked;
if (df_ret>0)
@@ -237,7 +239,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
/* to the norms of the columns of the initial jacobian. */
if (iter == 1) {
if (!useExternalScaling)
- for (int j = 0; j < n; ++j)
+ for (Index j = 0; j < n; ++j)
diag[j] = (wa2[j]==0.)? 1. : wa2[j];
/* on the first iteration, calculate the norm of the scaled x */
@@ -257,7 +259,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x)
/* compute the norm of the scaled gradient. */
gnorm = 0.;
if (fnorm != 0.)
- for (int j = 0; j < n; ++j)
+ for (Index j = 0; j < n; ++j)
if (wa2[permutation.indices()[j]] != 0.)
gnorm = std::max(gnorm, ei_abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]]));
@@ -410,7 +412,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageInit(FVectorType
return LevenbergMarquardtSpace::ImproperInputParameters;
if (useExternalScaling)
- for (int j = 0; j < n; ++j)
+ for (Index j = 0; j < n; ++j)
if (diag[j] <= 0.)
return LevenbergMarquardtSpace::ImproperInputParameters;
@@ -435,7 +437,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp
{
assert(x.size()==n); // check the caller is not cheating us
- int i, j;
+ Index i, j;
bool sing;
/* compute the qr factorization of the jacobian matrix */
@@ -444,7 +446,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp
/* n components in qtf. */
qtf.fill(0.);
fjac.fill(0.);
- int rownb = 2;
+ Index rownb = 2;
for (i = 0; i < m; ++i) {
if (functor.df(x, wa3, rownb) < 0) return LevenbergMarquardtSpace::UserAsked;
ei_rwupdt<Scalar>(fjac, wa3, qtf, fvec[i]);
@@ -471,7 +473,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp
fjac.diagonal() = qrfac.hCoeffs();
permutation = qrfac.colsPermutation();
// TODO : avoid this:
- for(int ii=0; ii< fjac.cols(); ii++) fjac.col(ii).segment(ii+1, fjac.rows()-ii-1) *= fjac(ii,ii); // rescale vectors
+ for(Index ii=0; ii< fjac.cols(); ii++) fjac.col(ii).segment(ii+1, fjac.rows()-ii-1) *= fjac(ii,ii); // rescale vectors
for (j = 0; j < n; ++j) {
if (fjac(j,j) != 0.) {
@@ -623,12 +625,12 @@ LevenbergMarquardtSpace::Status
LevenbergMarquardt<FunctorType,Scalar>::lmdif1(
FunctorType &functor,
FVectorType &x,
- int *nfev,
+ Index *nfev,
const Scalar tol
)
{
- int n = x.size();
- int m = functor.values();
+ Index n = x.size();
+ Index m = functor.values();
/* check the input parameters for errors. */
if (n <= 0 || m < n || tol < 0.)
diff --git a/unsupported/Eigen/src/NonLinearOptimization/chkder.h b/unsupported/Eigen/src/NonLinearOptimization/chkder.h
index 591e8bef7..4cb4fbdef 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/chkder.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/chkder.h
@@ -13,17 +13,19 @@ void ei_chkder(
Matrix< Scalar, Dynamic, 1 > &err
)
{
+ typedef DenseIndex Index;
+
const Scalar eps = ei_sqrt(NumTraits<Scalar>::epsilon());
const Scalar epsf = chkder_factor * NumTraits<Scalar>::epsilon();
const Scalar epslog = chkder_log10e * ei_log(eps);
Scalar temp;
- const int m = fvec.size(), n = x.size();
+ const Index m = fvec.size(), n = x.size();
if (mode != 2) {
/* mode = 1. */
xp.resize(n);
- for (int j = 0; j < n; ++j) {
+ for (Index j = 0; j < n; ++j) {
temp = eps * ei_abs(x[j]);
if (temp == 0.)
temp = eps;
@@ -33,13 +35,13 @@ void ei_chkder(
else {
/* mode = 2. */
err.setZero(m);
- for (int j = 0; j < n; ++j) {
+ for (Index j = 0; j < n; ++j) {
temp = ei_abs(x[j]);
if (temp == 0.)
temp = 1.;
err += temp * fjac.col(j);
}
- for (int i = 0; i < m; ++i) {
+ for (Index i = 0; i < m; ++i) {
temp = 1.;
if (fvec[i] != 0. && fvecp[i] != 0. && ei_abs(fvecp[i] - fvec[i]) >= epsf * ei_abs(fvec[i]))
temp = eps * ei_abs((fvecp[i] - fvec[i]) / eps - err[i]) / (ei_abs(fvec[i]) + ei_abs(fvecp[i]));
diff --git a/unsupported/Eigen/src/NonLinearOptimization/covar.h b/unsupported/Eigen/src/NonLinearOptimization/covar.h
index 7cfaa22d4..104898a30 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/covar.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/covar.h
@@ -5,13 +5,15 @@ void ei_covar(
const VectorXi &ipvt,
Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon()) )
{
+ typedef DenseIndex Index;
+
/* Local variables */
- int i, j, k, l, ii, jj;
- int sing;
+ Index i, j, k, l, ii, jj;
+ bool sing;
Scalar temp;
/* Function Body */
- const int n = r.cols();
+ const Index n = r.cols();
const Scalar tolr = tol * ei_abs(r(0,0));
Matrix< Scalar, Dynamic, 1 > wa(n);
assert(ipvt.size()==n);
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
index 9c1d38dea..ab01d5c47 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
@@ -7,15 +7,17 @@ void ei_dogleg(
Scalar delta,
Matrix< Scalar, Dynamic, 1 > &x)
{
+ typedef DenseIndex Index;
+
/* Local variables */
- int i, j;
+ Index i, j;
Scalar sum, temp, alpha, bnorm;
Scalar gnorm, qnorm;
Scalar sgnorm;
/* Function Body */
const Scalar epsmch = NumTraits<Scalar>::epsilon();
- const int n = qrfac.cols();
+ const Index n = qrfac.cols();
assert(n==qtb.size());
assert(n==x.size());
assert(n==diag.size());
diff --git a/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h b/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
index 3dc1e8070..74cf53b90 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
@@ -1,24 +1,26 @@
template<typename FunctorType, typename Scalar>
-int ei_fdjac1(
+DenseIndex ei_fdjac1(
const FunctorType &Functor,
Matrix< Scalar, Dynamic, 1 > &x,
Matrix< Scalar, Dynamic, 1 > &fvec,
Matrix< Scalar, Dynamic, Dynamic > &fjac,
- int ml, int mu,
+ DenseIndex ml, DenseIndex mu,
Scalar epsfcn)
{
+ typedef DenseIndex Index;
+
/* Local variables */
Scalar h;
- int j, k;
+ Index j, k;
Scalar eps, temp;
- int msum;
+ Index msum;
int iflag;
- int start, length;
+ Index start, length;
/* Function Body */
const Scalar epsmch = NumTraits<Scalar>::epsilon();
- const int n = x.size();
+ const Index n = x.size();
assert(fvec.size()==n);
Matrix< Scalar, Dynamic, 1 > wa1(n);
Matrix< Scalar, Dynamic, 1 > wa2(n);
@@ -57,7 +59,7 @@ int ei_fdjac1(
h = eps * ei_abs(wa2[j]);
if (h == 0.) h = eps;
fjac.col(j).setZero();
- start = std::max(0,j-mu);
+ start = std::max<Index>(0,j-mu);
length = std::min(n-1, j+ml) - start + 1;
fjac.col(j).segment(start, length) = ( wa1.segment(start, length)-fvec.segment(start, length))/h;
}
diff --git a/unsupported/Eigen/src/NonLinearOptimization/lmpar.h b/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
index 850011912..27138de96 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
@@ -9,11 +9,13 @@ void ei_lmpar(
Scalar &par,
Matrix< Scalar, Dynamic, 1 > &x)
{
+ typedef DenseIndex Index;
+
/* Local variables */
- int i, j, l;
+ Index i, j, l;
Scalar fp;
Scalar parc, parl;
- int iter;
+ Index iter;
Scalar temp, paru;
Scalar gnorm;
Scalar dxnorm;
@@ -21,7 +23,7 @@ void ei_lmpar(
/* Function Body */
const Scalar dwarf = std::numeric_limits<Scalar>::min();
- const int n = r.cols();
+ const Index n = r.cols();
assert(n==diag.size());
assert(n==qtb.size());
assert(n==x.size());
@@ -30,7 +32,7 @@ void ei_lmpar(
/* compute and store in x the gauss-newton direction. if the */
/* jacobian is rank-deficient, obtain a least squares solution. */
- int nsing = n-1;
+ Index nsing = n-1;
wa1 = qtb;
for (j = 0; j < n; ++j) {
if (r(j,j) == 0. && nsing == n-1)
@@ -163,11 +165,13 @@ void ei_lmpar2(
Matrix< Scalar, Dynamic, 1 > &x)
{
+ typedef DenseIndex Index;
+
/* Local variables */
- int j;
+ Index j;
Scalar fp;
Scalar parc, parl;
- int iter;
+ Index iter;
Scalar temp, paru;
Scalar gnorm;
Scalar dxnorm;
@@ -175,7 +179,7 @@ void ei_lmpar2(
/* Function Body */
const Scalar dwarf = std::numeric_limits<Scalar>::min();
- const int n = qr.matrixQR().cols();
+ const Index n = qr.matrixQR().cols();
assert(n==diag.size());
assert(n==qtb.size());
@@ -184,8 +188,8 @@ void ei_lmpar2(
/* compute and store in x the gauss-newton direction. if the */
/* jacobian is rank-deficient, obtain a least squares solution. */
-// const int rank = qr.nonzeroPivots(); // exactly double(0.)
- const int rank = qr.rank(); // use a threshold
+// const Index rank = qr.nonzeroPivots(); // exactly double(0.)
+ const Index rank = qr.rank(); // use a threshold
wa1 = qtb;
wa1.tail(n-rank).setZero();
qr.matrixQR().topLeftCorner(rank, rank).template triangularView<Upper>().solveInPlace(wa1.head(rank));
@@ -262,7 +266,7 @@ void ei_lmpar2(
for (j = 0; j < n; ++j) {
wa1[j] /= sdiag[j];
temp = wa1[j];
- for (int i = j+1; i < n; ++i)
+ for (Index i = j+1; i < n; ++i)
wa1[i] -= s(i,j) * temp;
}
temp = wa1.blueNorm();
diff --git a/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h b/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
index 205d934bd..bce8a4441 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
@@ -11,10 +11,12 @@ void ei_qrsolv(
Matrix< Scalar, Dynamic, 1 > &sdiag)
{
+ typedef DenseIndex Index;
+
/* Local variables */
- int i, j, k, l;
+ Index i, j, k, l;
Scalar temp;
- int n = s.cols();
+ Index n = s.cols();
Matrix< Scalar, Dynamic, 1 > wa(n);
PlanarRotation<Scalar> givens;
@@ -67,7 +69,7 @@ void ei_qrsolv(
/* solve the triangular system for z. if the system is */
/* singular, then obtain a least squares solution. */
- int nsing;
+ Index nsing;
for (nsing=0; nsing<n && sdiag[nsing]!=0; nsing++);
wa.tail(n-nsing).setZero();
diff --git a/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h b/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
index 855cb7a1b..ad319d9eb 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
@@ -2,18 +2,20 @@
// TODO : move this to GivensQR once there's such a thing in Eigen
template <typename Scalar>
-void ei_r1mpyq(int m, int n, Scalar *a, const std::vector<PlanarRotation<Scalar> > &v_givens, const std::vector<PlanarRotation<Scalar> > &w_givens)
+void ei_r1mpyq(DenseIndex m, DenseIndex n, Scalar *a, const std::vector<PlanarRotation<Scalar> > &v_givens, const std::vector<PlanarRotation<Scalar> > &w_givens)
{
+ typedef DenseIndex Index;
+
/* apply the first set of givens rotations to a. */
- for (int j = n-2; j>=0; --j)
- for (int i = 0; i<m; ++i) {
+ for (Index j = n-2; j>=0; --j)
+ for (Index i = 0; i<m; ++i) {
Scalar temp = v_givens[j].c() * a[i+m*j] - v_givens[j].s() * a[i+m*(n-1)];
a[i+m*(n-1)] = v_givens[j].s() * a[i+m*j] + v_givens[j].c() * a[i+m*(n-1)];
a[i+m*j] = temp;
}
/* apply the second set of givens rotations to a. */
- for (int j = 0; j<n-1; ++j)
- for (int i = 0; i<m; ++i) {
+ for (Index j = 0; j<n-1; ++j)
+ for (Index i = 0; i<m; ++i) {
Scalar temp = w_givens[j].c() * a[i+m*j] + w_givens[j].s() * a[i+m*(n-1)];
a[i+m*(n-1)] = -w_givens[j].s() * a[i+m*j] + w_givens[j].c() * a[i+m*(n-1)];
a[i+m*j] = temp;
diff --git a/unsupported/Eigen/src/NonLinearOptimization/r1updt.h b/unsupported/Eigen/src/NonLinearOptimization/r1updt.h
index 3d8978837..e01d02910 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/r1updt.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/r1updt.h
@@ -9,10 +9,12 @@ void ei_r1updt(
Matrix< Scalar, Dynamic, 1> &w,
bool *sing)
{
+ typedef DenseIndex Index;
+
/* Local variables */
- const int m = s.rows();
- const int n = s.cols();
- int i, j=1;
+ const Index m = s.rows();
+ const Index n = s.cols();
+ Index i, j=1;
Scalar temp;
PlanarRotation<Scalar> givens;
diff --git a/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h b/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h
index b0bf72923..aa0bf7d0f 100644
--- a/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h
+++ b/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h
@@ -6,7 +6,9 @@ void ei_rwupdt(
Matrix< Scalar, Dynamic, 1> &b,
Scalar alpha)
{
- const int n = r.cols();
+ typedef DenseIndex Index;
+
+ const Index n = r.cols();
assert(r.rows()>=n);
std::vector<PlanarRotation<Scalar> > givens(n);
@@ -14,12 +16,12 @@ void ei_rwupdt(
Scalar temp, rowj;
/* Function Body */
- for (int j = 0; j < n; ++j) {
+ for (Index j = 0; j < n; ++j) {
rowj = w[j];
/* apply the previous transformations to */
/* r(i,j), i=0,1,...,j-1, and to w(j). */
- for (int i = 0; i < j; ++i) {
+ for (Index i = 0; i < j; ++i) {
temp = givens[i].c() * r(i,j) + givens[i].s() * rowj;
rowj = -givens[i].s() * r(i,j) + givens[i].c() * rowj;
r(i,j) = temp;
diff --git a/unsupported/Eigen/src/Polynomials/Companion.h b/unsupported/Eigen/src/Polynomials/Companion.h
index 7c9e9c518..5a3bacc20 100644
--- a/unsupported/Eigen/src/Polynomials/Companion.h
+++ b/unsupported/Eigen/src/Polynomials/Companion.h
@@ -68,8 +68,10 @@ class ei_companion
typedef Matrix< Scalar, Deg_1, Deg_1 > BottomLeftBlock;
typedef Matrix< Scalar, 1, Deg_1 > LeftBlockFirstRow;
+ typedef DenseIndex Index;
+
public:
- EIGEN_STRONG_INLINE const _Scalar operator()( int row, int col ) const
+ EIGEN_STRONG_INLINE const _Scalar operator()(Index row, Index col ) const
{
if( m_bl_diag.rows() > col )
{
@@ -83,7 +85,7 @@ class ei_companion
template<typename VectorType>
void setPolynomial( const VectorType& poly )
{
- const int deg = poly.size()-1;
+ const Index deg = poly.size()-1;
m_monic = -1/poly[deg] * poly.head(deg);
//m_bl_diag.setIdentity( deg-1 );
m_bl_diag.setOnes(deg-1);
@@ -96,8 +98,8 @@ class ei_companion
public:
DenseCompanionMatrixType denseMatrix() const
{
- const int deg = m_monic.size();
- const int deg_1 = deg-1;
+ const Index deg = m_monic.size();
+ const Index deg_1 = deg-1;
DenseCompanionMatrixType companion(deg,deg);
companion <<
( LeftBlock(deg,deg_1)
@@ -220,8 +222,8 @@ template< typename _Scalar, int _Deg >
void ei_companion<_Scalar,_Deg>::balance()
{
EIGEN_STATIC_ASSERT( 1 < Deg, YOU_MADE_A_PROGRAMMING_MISTAKE );
- const int deg = m_monic.size();
- const int deg_1 = deg-1;
+ const Index deg = m_monic.size();
+ const Index deg_1 = deg-1;
bool hasConverged=false;
while( !hasConverged )
@@ -244,7 +246,7 @@ void ei_companion<_Scalar,_Deg>::balance()
//Middle rows and columns excluding the diagonal
//==============================================
- for( int i=1; i<deg_1; ++i )
+ for( Index i=1; i<deg_1; ++i )
{
// column norm, excluding the diagonal
colNorm = ei_abs(m_bl_diag[i]);
@@ -263,7 +265,7 @@ void ei_companion<_Scalar,_Deg>::balance()
//Last row, last column excluding the diagonal
//============================================
- const int ebl = m_bl_diag.size()-1;
+ const Index ebl = m_bl_diag.size()-1;
VectorBlock<RightColumn,Deg_1> headMonic( m_monic, 0, deg_1 );
colNorm = headMonic.array().abs().sum();
rowNorm = ei_abs( m_bl_diag[ebl] );
diff --git a/unsupported/Eigen/src/Polynomials/PolynomialSolver.h b/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
index 207836508..ba14b5911 100644
--- a/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
+++ b/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
@@ -49,6 +49,8 @@ class PolynomialSolverBase
typedef std::complex<RealScalar> RootType;
typedef Matrix<RootType,_Deg,1> RootsType;
+ typedef DenseIndex Index;
+
protected:
template< typename OtherPolynomial >
inline void setPolynomial( const OtherPolynomial& poly ){
@@ -81,7 +83,7 @@ class PolynomialSolverBase
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
{
bi_seq.clear();
- for( int i=0; i<m_roots.size(); ++i )
+ for(Index i=0; i<m_roots.size(); ++i )
{
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold ){
bi_seq.push_back( m_roots[i].real() ); }
@@ -92,9 +94,9 @@ class PolynomialSolverBase
template<typename squaredNormBinaryPredicate>
inline const RootType& selectComplexRoot_withRespectToNorm( squaredNormBinaryPredicate& pred ) const
{
- int res=0;
+ Index res=0;
RealScalar norm2 = ei_abs2( m_roots[0] );
- for( int i=1; i<m_roots.size(); ++i )
+ for( Index i=1; i<m_roots.size(); ++i )
{
const RealScalar currNorm2 = ei_abs2( m_roots[i] );
if( pred( currNorm2, norm2 ) ){
@@ -130,10 +132,10 @@ class PolynomialSolverBase
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
{
hasArealRoot = false;
- int res=0;
+ Index res=0;
RealScalar abs2(0);
- for( int i=0; i<m_roots.size(); ++i )
+ for( Index i=0; i<m_roots.size(); ++i )
{
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold )
{
@@ -170,10 +172,10 @@ class PolynomialSolverBase
const RealScalar& absImaginaryThreshold = NumTraits<Scalar>::dummy_precision() ) const
{
hasArealRoot = false;
- int res=0;
+ Index res=0;
RealScalar val(0);
- for( int i=0; i<m_roots.size(); ++i )
+ for( Index i=0; i<m_roots.size(); ++i )
{
if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold )
{
diff --git a/unsupported/Eigen/src/Polynomials/PolynomialUtils.h b/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
index d78821f90..d10b8f4dc 100644
--- a/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
+++ b/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
@@ -41,7 +41,7 @@ inline
T poly_eval_horner( const Polynomials& poly, const T& x )
{
T val=poly[poly.size()-1];
- for( int i=poly.size()-2; i>=0; --i ){
+ for(DenseIndex i=poly.size()-2; i>=0; --i ){
val = val*x + poly[i]; }
return val;
}
@@ -66,7 +66,7 @@ T poly_eval( const Polynomials& poly, const T& x )
{
T val=poly[0];
T inv_x = T(1)/x;
- for( int i=1; i<poly.size(); ++i ){
+ for( DenseIndex i=1; i<poly.size(); ++i ){
val = val*inv_x + poly[i]; }
return std::pow(x,(T)(poly.size()-1)) * val;
@@ -94,7 +94,7 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_max_bound( const Po
const Scalar inv_leading_coeff = Scalar(1)/poly[poly.size()-1];
Real cb(0);
- for( int i=0; i<poly.size()-1; ++i ){
+ for( DenseIndex i=0; i<poly.size()-1; ++i ){
cb += ei_abs(poly[i]*inv_leading_coeff); }
return cb + Real(1);
}
@@ -112,14 +112,14 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_min_bound( const Po
typedef typename Polynomial::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real Real;
- int i=0;
+ DenseIndex i=0;
while( i<poly.size()-1 && Scalar(0) == poly(i) ){ ++i; }
if( poly.size()-1 == i ){
return Real(1); }
const Scalar inv_min_coeff = Scalar(1)/poly[i];
Real cb(1);
- for( int j=i+1; j<poly.size(); ++j ){
+ for( DenseIndex j=i+1; j<poly.size(); ++j ){
cb += ei_abs(poly[j]*inv_min_coeff); }
return Real(1)/cb;
}
@@ -142,9 +142,9 @@ void roots_to_monicPolynomial( const RootVector& rv, Polynomial& poly )
poly.setZero( rv.size()+1 );
poly[0] = -rv[0]; poly[1] = Scalar(1);
- for( int i=1; i<(int)rv.size(); ++i )
+ for( DenseIndex i=1; i< rv.size(); ++i )
{
- for( int j=i+1; j>0; --j ){ poly[j] = poly[j-1] - rv[i]*poly[j]; }
+ for( DenseIndex j=i+1; j>0; --j ){ poly[j] = poly[j-1] - rv[i]*poly[j]; }
poly[0] = -rv[i]*poly[0];
}
}
diff --git a/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h b/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
index c8c5f7575..fa8f81908 100644
--- a/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
+++ b/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
@@ -38,6 +38,8 @@ template<typename MatrixType>
class SkylineInplaceLU {
protected:
typedef typename MatrixType::Scalar Scalar;
+ typedef typename MatrixType::Index Index;
+
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
public:
@@ -135,18 +137,18 @@ void SkylineInplaceLU<MatrixType>::compute() {
ei_assert(rows == cols && "We do not (yet) support rectangular LU.");
ei_assert(!m_lu.IsRowMajor && "LU decomposition does not work with rowMajor Storage");
- for (unsigned int row = 0; row < rows; row++) {
+ for (Index row = 0; row < rows; row++) {
const double pivot = m_lu.coeffDiag(row);
//Lower matrix Columns update
- const unsigned int& col = row;
+ const Index& col = row;
for (typename MatrixType::InnerLowerIterator lIt(m_lu, col); lIt; ++lIt) {
lIt.valueRef() /= pivot;
}
//Upper matrix update -> contiguous memory access
typename MatrixType::InnerLowerIterator lIt(m_lu, col);
- for (unsigned int rrow = row + 1; rrow < m_lu.rows(); rrow++) {
+ for (Index rrow = row + 1; rrow < m_lu.rows(); rrow++) {
typename MatrixType::InnerUpperIterator uItPivot(m_lu, row);
typename MatrixType::InnerUpperIterator uIt(m_lu, rrow);
const double coef = lIt.value();
@@ -165,12 +167,12 @@ void SkylineInplaceLU<MatrixType>::compute() {
//Upper matrix update -> non contiguous memory access
typename MatrixType::InnerLowerIterator lIt3(m_lu, col);
- for (unsigned int rrow = row + 1; rrow < m_lu.rows(); rrow++) {
+ for (Index rrow = row + 1; rrow < m_lu.rows(); rrow++) {
typename MatrixType::InnerUpperIterator uItPivot(m_lu, row);
const double coef = lIt3.value();
//update lower part -> non contiguous memory access
- for (unsigned int i = 0; i < rrow - row - 1; i++) {
+ for (Index i = 0; i < rrow - row - 1; i++) {
m_lu.coeffRefLower(rrow, row + i + 1) -= uItPivot.value() * coef;
++uItPivot;
}
@@ -178,7 +180,7 @@ void SkylineInplaceLU<MatrixType>::compute() {
}
//update diag -> contiguous
typename MatrixType::InnerLowerIterator lIt2(m_lu, col);
- for (unsigned int rrow = row + 1; rrow < m_lu.rows(); rrow++) {
+ for (Index rrow = row + 1; rrow < m_lu.rows(); rrow++) {
typename MatrixType::InnerUpperIterator uItPivot(m_lu, row);
typename MatrixType::InnerUpperIterator uIt(m_lu, rrow);
@@ -199,11 +201,11 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() {
ei_assert(rows == cols && "We do not (yet) support rectangular LU.");
ei_assert(m_lu.IsRowMajor && "You're trying to apply rowMajor decomposition on a ColMajor matrix !");
- for (unsigned int row = 0; row < rows; row++) {
+ for (Index row = 0; row < rows; row++) {
typename MatrixType::InnerLowerIterator llIt(m_lu, row);
- for (unsigned int col = llIt.col(); col < row; col++) {
+ for (Index col = llIt.col(); col < row; col++) {
if (m_lu.coeffExistLower(row, col)) {
const double diag = m_lu.coeffDiag(col);
@@ -211,10 +213,10 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() {
typename MatrixType::InnerUpperIterator uIt(m_lu, col);
- const int offset = lIt.col() - uIt.row();
+ const Index offset = lIt.col() - uIt.row();
- int stop = offset > 0 ? col - lIt.col() : col - uIt.row();
+ Index stop = offset > 0 ? col - lIt.col() : col - uIt.row();
//#define VECTORIZE
#ifdef VECTORIZE
@@ -230,7 +232,7 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() {
lIt += -offset;
Scalar newCoeff = m_lu.coeffLower(row, col);
- for (int k = 0; k < stop; ++k) {
+ for (Index k = 0; k < stop; ++k) {
const Scalar tmp = newCoeff;
newCoeff = tmp - lIt.value() * uIt.value();
++lIt;
@@ -243,15 +245,15 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() {
}
//Upper matrix update
- const int col = row;
+ const Index col = row;
typename MatrixType::InnerUpperIterator uuIt(m_lu, col);
- for (unsigned int rrow = uuIt.row(); rrow < col; rrow++) {
+ for (Index rrow = uuIt.row(); rrow < col; rrow++) {
typename MatrixType::InnerLowerIterator lIt(m_lu, rrow);
typename MatrixType::InnerUpperIterator uIt(m_lu, col);
- const int offset = lIt.col() - uIt.row();
+ const Index offset = lIt.col() - uIt.row();
- int stop = offset > 0 ? rrow - lIt.col() : rrow - uIt.row();
+ Index stop = offset > 0 ? rrow - lIt.col() : rrow - uIt.row();
#ifdef VECTORIZE
Map<VectorXd > rowVal(lIt.valuePtr() + (offset > 0 ? 0 : -offset), stop);
@@ -264,7 +266,7 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() {
else //Skip zero values of uIt
lIt += -offset;
Scalar newCoeff = m_lu.coeffUpper(rrow, col);
- for (int k = 0; k < stop; ++k) {
+ for (Index k = 0; k < stop; ++k) {
const Scalar tmp = newCoeff;
newCoeff = tmp - lIt.value() * uIt.value();
@@ -280,10 +282,10 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() {
typename MatrixType::InnerLowerIterator lIt(m_lu, row);
typename MatrixType::InnerUpperIterator uIt(m_lu, row);
- const int offset = lIt.col() - uIt.row();
+ const Index offset = lIt.col() - uIt.row();
- int stop = offset > 0 ? lIt.size() : uIt.size();
+ Index stop = offset > 0 ? lIt.size() : uIt.size();
#ifdef VECTORIZE
Map<VectorXd > rowVal(lIt.valuePtr() + (offset > 0 ? 0 : -offset), stop);
Map<VectorXd > colVal(uIt.valuePtr() + (offset > 0 ? offset : 0), stop);
@@ -294,7 +296,7 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() {
else //Skip zero values of uIt
lIt += -offset;
Scalar newCoeff = m_lu.coeffDiag(row);
- for (unsigned int k = 0; k < stop; ++k) {
+ for (Index k = 0; k < stop; ++k) {
const Scalar tmp = newCoeff;
newCoeff = tmp - lIt.value() * uIt.value();
++lIt;
@@ -320,12 +322,12 @@ bool SkylineInplaceLU<MatrixType>::solve(const MatrixBase<BDerived> &b, MatrixBa
const size_t cols = m_lu.cols();
- for (int row = 0; row < rows; row++) {
+ for (Index row = 0; row < rows; row++) {
x->coeffRef(row) = b.coeff(row);
Scalar newVal = x->coeff(row);
typename MatrixType::InnerLowerIterator lIt(m_lu, row);
- unsigned int col = lIt.col();
+ Index col = lIt.col();
while (lIt.col() < row) {
newVal -= x->coeff(col++) * lIt.value();
@@ -336,7 +338,7 @@ bool SkylineInplaceLU<MatrixType>::solve(const MatrixBase<BDerived> &b, MatrixBa
}
- for (int col = rows - 1; col > 0; col--) {
+ for (Index col = rows - 1; col > 0; col--) {
x->coeffRef(col) = x->coeff(col) / m_lu.coeffDiag(col);
const Scalar x_col = x->coeff(col);
diff --git a/unsupported/Eigen/src/Skyline/SkylineMatrix.h b/unsupported/Eigen/src/Skyline/SkylineMatrix.h
index 6dd4f1736..20fafafa8 100644
--- a/unsupported/Eigen/src/Skyline/SkylineMatrix.h
+++ b/unsupported/Eigen/src/Skyline/SkylineMatrix.h
@@ -46,6 +46,7 @@
template<typename _Scalar, int _Options>
struct ei_traits<SkylineMatrix<_Scalar, _Options> > {
typedef _Scalar Scalar;
+ typedef Sparse StorageKind;
enum {
RowsAtCompileTime = Dynamic,
@@ -71,45 +72,45 @@ protected:
typedef SkylineMatrix<Scalar, (Flags&~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0) > TransposedSkylineMatrix;
- int m_outerSize;
- int m_innerSize;
+ Index m_outerSize;
+ Index m_innerSize;
public:
- int* m_colStartIndex;
- int* m_rowStartIndex;
+ Index* m_colStartIndex;
+ Index* m_rowStartIndex;
SkylineStorage<Scalar> m_data;
public:
- inline int rows() const {
+ inline Index rows() const {
return IsRowMajor ? m_outerSize : m_innerSize;
}
- inline int cols() const {
+ inline Index cols() const {
return IsRowMajor ? m_innerSize : m_outerSize;
}
- inline int innerSize() const {
+ inline Index innerSize() const {
return m_innerSize;
}
- inline int outerSize() const {
+ inline Index outerSize() const {
return m_outerSize;
}
- inline int upperNonZeros() const {
+ inline Index upperNonZeros() const {
return m_data.upperSize();
}
- inline int lowerNonZeros() const {
+ inline Index lowerNonZeros() const {
return m_data.lowerSize();
}
- inline int upperNonZeros(int j) const {
+ inline Index upperNonZeros(Index j) const {
return m_colStartIndex[j + 1] - m_colStartIndex[j];
}
- inline int lowerNonZeros(int j) const {
+ inline Index lowerNonZeros(Index j) const {
return m_rowStartIndex[j + 1] - m_rowStartIndex[j];
}
@@ -137,25 +138,25 @@ public:
return &m_data.lower(0);
}
- inline const int* _upperProfilePtr() const {
+ inline const Index* _upperProfilePtr() const {
return &m_data.upperProfile(0);
}
- inline int* _upperProfilePtr() {
+ inline Index* _upperProfilePtr() {
return &m_data.upperProfile(0);
}
- inline const int* _lowerProfilePtr() const {
+ inline const Index* _lowerProfilePtr() const {
return &m_data.lowerProfile(0);
}
- inline int* _lowerProfilePtr() {
+ inline Index* _lowerProfilePtr() {
return &m_data.lowerProfile(0);
}
- inline Scalar coeff(int row, int col) const {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline Scalar coeff(Index row, Index col) const {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
@@ -166,7 +167,7 @@ public:
if (IsRowMajor) {
if (inner > outer) //upper matrix
{
- const int minOuterIndex = inner - m_data.upperProfile(inner);
+ const Index minOuterIndex = inner - m_data.upperProfile(inner);
if (outer >= minOuterIndex)
return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
else
@@ -174,7 +175,7 @@ public:
}
if (inner < outer) //lower matrix
{
- const int minInnerIndex = outer - m_data.lowerProfile(outer);
+ const Index minInnerIndex = outer - m_data.lowerProfile(outer);
if (inner >= minInnerIndex)
return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
else
@@ -184,7 +185,7 @@ public:
} else {
if (outer > inner) //upper matrix
{
- const int maxOuterIndex = inner + m_data.upperProfile(inner);
+ const Index maxOuterIndex = inner + m_data.upperProfile(inner);
if (outer <= maxOuterIndex)
return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
else
@@ -192,7 +193,7 @@ public:
}
if (outer < inner) //lower matrix
{
- const int maxInnerIndex = outer + m_data.lowerProfile(outer);
+ const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
if (inner <= maxInnerIndex)
return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
@@ -202,9 +203,9 @@ public:
}
}
- inline Scalar& coeffRef(int row, int col) {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline Scalar& coeffRef(Index row, Index col) {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
@@ -215,55 +216,55 @@ public:
if (IsRowMajor) {
if (col > row) //upper matrix
{
- const int minOuterIndex = inner - m_data.upperProfile(inner);
+ const Index minOuterIndex = inner - m_data.upperProfile(inner);
ei_assert(outer >= minOuterIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
}
if (col < row) //lower matrix
{
- const int minInnerIndex = outer - m_data.lowerProfile(outer);
+ const Index minInnerIndex = outer - m_data.lowerProfile(outer);
ei_assert(inner >= minInnerIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
}
} else {
if (outer > inner) //upper matrix
{
- const int maxOuterIndex = inner + m_data.upperProfile(inner);
+ const Index maxOuterIndex = inner + m_data.upperProfile(inner);
ei_assert(outer <= maxOuterIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
}
if (outer < inner) //lower matrix
{
- const int maxInnerIndex = outer + m_data.lowerProfile(outer);
+ const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
ei_assert(inner <= maxInnerIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
}
}
}
- inline Scalar coeffDiag(int idx) const {
+ inline Scalar coeffDiag(Index idx) const {
ei_assert(idx < outerSize());
ei_assert(idx < innerSize());
return this->m_data.diag(idx);
}
- inline Scalar coeffLower(int row, int col) const {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline Scalar coeffLower(Index row, Index col) const {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
ei_assert(inner != outer);
if (IsRowMajor) {
- const int minInnerIndex = outer - m_data.lowerProfile(outer);
+ const Index minInnerIndex = outer - m_data.lowerProfile(outer);
if (inner >= minInnerIndex)
return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
else
return Scalar(0);
} else {
- const int maxInnerIndex = outer + m_data.lowerProfile(outer);
+ const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
if (inner <= maxInnerIndex)
return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
else
@@ -271,22 +272,22 @@ public:
}
}
- inline Scalar coeffUpper(int row, int col) const {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline Scalar coeffUpper(Index row, Index col) const {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
ei_assert(inner != outer);
if (IsRowMajor) {
- const int minOuterIndex = inner - m_data.upperProfile(inner);
+ const Index minOuterIndex = inner - m_data.upperProfile(inner);
if (outer >= minOuterIndex)
return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
else
return Scalar(0);
} else {
- const int maxOuterIndex = inner + m_data.upperProfile(inner);
+ const Index maxOuterIndex = inner + m_data.upperProfile(inner);
if (outer <= maxOuterIndex)
return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
else
@@ -294,80 +295,80 @@ public:
}
}
- inline Scalar& coeffRefDiag(int idx) {
+ inline Scalar& coeffRefDiag(Index idx) {
ei_assert(idx < outerSize());
ei_assert(idx < innerSize());
return this->m_data.diag(idx);
}
- inline Scalar& coeffRefLower(int row, int col) {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline Scalar& coeffRefLower(Index row, Index col) {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
ei_assert(inner != outer);
if (IsRowMajor) {
- const int minInnerIndex = outer - m_data.lowerProfile(outer);
+ const Index minInnerIndex = outer - m_data.lowerProfile(outer);
ei_assert(inner >= minInnerIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
} else {
- const int maxInnerIndex = outer + m_data.lowerProfile(outer);
+ const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
ei_assert(inner <= maxInnerIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
}
}
- inline bool coeffExistLower(int row, int col) {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline bool coeffExistLower(Index row, Index col) {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
ei_assert(inner != outer);
if (IsRowMajor) {
- const int minInnerIndex = outer - m_data.lowerProfile(outer);
+ const Index minInnerIndex = outer - m_data.lowerProfile(outer);
return inner >= minInnerIndex;
} else {
- const int maxInnerIndex = outer + m_data.lowerProfile(outer);
+ const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
return inner <= maxInnerIndex;
}
}
- inline Scalar& coeffRefUpper(int row, int col) {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline Scalar& coeffRefUpper(Index row, Index col) {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
ei_assert(inner != outer);
if (IsRowMajor) {
- const int minOuterIndex = inner - m_data.upperProfile(inner);
+ const Index minOuterIndex = inner - m_data.upperProfile(inner);
ei_assert(outer >= minOuterIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
} else {
- const int maxOuterIndex = inner + m_data.upperProfile(inner);
+ const Index maxOuterIndex = inner + m_data.upperProfile(inner);
ei_assert(outer <= maxOuterIndex && "you try to acces a coeff that do not exist in the storage");
return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
}
}
- inline bool coeffExistUpper(int row, int col) {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ inline bool coeffExistUpper(Index row, Index col) {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
ei_assert(inner != outer);
if (IsRowMajor) {
- const int minOuterIndex = inner - m_data.upperProfile(inner);
+ const Index minOuterIndex = inner - m_data.upperProfile(inner);
return outer >= minOuterIndex;
} else {
- const int maxOuterIndex = inner + m_data.upperProfile(inner);
+ const Index maxOuterIndex = inner + m_data.upperProfile(inner);
return outer <= maxOuterIndex;
}
}
@@ -385,17 +386,17 @@ public:
/** Removes all non zeros */
inline void setZero() {
m_data.clear();
- memset(m_colStartIndex, 0, (m_outerSize + 1) * sizeof (int));
- memset(m_rowStartIndex, 0, (m_outerSize + 1) * sizeof (int));
+ memset(m_colStartIndex, 0, (m_outerSize + 1) * sizeof (Index));
+ memset(m_rowStartIndex, 0, (m_outerSize + 1) * sizeof (Index));
}
/** \returns the number of non zero coefficients */
- inline int nonZeros() const {
+ inline Index nonZeros() const {
return m_data.diagSize() + m_data.upperSize() + m_data.lowerSize();
}
/** Preallocates \a reserveSize non zeros */
- inline void reserve(int reserveSize, int reserveUpperSize, int reserveLowerSize) {
+ inline void reserve(Index reserveSize, Index reserveUpperSize, Index reserveLowerSize) {
m_data.reserve(reserveSize, reserveUpperSize, reserveLowerSize);
}
@@ -407,9 +408,9 @@ public:
*
* After an insertion session, you should call the finalize() function.
*/
- EIGEN_DONT_INLINE Scalar & insert(int row, int col) {
- const int outer = IsRowMajor ? row : col;
- const int inner = IsRowMajor ? col : row;
+ EIGEN_DONT_INLINE Scalar & insert(Index row, Index col) {
+ const Index outer = IsRowMajor ? row : col;
+ const Index inner = IsRowMajor ? col : row;
ei_assert(outer < outerSize());
ei_assert(inner < innerSize());
@@ -420,27 +421,27 @@ public:
if (IsRowMajor) {
if (outer < inner) //upper matrix
{
- int minOuterIndex = 0;
+ Index minOuterIndex = 0;
minOuterIndex = inner - m_data.upperProfile(inner);
if (outer < minOuterIndex) //The value does not yet exist
{
- const int previousProfile = m_data.upperProfile(inner);
+ const Index previousProfile = m_data.upperProfile(inner);
m_data.upperProfile(inner) = inner - outer;
- const int bandIncrement = m_data.upperProfile(inner) - previousProfile;
+ const Index bandIncrement = m_data.upperProfile(inner) - previousProfile;
//shift data stored after this new one
- const int stop = m_colStartIndex[cols()];
- const int start = m_colStartIndex[inner];
+ const Index stop = m_colStartIndex[cols()];
+ const Index start = m_colStartIndex[inner];
- for (int innerIdx = stop; innerIdx >= start; innerIdx--) {
+ for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
m_data.upper(innerIdx + bandIncrement) = m_data.upper(innerIdx);
}
- for (int innerIdx = cols(); innerIdx > inner; innerIdx--) {
+ for (Index innerIdx = cols(); innerIdx > inner; innerIdx--) {
m_colStartIndex[innerIdx] += bandIncrement;
}
@@ -455,23 +456,23 @@ public:
if (outer > inner) //lower matrix
{
- const int minInnerIndex = outer - m_data.lowerProfile(outer);
+ const Index minInnerIndex = outer - m_data.lowerProfile(outer);
if (inner < minInnerIndex) //The value does not yet exist
{
- const int previousProfile = m_data.lowerProfile(outer);
+ const Index previousProfile = m_data.lowerProfile(outer);
m_data.lowerProfile(outer) = outer - inner;
- const int bandIncrement = m_data.lowerProfile(outer) - previousProfile;
+ const Index bandIncrement = m_data.lowerProfile(outer) - previousProfile;
//shift data stored after this new one
- const int stop = m_rowStartIndex[rows()];
- const int start = m_rowStartIndex[outer];
+ const Index stop = m_rowStartIndex[rows()];
+ const Index start = m_rowStartIndex[outer];
- for (int innerIdx = stop; innerIdx >= start; innerIdx--) {
+ for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
m_data.lower(innerIdx + bandIncrement) = m_data.lower(innerIdx);
}
- for (int innerIdx = rows(); innerIdx > outer; innerIdx--) {
+ for (Index innerIdx = rows(); innerIdx > outer; innerIdx--) {
m_rowStartIndex[innerIdx] += bandIncrement;
}
@@ -485,22 +486,22 @@ public:
} else {
if (outer > inner) //upper matrix
{
- const int maxOuterIndex = inner + m_data.upperProfile(inner);
+ const Index maxOuterIndex = inner + m_data.upperProfile(inner);
if (outer > maxOuterIndex) //The value does not yet exist
{
- const int previousProfile = m_data.upperProfile(inner);
+ const Index previousProfile = m_data.upperProfile(inner);
m_data.upperProfile(inner) = outer - inner;
- const int bandIncrement = m_data.upperProfile(inner) - previousProfile;
+ const Index bandIncrement = m_data.upperProfile(inner) - previousProfile;
//shift data stored after this new one
- const int stop = m_rowStartIndex[rows()];
- const int start = m_rowStartIndex[inner + 1];
+ const Index stop = m_rowStartIndex[rows()];
+ const Index start = m_rowStartIndex[inner + 1];
- for (int innerIdx = stop; innerIdx >= start; innerIdx--) {
+ for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
m_data.upper(innerIdx + bandIncrement) = m_data.upper(innerIdx);
}
- for (int innerIdx = inner + 1; innerIdx < outerSize() + 1; innerIdx++) {
+ for (Index innerIdx = inner + 1; innerIdx < outerSize() + 1; innerIdx++) {
m_rowStartIndex[innerIdx] += bandIncrement;
}
memset(this->_upperPtr() + m_rowStartIndex[inner] + previousProfile + 1, 0, (bandIncrement - 1) * sizeof (Scalar));
@@ -512,22 +513,22 @@ public:
if (outer < inner) //lower matrix
{
- const int maxInnerIndex = outer + m_data.lowerProfile(outer);
+ const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
if (inner > maxInnerIndex) //The value does not yet exist
{
- const int previousProfile = m_data.lowerProfile(outer);
+ const Index previousProfile = m_data.lowerProfile(outer);
m_data.lowerProfile(outer) = inner - outer;
- const int bandIncrement = m_data.lowerProfile(outer) - previousProfile;
+ const Index bandIncrement = m_data.lowerProfile(outer) - previousProfile;
//shift data stored after this new one
- const int stop = m_colStartIndex[cols()];
- const int start = m_colStartIndex[outer + 1];
+ const Index stop = m_colStartIndex[cols()];
+ const Index start = m_colStartIndex[outer + 1];
- for (int innerIdx = stop; innerIdx >= start; innerIdx--) {
+ for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
m_data.lower(innerIdx + bandIncrement) = m_data.lower(innerIdx);
}
- for (int innerIdx = outer + 1; innerIdx < outerSize() + 1; innerIdx++) {
+ for (Index innerIdx = outer + 1; innerIdx < outerSize() + 1; innerIdx++) {
m_colStartIndex[innerIdx] += bandIncrement;
}
memset(this->_lowerPtr() + m_colStartIndex[outer] + previousProfile + 1, 0, (bandIncrement - 1) * sizeof (Scalar));
@@ -551,16 +552,16 @@ public:
// ei_assert(rows() == cols() && "memory reorganisatrion only works with suare matrix");
//
// Scalar* newArray = new Scalar[m_colStartIndex[cols()] + 1 + m_rowStartIndex[rows()] + 1];
- // unsigned int dataIdx = 0;
- // for (unsigned int row = 0; row < rows(); row++) {
+ // Index dataIdx = 0;
+ // for (Index row = 0; row < rows(); row++) {
//
- // const unsigned int nbLowerElts = m_rowStartIndex[row + 1] - m_rowStartIndex[row];
+ // const Index nbLowerElts = m_rowStartIndex[row + 1] - m_rowStartIndex[row];
// // std::cout << "nbLowerElts" << nbLowerElts << std::endl;
// memcpy(newArray + dataIdx, m_data.m_lower + m_rowStartIndex[row], nbLowerElts * sizeof (Scalar));
// m_rowStartIndex[row] = dataIdx;
// dataIdx += nbLowerElts;
//
- // const unsigned int nbUpperElts = m_colStartIndex[row + 1] - m_colStartIndex[row];
+ // const Index nbUpperElts = m_colStartIndex[row + 1] - m_colStartIndex[row];
// memcpy(newArray + dataIdx, m_data.m_upper + m_colStartIndex[row], nbUpperElts * sizeof (Scalar));
// m_colStartIndex[row] = dataIdx;
// dataIdx += nbUpperElts;
@@ -594,16 +595,16 @@ public:
}
/** Resizes the matrix to a \a rows x \a cols matrix and initializes it to zero
- * \sa resizeNonZeros(int), reserve(), setZero()
+ * \sa resizeNonZeros(Index), reserve(), setZero()
*/
void resize(size_t rows, size_t cols) {
- const int diagSize = rows > cols ? cols : rows;
+ const Index diagSize = rows > cols ? cols : rows;
m_innerSize = IsRowMajor ? cols : rows;
ei_assert(rows == cols && "Skyline matrix must be square matrix");
if (diagSize % 2) { // diagSize is odd
- const int k = (diagSize - 1) / 2;
+ const Index k = (diagSize - 1) / 2;
m_data.resize(diagSize, IsRowMajor ? cols : rows, IsRowMajor ? rows : cols,
2 * k * k + k + 1,
@@ -611,7 +612,7 @@ public:
} else // diagSize is even
{
- const int k = diagSize / 2;
+ const Index k = diagSize / 2;
m_data.resize(diagSize, IsRowMajor ? cols : rows, IsRowMajor ? rows : cols,
2 * k * k - k + 1,
2 * k * k - k + 1);
@@ -621,19 +622,19 @@ public:
delete[] m_colStartIndex;
delete[] m_rowStartIndex;
}
- m_colStartIndex = new int [cols + 1];
- m_rowStartIndex = new int [rows + 1];
+ m_colStartIndex = new Index [cols + 1];
+ m_rowStartIndex = new Index [rows + 1];
m_outerSize = diagSize;
m_data.reset();
m_data.clear();
m_outerSize = diagSize;
- memset(m_colStartIndex, 0, (cols + 1) * sizeof (int));
- memset(m_rowStartIndex, 0, (rows + 1) * sizeof (int));
+ memset(m_colStartIndex, 0, (cols + 1) * sizeof (Index));
+ memset(m_rowStartIndex, 0, (rows + 1) * sizeof (Index));
}
- void resizeNonZeros(int size) {
+ void resizeNonZeros(Index size) {
m_data.resize(size);
}
@@ -673,8 +674,8 @@ public:
swap(other.const_cast_derived());
} else {
resize(other.rows(), other.cols());
- memcpy(m_colStartIndex, other.m_colStartIndex, (m_outerSize + 1) * sizeof (int));
- memcpy(m_rowStartIndex, other.m_rowStartIndex, (m_outerSize + 1) * sizeof (int));
+ memcpy(m_colStartIndex, other.m_colStartIndex, (m_outerSize + 1) * sizeof (Index));
+ memcpy(m_rowStartIndex, other.m_rowStartIndex, (m_outerSize + 1) * sizeof (Index));
m_data = other.m_data;
}
return *this;
@@ -696,34 +697,34 @@ public:
EIGEN_DBG_SKYLINE(
std::cout << "upper elements : " << std::endl;
- for (unsigned int i = 0; i < m.m_data.upperSize(); i++)
+ for (Index i = 0; i < m.m_data.upperSize(); i++)
std::cout << m.m_data.upper(i) << "\t";
std::cout << std::endl;
std::cout << "upper profile : " << std::endl;
- for (unsigned int i = 0; i < m.m_data.upperProfileSize(); i++)
+ for (Index i = 0; i < m.m_data.upperProfileSize(); i++)
std::cout << m.m_data.upperProfile(i) << "\t";
std::cout << std::endl;
std::cout << "lower startIdx : " << std::endl;
- for (unsigned int i = 0; i < m.m_data.upperProfileSize(); i++)
+ for (Index i = 0; i < m.m_data.upperProfileSize(); i++)
std::cout << (IsRowMajor ? m.m_colStartIndex[i] : m.m_rowStartIndex[i]) << "\t";
std::cout << std::endl;
std::cout << "lower elements : " << std::endl;
- for (unsigned int i = 0; i < m.m_data.lowerSize(); i++)
+ for (Index i = 0; i < m.m_data.lowerSize(); i++)
std::cout << m.m_data.lower(i) << "\t";
std::cout << std::endl;
std::cout << "lower profile : " << std::endl;
- for (unsigned int i = 0; i < m.m_data.lowerProfileSize(); i++)
+ for (Index i = 0; i < m.m_data.lowerProfileSize(); i++)
std::cout << m.m_data.lowerProfile(i) << "\t";
std::cout << std::endl;
std::cout << "lower startIdx : " << std::endl;
- for (unsigned int i = 0; i < m.m_data.lowerProfileSize(); i++)
+ for (Index i = 0; i < m.m_data.lowerProfileSize(); i++)
std::cout << (IsRowMajor ? m.m_rowStartIndex[i] : m.m_colStartIndex[i]) << "\t";
std::cout << std::endl;
);
- for (unsigned int rowIdx = 0; rowIdx < m.rows(); rowIdx++) {
- for (unsigned int colIdx = 0; colIdx < m.cols(); colIdx++) {
+ for (Index rowIdx = 0; rowIdx < m.rows(); rowIdx++) {
+ for (Index colIdx = 0; colIdx < m.cols(); colIdx++) {
s << m.coeff(rowIdx, colIdx) << "\t";
}
s << std::endl;
@@ -745,7 +746,7 @@ template<typename Scalar, int _Options>
class SkylineMatrix<Scalar, _Options>::InnerUpperIterator {
public:
- InnerUpperIterator(const SkylineMatrix& mat, int outer)
+ InnerUpperIterator(const SkylineMatrix& mat, Index outer)
: m_matrix(mat), m_outer(outer),
m_id(_Options == RowMajor ? mat.m_colStartIndex[outer] : mat.m_rowStartIndex[outer] + 1),
m_start(m_id),
@@ -757,7 +758,7 @@ public:
return *this;
}
- inline InnerUpperIterator & operator+=(unsigned int shift) {
+ inline InnerUpperIterator & operator+=(Index shift) {
m_id += shift;
return *this;
}
@@ -774,16 +775,16 @@ public:
return const_cast<Scalar&> (m_matrix.m_data.upper(m_id));
}
- inline int index() const {
+ inline Index index() const {
return IsRowMajor ? m_outer - m_matrix.m_data.upperProfile(m_outer) + (m_id - m_start) :
m_outer + (m_id - m_start) + 1;
}
- inline int row() const {
+ inline Index row() const {
return IsRowMajor ? index() : m_outer;
}
- inline int col() const {
+ inline Index col() const {
return IsRowMajor ? m_outer : index();
}
@@ -797,17 +798,17 @@ public:
protected:
const SkylineMatrix& m_matrix;
- const int m_outer;
- int m_id;
- const int m_start;
- const int m_end;
+ const Index m_outer;
+ Index m_id;
+ const Index m_start;
+ const Index m_end;
};
template<typename Scalar, int _Options>
class SkylineMatrix<Scalar, _Options>::InnerLowerIterator {
public:
- InnerLowerIterator(const SkylineMatrix& mat, int outer)
+ InnerLowerIterator(const SkylineMatrix& mat, Index outer)
: m_matrix(mat),
m_outer(outer),
m_id(_Options == RowMajor ? mat.m_rowStartIndex[outer] : mat.m_colStartIndex[outer] + 1),
@@ -820,7 +821,7 @@ public:
return *this;
}
- inline InnerLowerIterator & operator+=(unsigned int shift) {
+ inline InnerLowerIterator & operator+=(Index shift) {
m_id += shift;
return *this;
}
@@ -837,17 +838,17 @@ public:
return const_cast<Scalar&> (m_matrix.m_data.lower(m_id));
}
- inline int index() const {
+ inline Index index() const {
return IsRowMajor ? m_outer - m_matrix.m_data.lowerProfile(m_outer) + (m_id - m_start) :
m_outer + (m_id - m_start) + 1;
;
}
- inline int row() const {
+ inline Index row() const {
return IsRowMajor ? m_outer : index();
}
- inline int col() const {
+ inline Index col() const {
return IsRowMajor ? index() : m_outer;
}
@@ -861,10 +862,10 @@ public:
protected:
const SkylineMatrix& m_matrix;
- const int m_outer;
- int m_id;
- const int m_start;
- const int m_end;
+ const Index m_outer;
+ Index m_id;
+ const Index m_start;
+ const Index m_end;
};
#endif // EIGEN_SkylineMatrix_H
diff --git a/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h b/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
index ff20b830c..17349c187 100644
--- a/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
+++ b/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
@@ -40,6 +40,8 @@ template<typename Derived> class SkylineMatrixBase : public EigenBase<Derived> {
public:
typedef typename ei_traits<Derived>::Scalar Scalar;
+ typedef typename ei_traits<Derived>::StorageKind StorageKind;
+ typedef typename ei_index<StorageKind>::type Index;
enum {
RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
@@ -113,36 +115,36 @@ public:
#endif // not EIGEN_PARSED_BY_DOXYGEN
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
- inline int rows() const {
+ inline Index rows() const {
return derived().rows();
}
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
- inline int cols() const {
+ inline Index cols() const {
return derived().cols();
}
/** \returns the number of coefficients, which is \a rows()*cols().
* \sa rows(), cols(), SizeAtCompileTime. */
- inline int size() const {
+ inline Index size() const {
return rows() * cols();
}
/** \returns the number of nonzero coefficients which is in practice the number
* of stored coefficients. */
- inline int nonZeros() const {
+ inline Index nonZeros() const {
return derived().nonZeros();
}
/** \returns the size of the storage major dimension,
* i.e., the number of columns for a columns major matrix, and the number of rows otherwise */
- int outerSize() const {
+ Index outerSize() const {
return (int(Flags) & RowMajorBit) ? this->rows() : this->cols();
}
/** \returns the size of the inner dimension according to the storage order,
* i.e., the number of rows for a columns major matrix, and the number of cols otherwise */
- int innerSize() const {
+ Index innerSize() const {
return (int(Flags) & RowMajorBit) ? this->cols() : this->rows();
}
@@ -167,8 +169,8 @@ public:
template<typename OtherDerived>
inline void assignGeneric(const OtherDerived& other) {
derived().resize(other.rows(), other.cols());
- for (unsigned int row = 0; row < rows(); row++)
- for (unsigned int col = 0; col < cols(); col++) {
+ for (Index row = 0; row < rows(); row++)
+ for (Index col = 0; col < cols(); col++) {
if (other.coeff(row, col) != Scalar(0))
derived().insert(row, col) = other.coeff(row, col);
}
@@ -196,8 +198,8 @@ public:
template<typename DenseDerived>
void evalTo(MatrixBase<DenseDerived>& dst) const {
dst.setZero();
- for (unsigned int i = 0; i < rows(); i++)
- for (unsigned int j = 0; j < rows(); j++)
+ for (Index i = 0; i < rows(); i++)
+ for (Index j = 0; j < rows(); j++)
dst(i, j) = derived().coeff(i, j);
}
diff --git a/unsupported/Eigen/src/Skyline/SkylineProduct.h b/unsupported/Eigen/src/Skyline/SkylineProduct.h
index 9586576b5..e6484ad13 100644
--- a/unsupported/Eigen/src/Skyline/SkylineProduct.h
+++ b/unsupported/Eigen/src/Skyline/SkylineProduct.h
@@ -106,11 +106,11 @@ public:
EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
}
- EIGEN_STRONG_INLINE int rows() const {
+ EIGEN_STRONG_INLINE Index rows() const {
return m_lhs.rows();
}
- EIGEN_STRONG_INLINE int cols() const {
+ EIGEN_STRONG_INLINE Index cols() const {
return m_rhs.cols();
}
@@ -147,18 +147,18 @@ EIGEN_DONT_INLINE void ei_skyline_row_major_time_dense_product(const Lhs& lhs, c
};
//Use matrix diagonal part <- Improvement : use inner iterator on dense matrix.
- for (unsigned int col = 0; col < rhs.cols(); col++) {
- for (unsigned int row = 0; row < lhs.rows(); row++) {
+ for (Index col = 0; col < rhs.cols(); col++) {
+ for (Index row = 0; row < lhs.rows(); row++) {
dst(row, col) = lhs.coeffDiag(row) * rhs(row, col);
}
}
//Use matrix lower triangular part
- for (unsigned int row = 0; row < lhs.rows(); row++) {
+ for (Index row = 0; row < lhs.rows(); row++) {
typename _Lhs::InnerLowerIterator lIt(lhs, row);
- const int stop = lIt.col() + lIt.size();
- for (unsigned int col = 0; col < rhs.cols(); col++) {
+ const Index stop = lIt.col() + lIt.size();
+ for (Index col = 0; col < rhs.cols(); col++) {
- unsigned int k = lIt.col();
+ Index k = lIt.col();
Scalar tmp = 0;
while (k < stop) {
tmp +=
@@ -173,14 +173,14 @@ EIGEN_DONT_INLINE void ei_skyline_row_major_time_dense_product(const Lhs& lhs, c
}
//Use matrix upper triangular part
- for (unsigned int lhscol = 0; lhscol < lhs.cols(); lhscol++) {
+ for (Index lhscol = 0; lhscol < lhs.cols(); lhscol++) {
typename _Lhs::InnerUpperIterator uIt(lhs, lhscol);
- const int stop = uIt.size() + uIt.row();
- for (unsigned int rhscol = 0; rhscol < rhs.cols(); rhscol++) {
+ const Index stop = uIt.size() + uIt.row();
+ for (Index rhscol = 0; rhscol < rhs.cols(); rhscol++) {
const Scalar rhsCoeff = rhs.coeff(lhscol, rhscol);
- unsigned int k = uIt.row();
+ Index k = uIt.row();
while (k < stop) {
dst(k++, rhscol) +=
uIt.value() *
@@ -210,19 +210,19 @@ EIGEN_DONT_INLINE void ei_skyline_col_major_time_dense_product(const Lhs& lhs, c
};
//Use matrix diagonal part <- Improvement : use inner iterator on dense matrix.
- for (unsigned int col = 0; col < rhs.cols(); col++) {
- for (unsigned int row = 0; row < lhs.rows(); row++) {
+ for (Index col = 0; col < rhs.cols(); col++) {
+ for (Index row = 0; row < lhs.rows(); row++) {
dst(row, col) = lhs.coeffDiag(row) * rhs(row, col);
}
}
//Use matrix upper triangular part
- for (unsigned int row = 0; row < lhs.rows(); row++) {
+ for (Index row = 0; row < lhs.rows(); row++) {
typename _Lhs::InnerUpperIterator uIt(lhs, row);
- const int stop = uIt.col() + uIt.size();
- for (unsigned int col = 0; col < rhs.cols(); col++) {
+ const Index stop = uIt.col() + uIt.size();
+ for (Index col = 0; col < rhs.cols(); col++) {
- unsigned int k = uIt.col();
+ Index k = uIt.col();
Scalar tmp = 0;
while (k < stop) {
tmp +=
@@ -238,13 +238,13 @@ EIGEN_DONT_INLINE void ei_skyline_col_major_time_dense_product(const Lhs& lhs, c
}
//Use matrix lower triangular part
- for (unsigned int lhscol = 0; lhscol < lhs.cols(); lhscol++) {
+ for (Index lhscol = 0; lhscol < lhs.cols(); lhscol++) {
typename _Lhs::InnerLowerIterator lIt(lhs, lhscol);
- const int stop = lIt.size() + lIt.row();
- for (unsigned int rhscol = 0; rhscol < rhs.cols(); rhscol++) {
+ const Index stop = lIt.size() + lIt.row();
+ for (Index rhscol = 0; rhscol < rhs.cols(); rhscol++) {
const Scalar rhsCoeff = rhs.coeff(lhscol, rhscol);
- unsigned int k = lIt.row();
+ Index k = lIt.row();
while (k < stop) {
dst(k++, rhscol) +=
lIt.value() *
diff --git a/unsupported/Eigen/src/Skyline/SkylineStorage.h b/unsupported/Eigen/src/Skyline/SkylineStorage.h
index 641508f75..13f3e0ced 100644
--- a/unsupported/Eigen/src/Skyline/SkylineStorage.h
+++ b/unsupported/Eigen/src/Skyline/SkylineStorage.h
@@ -34,6 +34,7 @@
template<typename Scalar>
class SkylineStorage {
typedef typename NumTraits<Scalar>::Real RealScalar;
+ typedef SparseIndex Index;
public:
SkylineStorage()
@@ -70,8 +71,8 @@ public:
memcpy(m_diag, other.m_diag, m_diagSize * sizeof (Scalar));
memcpy(m_upper, other.m_upper, other.upperSize() * sizeof (Scalar));
memcpy(m_lower, other.m_lower, other.lowerSize() * sizeof (Scalar));
- memcpy(m_upperProfile, other.m_upperProfile, m_upperProfileSize * sizeof (int));
- memcpy(m_lowerProfile, other.m_lowerProfile, m_lowerProfileSize * sizeof (int));
+ memcpy(m_upperProfile, other.m_upperProfile, m_upperProfileSize * sizeof (Index));
+ memcpy(m_lowerProfile, other.m_lowerProfile, m_lowerProfileSize * sizeof (Index));
return *this;
}
@@ -96,8 +97,8 @@ public:
delete[] m_lowerProfile;
}
- void reserve(size_t size, size_t upperProfileSize, size_t lowerProfileSize, size_t upperSize, size_t lowerSize) {
- int newAllocatedSize = size + upperSize + lowerSize;
+ void reserve(Index size, Index upperProfileSize, Index lowerProfileSize, Index upperSize, Index lowerSize) {
+ Index newAllocatedSize = size + upperSize + lowerSize;
if (newAllocatedSize > m_allocatedSize)
reallocate(size, upperProfileSize, lowerProfileSize, upperSize, lowerSize);
}
@@ -107,9 +108,9 @@ public:
reallocate(m_diagSize, m_upperProfileSize, m_lowerProfileSize, m_upperSize, m_lowerSize);
}
- void resize(size_t diagSize, size_t upperProfileSize, size_t lowerProfileSize, size_t upperSize, size_t lowerSize, float reserveSizeFactor = 0) {
+ void resize(Index diagSize, Index upperProfileSize, Index lowerProfileSize, Index upperSize, Index lowerSize, float reserveSizeFactor = 0) {
if (m_allocatedSize < diagSize + upperSize + lowerSize)
- reallocate(diagSize, upperProfileSize, lowerProfileSize, upperSize + size_t(reserveSizeFactor * upperSize), lowerSize + size_t(reserveSizeFactor * lowerSize));
+ reallocate(diagSize, upperProfileSize, lowerProfileSize, upperSize + Index(reserveSizeFactor * upperSize), lowerSize + Index(reserveSizeFactor * lowerSize));
m_diagSize = diagSize;
m_upperSize = upperSize;
m_lowerSize = lowerSize;
@@ -117,27 +118,27 @@ public:
m_lowerProfileSize = lowerProfileSize;
}
- inline size_t diagSize() const {
+ inline Index diagSize() const {
return m_diagSize;
}
- inline size_t upperSize() const {
+ inline Index upperSize() const {
return m_upperSize;
}
- inline size_t lowerSize() const {
+ inline Index lowerSize() const {
return m_lowerSize;
}
- inline size_t upperProfileSize() const {
+ inline Index upperProfileSize() const {
return m_upperProfileSize;
}
- inline size_t lowerProfileSize() const {
+ inline Index lowerProfileSize() const {
return m_lowerProfileSize;
}
- inline size_t allocatedSize() const {
+ inline Index allocatedSize() const {
return m_allocatedSize;
}
@@ -145,47 +146,47 @@ public:
m_diagSize = 0;
}
- inline Scalar& diag(size_t i) {
+ inline Scalar& diag(Index i) {
return m_diag[i];
}
- inline const Scalar& diag(size_t i) const {
+ inline const Scalar& diag(Index i) const {
return m_diag[i];
}
- inline Scalar& upper(size_t i) {
+ inline Scalar& upper(Index i) {
return m_upper[i];
}
- inline const Scalar& upper(size_t i) const {
+ inline const Scalar& upper(Index i) const {
return m_upper[i];
}
- inline Scalar& lower(size_t i) {
+ inline Scalar& lower(Index i) {
return m_lower[i];
}
- inline const Scalar& lower(size_t i) const {
+ inline const Scalar& lower(Index i) const {
return m_lower[i];
}
- inline int& upperProfile(size_t i) {
+ inline Index& upperProfile(Index i) {
return m_upperProfile[i];
}
- inline const int& upperProfile(size_t i) const {
+ inline const Index& upperProfile(Index i) const {
return m_upperProfile[i];
}
- inline int& lowerProfile(size_t i) {
+ inline Index& lowerProfile(Index i) {
return m_lowerProfile[i];
}
- inline const int& lowerProfile(size_t i) const {
+ inline const Index& lowerProfile(Index i) const {
return m_lowerProfile[i];
}
- static SkylineStorage Map(int* upperProfile, int* lowerProfile, Scalar* diag, Scalar* upper, Scalar* lower, size_t size, size_t upperSize, size_t lowerSize) {
+ static SkylineStorage Map(Index* upperProfile, Index* lowerProfile, Scalar* diag, Scalar* upper, Scalar* lower, Index size, Index upperSize, Index lowerSize) {
SkylineStorage res;
res.m_upperProfile = upperProfile;
res.m_lowerProfile = lowerProfile;
@@ -202,8 +203,8 @@ public:
memset(m_diag, 0, m_diagSize * sizeof (Scalar));
memset(m_upper, 0, m_upperSize * sizeof (Scalar));
memset(m_lower, 0, m_lowerSize * sizeof (Scalar));
- memset(m_upperProfile, 0, m_diagSize * sizeof (int));
- memset(m_lowerProfile, 0, m_diagSize * sizeof (int));
+ memset(m_upperProfile, 0, m_diagSize * sizeof (Index));
+ memset(m_lowerProfile, 0, m_diagSize * sizeof (Index));
}
void prune(Scalar reference, RealScalar epsilon = dummy_precision<RealScalar>()) {
@@ -212,26 +213,26 @@ public:
protected:
- inline void reallocate(size_t diagSize, size_t upperProfileSize, size_t lowerProfileSize, size_t upperSize, size_t lowerSize) {
+ inline void reallocate(Index diagSize, Index upperProfileSize, Index lowerProfileSize, Index upperSize, Index lowerSize) {
Scalar* diag = new Scalar[diagSize];
Scalar* upper = new Scalar[upperSize];
Scalar* lower = new Scalar[lowerSize];
- int* upperProfile = new int[upperProfileSize];
- int* lowerProfile = new int[lowerProfileSize];
+ Index* upperProfile = new Index[upperProfileSize];
+ Index* lowerProfile = new Index[lowerProfileSize];
- size_t copyDiagSize = std::min(diagSize, m_diagSize);
- size_t copyUpperSize = std::min(upperSize, m_upperSize);
- size_t copyLowerSize = std::min(lowerSize, m_lowerSize);
- size_t copyUpperProfileSize = std::min(upperProfileSize, m_upperProfileSize);
- size_t copyLowerProfileSize = std::min(lowerProfileSize, m_lowerProfileSize);
+ Index copyDiagSize = std::min(diagSize, m_diagSize);
+ Index copyUpperSize = std::min(upperSize, m_upperSize);
+ Index copyLowerSize = std::min(lowerSize, m_lowerSize);
+ Index copyUpperProfileSize = std::min(upperProfileSize, m_upperProfileSize);
+ Index copyLowerProfileSize = std::min(lowerProfileSize, m_lowerProfileSize);
// copy
memcpy(diag, m_diag, copyDiagSize * sizeof (Scalar));
memcpy(upper, m_upper, copyUpperSize * sizeof (Scalar));
memcpy(lower, m_lower, copyLowerSize * sizeof (Scalar));
- memcpy(upperProfile, m_upperProfile, copyUpperProfileSize * sizeof (int));
- memcpy(lowerProfile, m_lowerProfile, copyLowerProfileSize * sizeof (int));
+ memcpy(upperProfile, m_upperProfile, copyUpperProfileSize * sizeof (Index));
+ memcpy(lowerProfile, m_lowerProfile, copyLowerProfileSize * sizeof (Index));
@@ -255,14 +256,14 @@ public:
Scalar* m_diag;
Scalar* m_upper;
Scalar* m_lower;
- int* m_upperProfile;
- int* m_lowerProfile;
- size_t m_diagSize;
- size_t m_upperSize;
- size_t m_lowerSize;
- size_t m_upperProfileSize;
- size_t m_lowerProfileSize;
- size_t m_allocatedSize;
+ Index* m_upperProfile;
+ Index* m_lowerProfile;
+ Index m_diagSize;
+ Index m_upperSize;
+ Index m_lowerSize;
+ Index m_upperProfileSize;
+ Index m_lowerProfileSize;
+ Index m_allocatedSize;
};
diff --git a/unsupported/Eigen/src/Skyline/SkylineUtil.h b/unsupported/Eigen/src/Skyline/SkylineUtil.h
index 71563adfb..7781c33e7 100644
--- a/unsupported/Eigen/src/Skyline/SkylineUtil.h
+++ b/unsupported/Eigen/src/Skyline/SkylineUtil.h
@@ -56,20 +56,22 @@ EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
}
#define EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
-EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
-EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
-EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
-EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
-EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
+ EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
+ EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
+ EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
+ EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
+ EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
#define _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
-typedef BaseClass Base; \
-typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
-typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
-enum { Flags = Eigen::ei_traits<Derived>::Flags, };
+ typedef BaseClass Base; \
+ typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
+ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
+ typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \
+ typedef typename Eigen::ei_index<StorageKind>::type Index; \
+ enum { Flags = Eigen::ei_traits<Derived>::Flags, };
#define EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived) \
-_EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SkylineMatrixBase<Derived>)
+ _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SkylineMatrixBase<Derived>)
template<typename Derived> class SkylineMatrixBase;
template<typename _Scalar, int _Flags = 0> class SkylineMatrix;