Advertisement
lostera

src/Core/Diagonal.h.patch

Jul 10th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.46 KB | None | 0 0
  1. @@ -26,6 +26,8 @@
  2.  #ifndef EIGEN_DIAGONAL_H
  3.  #define EIGEN_DIAGONAL_H
  4.  
  5.  namespace Eigen {
  6.  
  7.  /** \class Diagonal
  8.    * \ingroup Core_Module
  9.    *
  10. @@ -54,16 +56,17 @@
  11.    typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
  12.    typedef typename MatrixType::StorageKind StorageKind;
  13.    enum {
  14. -    AbsDiagIndex = DiagIndex<0 ? -DiagIndex : DiagIndex, // only used if DiagIndex != Dynamic
  15. -    // FIXME these computations are broken in the case where the matrix is rectangular and DiagIndex!=0
  16.      RowsAtCompileTime = (int(DiagIndex) == Dynamic || int(MatrixType::SizeAtCompileTime) == Dynamic) ? Dynamic
  17. -                      : (EIGEN_SIZE_MIN_PREFER_DYNAMIC(MatrixType::RowsAtCompileTime,
  18. -                                        MatrixType::ColsAtCompileTime) - AbsDiagIndex),
  19. +                      : (EIGEN_SIZE_MIN_PREFER_DYNAMIC(
  20. +                            MatrixType::RowsAtCompileTime - EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0),
  21. +                            MatrixType::ColsAtCompileTime - EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))),
  22.      ColsAtCompileTime = 1,
  23.      MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic
  24.                           : DiagIndex == Dynamic ? EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime,
  25.                                                                      MatrixType::MaxColsAtCompileTime)
  26. -                         : (EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) - AbsDiagIndex),
  27. +                         : (EIGEN_SIZE_MIN_PREFER_FIXED(
  28. +                            MatrixType::MaxRowsAtCompileTime - EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0),
  29. +                            MatrixType::MaxColsAtCompileTime - EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))),
  30.      MaxColsAtCompileTime = 1,
  31.      MaskLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
  32.      Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit | MaskLvalueBit | DirectAccessBit) & ~RowMajorBit,
  33. @@ -88,7 +91,11 @@
  34.      EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal)
  35.  
  36.      inline Index rows() const
  37. -    { return m_index.value()<0 ? (std::min)(m_matrix.cols(),m_matrix.rows()+m_index.value()) : (std::min)(m_matrix.rows(),m_matrix.cols()-m_index.value()); }
  38. +    {
  39. +       return std::min(
  40. +           m_matrix.rows() - std::max(-m_index.value(), 0),
  41. +           m_matrix.cols() - std::max( m_index.value(), 0));
  42. +   }
  43.  
  44.      inline Index cols() const { return 1; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement