Re: [eigen] Propagating Max*AtCompileTime template parameters to decompositions

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


<snip>
>>>>> >>> Supreme refinement is to add a unit test for that. We already have
>>>>> >>> the
>>>>> >>> skeleton in the nomalloc test (test/nomalloc.cpp). Indeed, when
>>>>> >>> EIGEN_NO_MALLOC is defined, any heap allocation will cause an assert
>>>>> >>> failure, which in the context of unit tests we convert into an
>>>>> >>> exception.
>>>>> >>>
>>>>> >>> So don't hesitate to expand the nomalloc.cpp test, just with new
>>>>> >>> executable targets (CALL_SUBTEST_x for a new value of x up to 16) so
>>>>> >>> that no single executable gets too big. Testing only 'float' is good
>>>>> >>> enough.
</snip>

I wouldn't call it supreme refinement ;) but here goes my patch.. Feel free to voice out suggestions/improvements.

Best,

Adolfo
# HG changeset patch
# User Adolfo Rodriguez Tsouroukdissian <adolfo.rodriguez@xxxxxxxxxxxxxxxx>
# Date 1268073087 -3600
# Node ID 4091dcef3e750b71d24d659d0e40500344b0d96c
# Parent  ca79aaf246c18833d51409b972e492198f8d21a7
Propagate all five matrix template parameters to members and temporaries of decomposition classes. One particular advantage of this is that decomposing matrices with max sizes known at compile time will not allocate.
NOTE: The ComplexEigenSolver class currently _does_ allocate (line 135 of Eigenvalues/ComplexEigenSolver.h), but the reason appears to be in the implementation of matrix-matrix products, and not in the decomposition itself.
The nomalloc unit test has been extended to verify that decompositions do not allocate when max sizes are specified. There are currently two workarounds to prevent the test from failing (see comments in test/nomalloc.cpp), both of which are related to matrix products that allocate on the stack.

diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Cholesky/LDLT.h
--- a/Eigen/src/Cholesky/LDLT.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Cholesky/LDLT.h	Mon Mar 08 19:31:27 2010 +0100
@@ -56,11 +56,18 @@
 {
   public:
     typedef _MatrixType MatrixType;
+    enum {
+      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
-    typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
-    typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;
-    typedef Matrix<int, 1, MatrixType::RowsAtCompileTime> IntRowVectorType;
+    typedef Matrix<Scalar, ColsAtCompileTime, 1,  Options, MaxColsAtCompileTime, 1> VectorType;
+    typedef Matrix<int, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> IntColVectorType;
+    typedef Matrix<int, 1, RowsAtCompileTime, Options, 1, MaxRowsAtCompileTime> IntRowVectorType;
 
     /** \brief Default Constructor.
       *
@@ -201,7 +208,7 @@
   // By using a temorary, packet-aligned products are guarenteed. In the LLT
   // case this is unnecessary because the diagonal is included and will always
   // have optimal alignment.
-  Matrix<Scalar,MatrixType::RowsAtCompileTime,1> _temporary(size);
+  Matrix<Scalar, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> _temporary(size);
 
   for (int j = 0; j < size; ++j)
   {
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Cholesky/LLT.h
--- a/Eigen/src/Cholesky/LLT.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Cholesky/LLT.h	Mon Mar 08 19:31:27 2010 +0100
@@ -57,9 +57,15 @@
 {
   public:
     typedef _MatrixType MatrixType;
+    enum {
+      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
-    typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
+    typedef Matrix<Scalar, ColsAtCompileTime, 1, Options, MaxColsAtCompileTime, 1> VectorType;
 
     enum {
       PacketSize = ei_packet_traits<Scalar>::size,
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Eigenvalues/ComplexEigenSolver.h
--- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h	Mon Mar 08 19:31:27 2010 +0100
@@ -41,11 +41,18 @@
 {
   public:
     typedef _MatrixType MatrixType;
+    enum {
+      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<Scalar>::Real RealScalar;
     typedef std::complex<RealScalar> Complex;
-    typedef Matrix<Complex, MatrixType::ColsAtCompileTime,1> EigenvalueType;
-    typedef Matrix<Complex, MatrixType::RowsAtCompileTime,MatrixType::ColsAtCompileTime> EigenvectorType;
+    typedef Matrix<Complex, ColsAtCompileTime, 1, Options, MaxColsAtCompileTime, 1> EigenvalueType;
+    typedef Matrix<Complex, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, ColsAtCompileTime> EigenvectorType;
 
     /**
     * \brief Default Constructor.
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Eigenvalues/ComplexSchur.h
--- a/Eigen/src/Eigenvalues/ComplexSchur.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Eigenvalues/ComplexSchur.h	Mon Mar 08 19:31:27 2010 +0100
@@ -45,10 +45,17 @@
 {
   public:
     typedef _MatrixType MatrixType;
+    enum {
+      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<Scalar>::Real RealScalar;
     typedef std::complex<RealScalar> Complex;
-    typedef Matrix<Complex, MatrixType::RowsAtCompileTime,MatrixType::ColsAtCompileTime> ComplexMatrixType;
+    typedef Matrix<Complex, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> ComplexMatrixType;
     enum {
       Size = MatrixType::RowsAtCompileTime
     };
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Eigenvalues/EigenSolver.h
--- a/Eigen/src/Eigenvalues/EigenSolver.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Eigenvalues/EigenSolver.h	Mon Mar 08 19:31:27 2010 +0100
@@ -45,13 +45,19 @@
   public:
 
     typedef _MatrixType MatrixType;
+    enum {
+      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<Scalar>::Real RealScalar;
     typedef std::complex<RealScalar> Complex;
-    typedef Matrix<Complex, MatrixType::ColsAtCompileTime, 1> EigenvalueType;
-    typedef Matrix<Complex, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime> EigenvectorType;
-    typedef Matrix<RealScalar, MatrixType::ColsAtCompileTime, 1> RealVectorType;
-    typedef Matrix<RealScalar, Dynamic, 1> RealVectorTypeX;
+    typedef Matrix<Complex, ColsAtCompileTime, 1, Options, MaxColsAtCompileTime, 1> EigenvalueType;
+    typedef Matrix<Complex, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> EigenvectorType;
+    typedef Matrix<RealScalar, ColsAtCompileTime, 1, Options, MaxColsAtCompileTime, 1> RealVectorType;
 
     /**
     * \brief Default Constructor.
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Eigenvalues/HessenbergDecomposition.h
--- a/Eigen/src/Eigenvalues/HessenbergDecomposition.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Eigenvalues/HessenbergDecomposition.h	Mon Mar 08 19:31:27 2010 +0100
@@ -44,17 +44,17 @@
   public:
 
     typedef _MatrixType MatrixType;
+    enum {
+      Size = MatrixType::RowsAtCompileTime,
+      SizeMinusOne = Size == Dynamic ? Dynamic : Size - 1,
+      Options = MatrixType::Options,
+      MaxSize = MatrixType::MaxRowsAtCompileTime,
+      MaxSizeMinusOne = MaxSize == Dynamic ? Dynamic : MaxSize - 1
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<Scalar>::Real RealScalar;
-
-    enum {
-      Size = MatrixType::RowsAtCompileTime,
-      SizeMinusOne = MatrixType::RowsAtCompileTime==Dynamic
-                   ? Dynamic
-                   : MatrixType::RowsAtCompileTime-1
-    };
-
-    typedef Matrix<Scalar, SizeMinusOne, 1> CoeffVectorType;
+    typedef Matrix<Scalar, SizeMinusOne, 1, Options, MaxSizeMinusOne, 1> CoeffVectorType;
+    typedef Matrix<Scalar, 1, Size, Options, 1, MaxSize> VectorType;
 
     /** This constructor initializes a HessenbergDecomposition object for
       * further use with HessenbergDecomposition::compute()
@@ -143,7 +143,7 @@
 {
   assert(matA.rows()==matA.cols());
   int n = matA.rows();
-  Matrix<Scalar,1,Dynamic> temp(n);
+  VectorType temp(n);
   for (int i = 0; i<n-1; ++i)
   {
     // let's consider the vector v = i-th column starting at position i+1
@@ -174,7 +174,7 @@
 {
   int n = m_matrix.rows();
   MatrixType matQ = MatrixType::Identity(n,n);
-  Matrix<Scalar,1,MatrixType::ColsAtCompileTime> temp(n);
+  VectorType temp(n);
   for (int i = n-2; i>=0; i--)
   {
     matQ.corner(BottomRight,n-i-1,n-i-1)
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
--- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h	Mon Mar 08 19:31:27 2010 +0100
@@ -42,13 +42,17 @@
 {
   public:
 
-    enum {Size = _MatrixType::RowsAtCompileTime };
     typedef _MatrixType MatrixType;
+    enum {
+      Size = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<Scalar>::Real RealScalar;
     typedef std::complex<RealScalar> Complex;
-    typedef Matrix<RealScalar, MatrixType::ColsAtCompileTime, 1> RealVectorType;
-    typedef Matrix<RealScalar, Dynamic, 1> RealVectorTypeX;
+    typedef Matrix<RealScalar, ColsAtCompileTime, 1, Options, MaxColsAtCompileTime, 1> RealVectorType;
     typedef Tridiagonalization<MatrixType> TridiagonalizationType;
 //     typedef typename TridiagonalizationType::TridiagonalMatrixType TridiagonalMatrixType;
 
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/Eigenvalues/Tridiagonalization.h
--- a/Eigen/src/Eigenvalues/Tridiagonalization.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/Eigenvalues/Tridiagonalization.h	Mon Mar 08 19:31:27 2010 +0100
@@ -50,16 +50,18 @@
 
     enum {
       Size = MatrixType::RowsAtCompileTime,
-      SizeMinusOne = MatrixType::RowsAtCompileTime==Dynamic
-                   ? Dynamic
-                   : MatrixType::RowsAtCompileTime-1,
+      SizeMinusOne = Size == Dynamic ? Dynamic : Size - 1,
+      Options = MatrixType::Options,
+      MaxSize = MatrixType::MaxRowsAtCompileTime,
+      MaxSizeMinusOne = MaxSize == Dynamic ? Dynamic : MaxSize - 1,
       PacketSize = ei_packet_traits<Scalar>::size
     };
 
-    typedef Matrix<Scalar, SizeMinusOne, 1> CoeffVectorType;
-    typedef Matrix<RealScalar, Size, 1> DiagonalType;
-    typedef Matrix<RealScalar, SizeMinusOne, 1> SubDiagonalType;
-
+    typedef Matrix<Scalar, SizeMinusOne, 1, Options, MaxSizeMinusOne, 1> CoeffVectorType;
+    typedef Matrix<RealScalar, Size, 1, Options, MaxSize, 1> DiagonalType;
+    typedef Matrix<RealScalar, SizeMinusOne, 1, Options, MaxSizeMinusOne, 1> SubDiagonalType;
+    typedef Matrix<Scalar, 1, Size, Options, 1, MaxSize> RowVectorType;
+    
     typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
               typename Diagonal<MatrixType,0>::RealReturnType,
               Diagonal<MatrixType,0>
@@ -238,7 +240,7 @@
   QDerived& matQ = q->derived();
   int n = m_matrix.rows();
   matQ = MatrixType::Identity(n,n);
-  Matrix<Scalar,1,Dynamic> aux(n);
+  RowVectorType aux(n);
   for (int i = n-2; i>=0; i--)
   {
     matQ.corner(BottomRight,n-i-1,n-i-1)
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/LU/FullPivLU.h
--- a/Eigen/src/LU/FullPivLU.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/LU/FullPivLU.h	Mon Mar 08 19:31:27 2010 +0100
@@ -59,12 +59,19 @@
 {
   public:
     typedef _MatrixType MatrixType;
+    enum {
+      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
-    typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;
-    typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;
-    typedef PermutationMatrix<MatrixType::ColsAtCompileTime> PermutationQType;
-    typedef PermutationMatrix<MatrixType::RowsAtCompileTime> PermutationPType;
+    typedef Matrix<int, 1, ColsAtCompileTime, Options, 1, MaxColsAtCompileTime> IntRowVectorType;
+    typedef Matrix<int, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> IntColVectorType;
+    typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationQType;
+    typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationPType;
 
     /**
       * \brief Default Constructor.
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/LU/PartialPivLU.h
--- a/Eigen/src/LU/PartialPivLU.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/LU/PartialPivLU.h	Mon Mar 08 19:31:27 2010 +0100
@@ -62,15 +62,18 @@
   public:
 
     typedef _MatrixType MatrixType;
+    enum {
+      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
+      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
+      Options = MatrixType::Options,
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
+    };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
-    typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> PermutationVectorType;
-    typedef PermutationMatrix<MatrixType::RowsAtCompileTime> PermutationType;
+    typedef Matrix<int, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> PermutationVectorType;
+    typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType;
 
-    enum { MaxSmallDimAtCompileTime = EIGEN_SIZE_MIN(
-             MatrixType::MaxColsAtCompileTime,
-             MatrixType::MaxRowsAtCompileTime)
-    };
 
     /**
     * \brief Default Constructor.
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/QR/ColPivHouseholderQR.h
--- a/Eigen/src/QR/ColPivHouseholderQR.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/QR/ColPivHouseholderQR.h	Mon Mar 08 19:31:27 2010 +0100
@@ -51,16 +51,19 @@
       RowsAtCompileTime = MatrixType::RowsAtCompileTime,
       ColsAtCompileTime = MatrixType::ColsAtCompileTime,
       Options = MatrixType::Options,
-      DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime)
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
+      DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime),
+      MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN(MaxColsAtCompileTime,MaxRowsAtCompileTime)
     };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename MatrixType::RealScalar RealScalar;
-    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime> MatrixQType;
-    typedef Matrix<Scalar, DiagSizeAtCompileTime, 1> HCoeffsType;
-    typedef PermutationMatrix<ColsAtCompileTime> PermutationType;
-    typedef Matrix<int, 1, ColsAtCompileTime> IntRowVectorType;
-    typedef Matrix<Scalar, 1, ColsAtCompileTime> RowVectorType;
-    typedef Matrix<RealScalar, 1, ColsAtCompileTime> RealRowVectorType;
+    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, Options, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixQType;
+    typedef Matrix<Scalar, DiagSizeAtCompileTime, 1, Options, MaxDiagSizeAtCompileTime, 1> HCoeffsType;
+    typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType;
+    typedef Matrix<int, 1, ColsAtCompileTime, Options, 1, MaxColsAtCompileTime> IntRowVectorType;
+    typedef Matrix<Scalar, 1, ColsAtCompileTime, Options, 1, MaxColsAtCompileTime> RowVectorType;
+    typedef Matrix<RealScalar, 1, ColsAtCompileTime, Options, 1, MaxColsAtCompileTime> RealRowVectorType;
     typedef typename HouseholderSequence<MatrixType,HCoeffsType>::ConjugateReturnType HouseholderSequenceType;
 
     /**
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/QR/FullPivHouseholderQR.h
--- a/Eigen/src/QR/FullPivHouseholderQR.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/QR/FullPivHouseholderQR.h	Mon Mar 08 19:31:27 2010 +0100
@@ -51,17 +51,20 @@
       RowsAtCompileTime = MatrixType::RowsAtCompileTime,
       ColsAtCompileTime = MatrixType::ColsAtCompileTime,
       Options = MatrixType::Options,
-      DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime)
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
+      DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime),
+      MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN(MaxColsAtCompileTime,MaxRowsAtCompileTime)
     };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename MatrixType::RealScalar RealScalar;
-    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime> MatrixQType;
-    typedef Matrix<Scalar, DiagSizeAtCompileTime, 1> HCoeffsType;
-    typedef Matrix<int, 1, ColsAtCompileTime> IntRowVectorType;
-    typedef PermutationMatrix<ColsAtCompileTime> PermutationType;
-    typedef Matrix<int, RowsAtCompileTime, 1> IntColVectorType;
-    typedef Matrix<Scalar, 1, ColsAtCompileTime> RowVectorType;
-    typedef Matrix<Scalar, RowsAtCompileTime, 1> ColVectorType;
+    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, Options, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixQType;
+    typedef Matrix<Scalar, DiagSizeAtCompileTime, 1, Options, MaxDiagSizeAtCompileTime, 1> HCoeffsType;
+    typedef Matrix<int, 1, ColsAtCompileTime, Options, 1, MaxColsAtCompileTime> IntRowVectorType;
+    typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType;
+    typedef Matrix<int, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> IntColVectorType;
+    typedef Matrix<Scalar, 1, ColsAtCompileTime, Options, 1, MaxColsAtCompileTime> RowVectorType;
+    typedef Matrix<Scalar, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> ColVectorType;
 
     /** \brief Default Constructor.
       *
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/QR/HouseholderQR.h
--- a/Eigen/src/QR/HouseholderQR.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/QR/HouseholderQR.h	Mon Mar 08 19:31:27 2010 +0100
@@ -55,13 +55,16 @@
       RowsAtCompileTime = MatrixType::RowsAtCompileTime,
       ColsAtCompileTime = MatrixType::ColsAtCompileTime,
       Options = MatrixType::Options,
-      DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime)
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
+      DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime),
+      MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN(MaxColsAtCompileTime,MaxRowsAtCompileTime)
     };
     typedef typename MatrixType::Scalar Scalar;
     typedef typename MatrixType::RealScalar RealScalar;
-    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, ei_traits<MatrixType>::Flags&RowMajorBit ? RowMajor : ColMajor> MatrixQType;
-    typedef Matrix<Scalar, DiagSizeAtCompileTime, 1> HCoeffsType;
-    typedef Matrix<Scalar, 1, ColsAtCompileTime> RowVectorType;
+    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, ei_traits<MatrixType>::Flags&RowMajorBit ? RowMajor : ColMajor, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixQType;
+    typedef Matrix<Scalar, DiagSizeAtCompileTime, 1, Options, MaxDiagSizeAtCompileTime, 1> HCoeffsType;
+    typedef Matrix<Scalar, 1, ColsAtCompileTime, Options, 1, MaxColsAtCompileTime> RowVectorType;
     typedef typename HouseholderSequence<MatrixType,HCoeffsType>::ConjugateReturnType HouseholderSequenceType;
 
     /**
diff -r ca79aaf246c1 -r 4091dcef3e75 Eigen/src/SVD/SVD.h
--- a/Eigen/src/SVD/SVD.h	Mon Mar 08 10:34:59 2010 -0500
+++ b/Eigen/src/SVD/SVD.h	Mon Mar 08 19:31:27 2010 +0100
@@ -52,15 +52,18 @@
       ColsAtCompileTime = MatrixType::ColsAtCompileTime,
       PacketSize = ei_packet_traits<Scalar>::size,
       AlignmentMask = int(PacketSize)-1,
-      MinSize = EIGEN_SIZE_MIN(RowsAtCompileTime, ColsAtCompileTime)
+      MinSize = EIGEN_SIZE_MIN(RowsAtCompileTime, ColsAtCompileTime),
+      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
+      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
+      MatrixOptions = MatrixType::Options
     };
 
-    typedef Matrix<Scalar, RowsAtCompileTime, 1> ColVector;
-    typedef Matrix<Scalar, ColsAtCompileTime, 1> RowVector;
+    typedef Matrix<Scalar, RowsAtCompileTime, 1, MatrixOptions, MaxRowsAtCompileTime, 1> ColVector;
+    typedef Matrix<Scalar, ColsAtCompileTime, 1, MatrixOptions, MaxColsAtCompileTime, 1> RowVector;
 
-    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime> MatrixUType;
-    typedef Matrix<Scalar, ColsAtCompileTime, ColsAtCompileTime> MatrixVType;
-    typedef Matrix<Scalar, ColsAtCompileTime, 1> SingularValuesType;
+    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, MatrixOptions, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixUType;
+    typedef Matrix<Scalar, ColsAtCompileTime, ColsAtCompileTime, MatrixOptions, MaxColsAtCompileTime, MaxColsAtCompileTime> MatrixVType;
+    typedef Matrix<Scalar, ColsAtCompileTime, 1, MatrixOptions, MaxColsAtCompileTime, 1> SingularValuesType;
 
     /**
     * \brief Default Constructor.
@@ -195,7 +198,8 @@
   bool convergence = true;
   Scalar eps = NumTraits<Scalar>::dummy_precision();
 
-  Matrix<Scalar,Dynamic,1> rv1(n);
+  RowVector rv1(n);
+
   g = scale = anorm = 0;
   // Householder reduction to bidiagonal form.
   for (i=0; i<n; i++)
diff -r ca79aaf246c1 -r 4091dcef3e75 test/nomalloc.cpp
--- a/test/nomalloc.cpp	Mon Mar 08 10:34:59 2010 -0500
+++ b/test/nomalloc.cpp	Mon Mar 08 19:31:27 2010 +0100
@@ -33,6 +33,11 @@
 #define EIGEN_NO_MALLOC
 
 #include "main.h"
+#include <Eigen/Cholesky>
+#include <Eigen/Eigenvalues>
+#include <Eigen/LU>
+#include <Eigen/QR>
+#include <Eigen/SVD>
 
 template<typename MatrixType> void nomalloc(const MatrixType& m)
 {
@@ -73,6 +78,58 @@
   }
 }
 
+void ctms_decompositions()
+{
+  const int maxSize = 16;
+  const int size    = 12;
+
+  typedef Eigen::Matrix<float,
+                        Eigen::Dynamic, Eigen::Dynamic,
+                        Eigen::ColMajor | Eigen::AutoAlign,
+                        maxSize, maxSize> Matrix;
+
+  typedef Eigen::Matrix<float,
+                        Eigen::Dynamic, 1,
+                        Eigen::ColMajor | Eigen::AutoAlign,
+                        maxSize, 1> Vector;
+
+  typedef Eigen::Matrix<std::complex<float>,
+                        Eigen::Dynamic, Eigen::Dynamic,
+                        Eigen::ColMajor | Eigen::AutoAlign,
+                        maxSize, maxSize> ComplexMatrix;
+
+  const Matrix A(Matrix::Random(size, size));
+  const ComplexMatrix complexA(ComplexMatrix::Random(size, size));
+//   const Matrix saA = A.adjoint() * A; // NOTE: This product allocates on the stack. The two following lines are a kludgy workaround
+  Matrix saA(Matrix::Constant(size, size, 1.0));
+  saA.diagonal().setConstant(2.0);
+
+  // Cholesky module
+  Eigen::LLT<Matrix>  LLT;  LLT.compute(A);
+  Eigen::LDLT<Matrix> LDLT; LDLT.compute(A);
+
+  // Eigenvalues module
+  Eigen::HessenbergDecomposition<ComplexMatrix> hessDecomp;        hessDecomp.compute(complexA);
+  Eigen::ComplexSchur<ComplexMatrix>            cSchur(size);      cSchur.compute(complexA);
+  Eigen::ComplexEigenSolver<ComplexMatrix>      cEigSolver;        //cEigSolver.compute(complexA); // NOTE: Commented-out because makes test fail (L135 of ComplexEigenSolver.h has a product that allocates on the stack)
+  Eigen::EigenSolver<Matrix>                    eigSolver;         eigSolver.compute(A);
+  Eigen::SelfAdjointEigenSolver<Matrix>         saEigSolver(size); saEigSolver.compute(saA);
+  Eigen::Tridiagonalization<Matrix>             tridiag;           tridiag.compute(saA);
+
+  // LU module
+  Eigen::PartialPivLU<Matrix> ppLU; ppLU.compute(A);
+  Eigen::FullPivLU<Matrix>    fpLU; fpLU.compute(A);
+
+  // QR module
+  Eigen::HouseholderQR<Matrix>        hQR;  hQR.compute(A);
+  Eigen::ColPivHouseholderQR<Matrix>  cpQR; cpQR.compute(A);
+  Eigen::FullPivHouseholderQR<Matrix> fpQR; fpQR.compute(A);
+
+  // SVD module
+  Eigen::JacobiSVD<Matrix> jSVD; jSVD.compute(A);
+  Eigen::SVD<Matrix>       svd;  svd.compute(A);
+}
+
 void test_nomalloc()
 {
   // check that our operator new is indeed called:
@@ -80,4 +137,8 @@
   CALL_SUBTEST(nomalloc(Matrix<float, 1, 1>()) );
   CALL_SUBTEST(nomalloc(Matrix4d()) );
   CALL_SUBTEST(nomalloc(Matrix<float,32,32>()) );
+  
+  // Check decomposition modules with dynamic matrices that have a known compile-time max size (ctms)
+  CALL_SUBTEST(ctms_decompositions());
+
 }


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