[eigen] Diagonal matrices diff

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

before i can do the svd i need Banded matrices, for which i needed
some improvements in DiagonalCoeffs.
So here's a patch but as it is changing several things i thought i'd
ask for your opinion (you know who you are) before committing.

* rename DiagonalCoeffs (clumsy name) to Band. I tried first Diagonal,
but that name was already taken by a constant Diagonal which is used
for various things already.
* rename the template parameter DiagId to Index.
* keep diagonal() unchanged, returns a Band<Derived, 0>
* rename diagonal<int>() to band<int>()
* introduce diagonal(int), returning a Band<Derived, Dynamic>. The
trick here is as we already do in Block : use ei_int_if_dynamic to
store the Index in Band.
   ---> that is the improvement that i need in order to code
BandedMatrix. No need to unroll an outer loop there, and that also
will reduce compilation times (only one Band type instantiated).

Cheers,
Benoit
Index: test/submatrices.cpp
===================================================================
--- test/submatrices.cpp	(révision 965486)
+++ test/submatrices.cpp	(copie de travail)
@@ -109,7 +109,6 @@
   VERIFY_IS_APPROX(m1.diagonal(), m1.transpose().diagonal());
   m2.diagonal() = 2 * m1.diagonal();
   m2.diagonal()[0] *= 3;
-  VERIFY_IS_APPROX(m2.diagonal()[0], static_cast<Scalar>(6) * m1.diagonal()[0]);
 
   const int BlockRows = EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime,2);
   const int BlockCols = EIGEN_ENUM_MIN(MatrixType::ColsAtCompileTime,5);
@@ -145,13 +144,21 @@
     };
 
     // check sub/super diagonal
-    m2.template diagonal<N1>() = 2 * m1.template diagonal<N1>();
-    m2.template diagonal<N1>()[0] *= 3;
-    VERIFY_IS_APPROX(m2.template diagonal<N1>()[0], static_cast<Scalar>(6) * m1.template diagonal<N1>()[0]);
+    m2.template band<N1>() = 2 * m1.template band<N1>();
+    m2.template band<N1>()[0] *= 3;
+    VERIFY_IS_APPROX(m2.template band<N1>()[0], static_cast<Scalar>(6) * m1.template band<N1>()[0]);
 
-    m2.template diagonal<N2>() = 2 * m1.template diagonal<N2>();
-    m2.template diagonal<N2>()[0] *= 3;
-    VERIFY_IS_APPROX(m2.template diagonal<N2>()[0], static_cast<Scalar>(6) * m1.template diagonal<N2>()[0]);
+    m2.template band<N2>() = 2 * m1.template band<N2>();
+    m2.template band<N2>()[0] *= 3;
+    VERIFY_IS_APPROX(m2.template band<N2>()[0], static_cast<Scalar>(6) * m1.template band<N2>()[0]);
+
+    m2.band(N1) = 2 * m1.band(N1);
+    m2.band(N1)[0] *= 3;
+    VERIFY_IS_APPROX(m2.band(N1)[0], static_cast<Scalar>(6) * m1.band(N1)[0]);
+
+    m2.band(N2) = 2 * m1.band(N2);
+    m2.band(N2)[0] *= 3;
+    VERIFY_IS_APPROX(m2.band(N2)[0], static_cast<Scalar>(6) * m1.band(N2)[0]);
   }
 
   // stress some basic stuffs with block matrices
Index: Eigen/src/LU/LU.h
===================================================================
--- Eigen/src/LU/LU.h	(révision 965486)
+++ Eigen/src/LU/LU.h	(copie de travail)
@@ -333,7 +333,7 @@
     m_p(matrix.rows()),
     m_q(matrix.cols())
 {
-  const int size = matrix.diagonal().size();
+  const int size = matrix.diagonalSize();
   const int rows = matrix.rows();
   const int cols = matrix.cols();
   
@@ -402,7 +402,7 @@
 template<typename MatrixType>
 typename ei_traits<MatrixType>::Scalar LU<MatrixType>::determinant() const
 {
-  return Scalar(m_det_pq) * m_lu.diagonal().redux(ei_scalar_product_op<Scalar>());
+  return Scalar(m_det_pq) * m_lu.diagonal().prod();
 }
 
 template<typename MatrixType>
Index: Eigen/src/Cholesky/LDLT.h
===================================================================
--- Eigen/src/Cholesky/LDLT.h	(révision 965486)
+++ Eigen/src/Cholesky/LDLT.h	(copie de travail)
@@ -83,7 +83,7 @@
     }
 
     /** \returns the coefficients of the diagonal matrix D */
-    inline DiagonalCoeffs<MatrixType> vectorD(void) const { return m_matrix.diagonal(); }
+    inline Band<MatrixType,0> vectorD(void) const { return m_matrix.diagonal(); }
 
     /** \returns true if the matrix is positive (semidefinite) */
     inline bool isPositive(void) const { return m_sign == 1; }
Index: Eigen/src/QR/Tridiagonalization.h
===================================================================
--- Eigen/src/QR/Tridiagonalization.h	(révision 965486)
+++ Eigen/src/QR/Tridiagonalization.h	(copie de travail)
@@ -60,10 +60,10 @@
     typedef Matrix<RealScalar, Size, 1> DiagonalType;
     typedef Matrix<RealScalar, SizeMinusOne, 1> SubDiagonalType;
 
-    typedef typename NestByValue<DiagonalCoeffs<MatrixType> >::RealReturnType DiagonalReturnType;
+    typedef typename NestByValue<Band<MatrixType,0> >::RealReturnType DiagonalReturnType;
 
-    typedef typename NestByValue<DiagonalCoeffs<
-        NestByValue<Block<MatrixType,SizeMinusOne,SizeMinusOne> > > >::RealReturnType SubDiagonalReturnType;
+    typedef typename NestByValue<Band<
+        NestByValue<Block<MatrixType,SizeMinusOne,SizeMinusOne> >,0 > >::RealReturnType SubDiagonalReturnType;
 
     /** This constructor initializes a Tridiagonalization object for
       * further use with Tridiagonalization::compute()
Index: Eigen/src/QR/HessenbergDecomposition.h
===================================================================
--- Eigen/src/QR/HessenbergDecomposition.h	(révision 965486)
+++ Eigen/src/QR/HessenbergDecomposition.h	(copie de travail)
@@ -58,10 +58,10 @@
     typedef Matrix<RealScalar, Size, 1> DiagonalType;
     typedef Matrix<RealScalar, SizeMinusOne, 1> SubDiagonalType;
 
-    typedef typename NestByValue<DiagonalCoeffs<MatrixType> >::RealReturnType DiagonalReturnType;
+    typedef typename NestByValue<Band<MatrixType,0> >::RealReturnType DiagonalReturnType;
 
-    typedef typename NestByValue<DiagonalCoeffs<
-        NestByValue<Block<MatrixType,SizeMinusOne,SizeMinusOne> > > >::RealReturnType SubDiagonalReturnType;
+    typedef typename NestByValue<Band<
+        NestByValue<Block<MatrixType,SizeMinusOne,SizeMinusOne> >,0 > >::RealReturnType SubDiagonalReturnType;
 
     /** This constructor initializes a HessenbergDecomposition object for
       * further use with HessenbergDecomposition::compute()
Index: Eigen/src/Core/Band.h
===================================================================
--- Eigen/src/Core/Band.h	(révision 964038)
+++ Eigen/src/Core/Band.h	(copie de travail)
@@ -22,87 +22,88 @@
 // License and a copy of the GNU General Public License along with
 // Eigen. If not, see <http://www.gnu.org/licenses/>.
 
-#ifndef EIGEN_DIAGONALCOEFFS_H
-#define EIGEN_DIAGONALCOEFFS_H
+#ifndef EIGEN_BAND_H
+#define EIGEN_BAND_H
 
-/** \class DiagonalCoeffs
+/** \class Band
   *
-  * \brief Expression of a sub/main/super diagonal of a matrix
+  * \brief Expression of a diagonal band in a matrix
   *
   * \param MatrixType the type of the object in which we are taking s sub/main/super diagonal
-  * \param DiagId the index of the sub/super diagonal. The default is 0 and it means the main diagonal.
+  * \param Index the index of the sub/super diagonal. The default is 0 and it means the main diagonal.
+  *              You can also use Dynamic so the index can be set at runtime.
   *
   * The matrix is not required to be square.
   *
   * This class represents an expression of the main diagonal, or any sub/super diagonal
-  * of a square matrix. It is the return type of MatrixBase::diagonal() and most of the
+  * of a square matrix. It is the return type of MatrixBase::diagonal() and MatrixBase::band(int) and most of the
   * time this is the only way it is used.
   *
-  * \sa MatrixBase::diagonal()
+  * \sa MatrixBase::diagonal() and MatrixBase::band(int)
   */
-template<typename MatrixType, int DiagId>
-struct ei_traits<DiagonalCoeffs<MatrixType,DiagId> >
+template<typename MatrixType, int Index>
+struct ei_traits<Band<MatrixType,Index> >
 {
   typedef typename MatrixType::Scalar Scalar;
   typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
   typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
   enum {
-    AbsDiagId = DiagId<0 ? -DiagId : DiagId,
-    RowsAtCompileTime = int(MatrixType::SizeAtCompileTime) == Dynamic ? Dynamic
+    AbsIndex = Index<0 ? -Index : Index, // only used if Index != Dynamic
+    RowsAtCompileTime = (int(Index) == Dynamic || int(MatrixType::SizeAtCompileTime) == Dynamic) ? Dynamic
                       : (EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime,
-                                        MatrixType::ColsAtCompileTime) - AbsDiagId),
+                                        MatrixType::ColsAtCompileTime) - AbsIndex),
     ColsAtCompileTime = 1,
     MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic
                          : (EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime,
-                                          MatrixType::MaxColsAtCompileTime) - AbsDiagId),
+                                          MatrixType::MaxColsAtCompileTime) - AbsIndex),
     MaxColsAtCompileTime = 1,
     Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit),
     CoeffReadCost = _MatrixTypeNested::CoeffReadCost
   };
 };
 
-template<typename MatrixType, int DiagId> class DiagonalCoeffs
-   : public MatrixBase<DiagonalCoeffs<MatrixType, DiagId> >
+template<typename MatrixType, int Index> class Band
+   : public MatrixBase<Band<MatrixType, Index> >
 {
-    enum {
-      AbsDiagId = DiagId<0 ? -DiagId : DiagId,
-      OffsetRow = DiagId<0 ? -DiagId : 0,
-      OffsetCol = DiagId<0 ? 0 : DiagId
-    };
+    // some compilers may fail to optimize std::max etc in case of compile-time constants...
+    EIGEN_STRONG_INLINE int absIndex() const { return m_index.value()>0 ? m_index.value() : -m_index.value(); }
+    EIGEN_STRONG_INLINE int rowOffset() const { return m_index.value()>0 ? 0 : -m_index.value(); }
+    EIGEN_STRONG_INLINE int colOffset() const { return m_index.value()>0 ? m_index.value() : 0; }
+    
   public:
 
-    EIGEN_GENERIC_PUBLIC_INTERFACE(DiagonalCoeffs)
+    EIGEN_GENERIC_PUBLIC_INTERFACE(Band)
 
-    inline DiagonalCoeffs(const MatrixType& matrix) : m_matrix(matrix) {}
+    inline Band(const MatrixType& matrix, int index = Index) : m_matrix(matrix), m_index(index) {}
 
-    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
+    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Band)
 
-    inline int rows() const { return std::min(m_matrix.rows(), m_matrix.cols()) - AbsDiagId; }
+    inline int rows() const{ return m_matrix.diagonalSize() - absIndex(); }
     inline int cols() const { return 1; }
 
     inline Scalar& coeffRef(int row, int)
     {
-      return m_matrix.const_cast_derived().coeffRef(row+OffsetRow, row+OffsetCol);
+      return m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset());
     }
 
     inline const Scalar coeff(int row, int) const
     {
-      return m_matrix.coeff(row+OffsetRow, row+OffsetCol);
+      return m_matrix.coeff(row+rowOffset(), row+colOffset());
     }
 
     inline Scalar& coeffRef(int index)
     {
-      return m_matrix.const_cast_derived().coeffRef(index+OffsetRow, index+OffsetCol);
+      return m_matrix.const_cast_derived().coeffRef(index+rowOffset(), index+colOffset());
     }
 
     inline const Scalar coeff(int index) const
     {
-      return m_matrix.coeff(index+OffsetRow, index+OffsetCol);
+      return m_matrix.coeff(index+rowOffset(), index+colOffset());
     }
 
   protected:
-
     const typename MatrixType::Nested m_matrix;
+    const ei_int_if_dynamic<Index> m_index;
 };
 
 /** \returns an expression of the main diagonal of the matrix \c *this
@@ -112,48 +113,74 @@
   * Example: \include MatrixBase_diagonal.cpp
   * Output: \verbinclude MatrixBase_diagonal.out
   *
-  * \sa class DiagonalCoeffs */
+  * \sa class Band */
 template<typename Derived>
-inline DiagonalCoeffs<Derived>
+inline Band<Derived, 0>
 MatrixBase<Derived>::diagonal()
 {
-  return DiagonalCoeffs<Derived>(derived());
+  return Band<Derived, 0>(derived());
 }
 
 /** This is the const version of diagonal(). */
 template<typename Derived>
-inline const DiagonalCoeffs<Derived>
+inline const Band<Derived, 0>
 MatrixBase<Derived>::diagonal() const
 {
-  return DiagonalCoeffs<Derived>(derived());
+  return Band<Derived, 0>(derived());
 }
 
-/** \returns an expression of the \a Id-th sub or super diagonal of the matrix \c *this
+/** \returns an expression of the \a Index-th sub or super diagonal of the matrix \c *this
   *
   * \c *this is not required to be square.
   *
-  * The template parameter \a Id represent a super diagonal if \a Id > 0
-  * and a sub diagonal otherwise. \a Id == 0 is equivalent to the main diagonal.
+  * The template parameter \a Index represent a super diagonal if \a Index > 0
+  * and a sub diagonal otherwise. \a Index == 0 is equivalent to the main diagonal.
   *
-  * Example: \include MatrixBase_diagonal_int.cpp
-  * Output: \verbinclude MatrixBase_diagonal_int.out
+  * Example: \include MatrixBase_band_int.cpp
+  * Output: \verbinclude MatrixBase_band_int.out
   *
-  * \sa MatrixBase::diagonal(), class DiagonalCoeffs */
+  * \sa MatrixBase::diagonal(), class Band */
 template<typename Derived>
-template<int Id>
-inline DiagonalCoeffs<Derived,Id>
-MatrixBase<Derived>::diagonal()
+inline Band<Derived, Dynamic>
+MatrixBase<Derived>::band(int index)
 {
-  return DiagonalCoeffs<Derived,Id>(derived());
+  return Band<Derived, Dynamic>(derived(), index);
 }
 
-/** This is the const version of diagonal<int>(). */
+/** This is the const version of band(int). */
 template<typename Derived>
-template<int Id>
-inline const DiagonalCoeffs<Derived,Id>
-MatrixBase<Derived>::diagonal() const
+inline const Band<Derived, Dynamic>
+MatrixBase<Derived>::band(int index) const
 {
-  return DiagonalCoeffs<Derived,Id>(derived());
+  return Band<Derived, Dynamic>(derived(), index);
 }
 
-#endif // EIGEN_DIAGONALCOEFFS_H
+/** \returns an expression of the \a Index-th sub or super diagonal of the matrix \c *this
+  *
+  * \c *this is not required to be square.
+  *
+  * The template parameter \a Index represent a super diagonal if \a Index > 0
+  * and a sub diagonal otherwise. \a Index == 0 is equivalent to the main diagonal.
+  *
+  * Example: \include MatrixBase_band_template_int.cpp
+  * Output: \verbinclude MatrixBase_band_template_int.out
+  *
+  * \sa MatrixBase::diagonal(), class Band */
+template<typename Derived>
+template<int Index>
+inline Band<Derived,Index>
+MatrixBase<Derived>::band()
+{
+  return Band<Derived,Index>(derived());
+}
+
+/** This is the const version of band<int>(). */
+template<typename Derived>
+template<int Index>
+inline const Band<Derived,Index>
+MatrixBase<Derived>::band() const
+{
+  return Band<Derived,Index>(derived());
+}
+
+#endif // EIGEN_BAND_H

Modification de propriétés sur Eigen/src/Core/Band.h
___________________________________________________________________
Ajouté : svn:mergeinfo

Index: Eigen/src/Core/MatrixBase.h
===================================================================
--- Eigen/src/Core/MatrixBase.h	(révision 965486)
+++ Eigen/src/Core/MatrixBase.h	(copie de travail)
@@ -167,9 +167,12 @@
     inline int rows() const { return derived().rows(); }
     /** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
     inline int cols() const { return derived().cols(); }
-    /** \returns the number of coefficients, which is \a rows()*cols().
+    /** \returns the number of coefficients, which is rows()*cols().
       * \sa rows(), cols(), SizeAtCompileTime. */
     inline int size() const { return rows() * cols(); }
+    /** \returns the size of the main diagonal, which is min(rows(),cols()).
+      * \sa rows(), cols(), SizeAtCompileTime. */
+    inline int diagonalSize() const { return std::min(rows(),cols()); }
     /** \returns the number of nonzero coefficients which is in practice the number
       * of stored coefficients. */
     inline int nonZeros() const { return derived().nonZeros(); }
@@ -419,12 +422,15 @@
     template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType segment(int start);
     template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType segment(int start) const;
 
-    DiagonalCoeffs<Derived> diagonal();
-    const DiagonalCoeffs<Derived> diagonal() const;
+    Band<Derived,0> diagonal();
+    const Band<Derived,0> diagonal() const;
 
-    template<int Id> DiagonalCoeffs<Derived,Id> diagonal();
-    template<int Id> const DiagonalCoeffs<Derived,Id> diagonal() const;
-
+    template<int Index> Band<Derived,Index> band();
+    template<int Index> const Band<Derived,Index> band() const;
+    
+    Band<Derived, Dynamic> band(int index);
+    const Band<Derived, Dynamic> band(int index) const;
+    
     template<unsigned int Mode> Part<Derived, Mode> part();
     template<unsigned int Mode> const Part<Derived, Mode> part() const;
 
Index: Eigen/src/Core/DiagonalCoeffs.h
===================================================================
--- Eigen/src/Core/DiagonalCoeffs.h	(révision 965486)
+++ Eigen/src/Core/DiagonalCoeffs.h	(copie de travail)
@@ -1,159 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
-//
-// Eigen is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 3 of the License, or (at your option) any later version.
-//
-// Alternatively, you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of
-// the License, or (at your option) any later version.
-//
-// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License and a copy of the GNU General Public License along with
-// Eigen. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef EIGEN_DIAGONALCOEFFS_H
-#define EIGEN_DIAGONALCOEFFS_H
-
-/** \class DiagonalCoeffs
-  *
-  * \brief Expression of a sub/main/super diagonal of a matrix
-  *
-  * \param MatrixType the type of the object in which we are taking s sub/main/super diagonal
-  * \param DiagId the index of the sub/super diagonal. The default is 0 and it means the main diagonal.
-  *
-  * The matrix is not required to be square.
-  *
-  * This class represents an expression of the main diagonal, or any sub/super diagonal
-  * of a square matrix. It is the return type of MatrixBase::diagonal() and most of the
-  * time this is the only way it is used.
-  *
-  * \sa MatrixBase::diagonal()
-  */
-template<typename MatrixType, int DiagId>
-struct ei_traits<DiagonalCoeffs<MatrixType,DiagId> >
-{
-  typedef typename MatrixType::Scalar Scalar;
-  typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
-  typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
-  enum {
-    AbsDiagId = DiagId<0 ? -DiagId : DiagId,
-    RowsAtCompileTime = int(MatrixType::SizeAtCompileTime) == Dynamic ? Dynamic
-                      : (EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime,
-                                        MatrixType::ColsAtCompileTime) - AbsDiagId),
-    ColsAtCompileTime = 1,
-    MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic
-                         : (EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime,
-                                          MatrixType::MaxColsAtCompileTime) - AbsDiagId),
-    MaxColsAtCompileTime = 1,
-    Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit),
-    CoeffReadCost = _MatrixTypeNested::CoeffReadCost
-  };
-};
-
-template<typename MatrixType, int DiagId> class DiagonalCoeffs
-   : public MatrixBase<DiagonalCoeffs<MatrixType, DiagId> >
-{
-    enum {
-      AbsDiagId = DiagId<0 ? -DiagId : DiagId,
-      OffsetRow = DiagId<0 ? -DiagId : 0,
-      OffsetCol = DiagId<0 ? 0 : DiagId
-    };
-  public:
-
-    EIGEN_GENERIC_PUBLIC_INTERFACE(DiagonalCoeffs)
-
-    inline DiagonalCoeffs(const MatrixType& matrix) : m_matrix(matrix) {}
-
-    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
-
-    inline int rows() const { return std::min(m_matrix.rows(), m_matrix.cols()) - AbsDiagId; }
-    inline int cols() const { return 1; }
-
-    inline Scalar& coeffRef(int row, int)
-    {
-      return m_matrix.const_cast_derived().coeffRef(row+OffsetRow, row+OffsetCol);
-    }
-
-    inline const Scalar coeff(int row, int) const
-    {
-      return m_matrix.coeff(row+OffsetRow, row+OffsetCol);
-    }
-
-    inline Scalar& coeffRef(int index)
-    {
-      return m_matrix.const_cast_derived().coeffRef(index+OffsetRow, index+OffsetCol);
-    }
-
-    inline const Scalar coeff(int index) const
-    {
-      return m_matrix.coeff(index+OffsetRow, index+OffsetCol);
-    }
-
-  protected:
-
-    const typename MatrixType::Nested m_matrix;
-};
-
-/** \returns an expression of the main diagonal of the matrix \c *this
-  *
-  * \c *this is not required to be square.
-  *
-  * Example: \include MatrixBase_diagonal.cpp
-  * Output: \verbinclude MatrixBase_diagonal.out
-  *
-  * \sa class DiagonalCoeffs */
-template<typename Derived>
-inline DiagonalCoeffs<Derived>
-MatrixBase<Derived>::diagonal()
-{
-  return DiagonalCoeffs<Derived>(derived());
-}
-
-/** This is the const version of diagonal(). */
-template<typename Derived>
-inline const DiagonalCoeffs<Derived>
-MatrixBase<Derived>::diagonal() const
-{
-  return DiagonalCoeffs<Derived>(derived());
-}
-
-/** \returns an expression of the \a Id-th sub or super diagonal of the matrix \c *this
-  *
-  * \c *this is not required to be square.
-  *
-  * The template parameter \a Id represent a super diagonal if \a Id > 0
-  * and a sub diagonal otherwise. \a Id == 0 is equivalent to the main diagonal.
-  *
-  * Example: \include MatrixBase_diagonal_int.cpp
-  * Output: \verbinclude MatrixBase_diagonal_int.out
-  *
-  * \sa MatrixBase::diagonal(), class DiagonalCoeffs */
-template<typename Derived>
-template<int Id>
-inline DiagonalCoeffs<Derived,Id>
-MatrixBase<Derived>::diagonal()
-{
-  return DiagonalCoeffs<Derived,Id>(derived());
-}
-
-/** This is the const version of diagonal<int>(). */
-template<typename Derived>
-template<int Id>
-inline const DiagonalCoeffs<Derived,Id>
-MatrixBase<Derived>::diagonal() const
-{
-  return DiagonalCoeffs<Derived,Id>(derived());
-}
-
-#endif // EIGEN_DIAGONALCOEFFS_H
Index: Eigen/src/Core/Transpose.h
===================================================================
--- Eigen/src/Core/Transpose.h	(révision 965486)
+++ Eigen/src/Core/Transpose.h	(copie de travail)
@@ -138,7 +138,7 @@
   * m = m.transpose().eval();
   * \endcode
   *
-  * \sa transposeInPlace(), adjoint(), class DiagonalCoeffs */
+  * \sa transposeInPlace(), adjoint() */
 template<typename Derived>
 inline Transpose<Derived>
 MatrixBase<Derived>::transpose()
Index: Eigen/src/Core/util/Constants.h
===================================================================
--- Eigen/src/Core/util/Constants.h	(révision 965486)
+++ Eigen/src/Core/util/Constants.h	(copie de travail)
@@ -140,7 +140,7 @@
   * First, references to the coefficients must be available through coeffRef(int, int). This rules out read-only
   * expressions whose coefficients are computed on demand by coeff(int, int). Second, the memory layout of the
   * array of coefficients must be exactly the natural one suggested by rows(), cols(), stride(), and the RowMajorBit.
-  * This rules out expressions such as DiagonalCoeffs, whose coefficients, though referencable, do not have
+  * This rules out expressions such as Diagonal, whose coefficients, though referencable, do not have
   * such a regular memory layout.
   */
 const unsigned int DirectAccessBit = 0x20;
@@ -186,14 +186,12 @@
                                   | EvalBeforeAssigningBit
                                   | SparseBit;
 
-// Possible values for the Mode parameter of part() and of extract()
+// Possible values for the Mode parameter of part()
 const unsigned int UpperTriangular = UpperTriangularBit;
 const unsigned int StrictlyUpperTriangular = UpperTriangularBit | ZeroDiagBit;
 const unsigned int LowerTriangular = LowerTriangularBit;
 const unsigned int StrictlyLowerTriangular = LowerTriangularBit | ZeroDiagBit;
 const unsigned int SelfAdjoint = SelfAdjointBit;
-
-// additional possible values for the Mode parameter of extract()
 const unsigned int UnitUpperTriangular = UpperTriangularBit | UnitDiagBit;
 const unsigned int UnitLowerTriangular = LowerTriangularBit | UnitDiagBit;
 const unsigned int Diagonal = UpperTriangular | LowerTriangular;
Index: Eigen/src/Core/util/ForwardDeclarations.h
===================================================================
--- Eigen/src/Core/util/ForwardDeclarations.h	(révision 965486)
+++ Eigen/src/Core/util/ForwardDeclarations.h	(copie de travail)
@@ -48,7 +48,7 @@
 template<typename CoeffsVectorType, typename Derived> class DiagonalMatrixBase;
 template<typename CoeffsVectorType> class DiagonalMatrixWrapper;
 template<typename _Scalar, int _Size> class DiagonalMatrix;
-template<typename MatrixType, int DiagId=0> class DiagonalCoeffs;
+template<typename MatrixType, int Index> class Band;
 template<typename MatrixType, int PacketAccess = AsRequested> class Map;
 template<typename MatrixType, unsigned int Mode> class Part;
 template<typename MatrixType, unsigned int Mode> class Extract;
Index: Eigen/src/Sparse/SparseMatrixBase.h
===================================================================
--- Eigen/src/Sparse/SparseMatrixBase.h	(révision 965486)
+++ Eigen/src/Sparse/SparseMatrixBase.h	(copie de travail)
@@ -384,8 +384,8 @@
 //     template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType segment(int start);
 //     template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType segment(int start) const;
 
-//     DiagonalCoeffs<Derived> diagonal();
-//     const DiagonalCoeffs<Derived> diagonal() const;
+//     Diagonal<Derived> diagonal();
+//     const Diagonal<Derived> diagonal() const;
 
 //     template<unsigned int Mode> Part<Derived, Mode> part();
 //     template<unsigned int Mode> const Part<Derived, Mode> part() const;
Index: Eigen/Core
===================================================================
--- Eigen/Core	(révision 965486)
+++ Eigen/Core	(copie de travail)
@@ -166,7 +166,7 @@
 #include "src/Core/Minor.h"
 #include "src/Core/Transpose.h"
 #include "src/Core/DiagonalMatrix.h"
-#include "src/Core/DiagonalCoeffs.h"
+#include "src/Core/Band.h"
 #include "src/Core/Redux.h"
 #include "src/Core/Visitor.h"
 #include "src/Core/Fuzzy.h"
Index: doc/snippets/MatrixBase_diagonal_int.cpp
===================================================================
--- doc/snippets/MatrixBase_diagonal_int.cpp	(révision 965486)
+++ doc/snippets/MatrixBase_diagonal_int.cpp	(copie de travail)
@@ -1,5 +0,0 @@
-Matrix4i m = Matrix4i::Random();
-cout << "Here is the matrix m:" << endl << m << endl;
-cout << "Here are the coefficients on the 1st super-diagonal and 2nd sub-diagonal of m:" << endl
-     << m.diagonal<1>().transpose() << endl
-     << m.diagonal<-2>().transpose() << endl;

Modification de propriétés sur doc/snippets/MatrixBase_band_template_int.cpp
___________________________________________________________________
Ajouté : svn:mergeinfo

Index: doc/snippets/MatrixBase_band_int.cpp
===================================================================
--- doc/snippets/MatrixBase_band_int.cpp	(révision 964038)
+++ doc/snippets/MatrixBase_band_int.cpp	(copie de travail)
@@ -1,5 +1,5 @@
 Matrix4i m = Matrix4i::Random();
 cout << "Here is the matrix m:" << endl << m << endl;
 cout << "Here are the coefficients on the 1st super-diagonal and 2nd sub-diagonal of m:" << endl
-     << m.diagonal<1>().transpose() << endl
-     << m.diagonal<-2>().transpose() << endl;
+     << m.diagonal(1).transpose() << endl
+     << m.diagonal(-2).transpose() << endl;

Modification de propriétés sur doc/snippets/MatrixBase_band_int.cpp
___________________________________________________________________
Ajouté : svn:mergeinfo



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/