aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Eigen/Core2
-rw-r--r--Eigen/src/Core/Block.h60
-rw-r--r--Eigen/src/Core/Column.h119
-rw-r--r--Eigen/src/Core/CommaInitializer.h16
-rw-r--r--Eigen/src/Core/ForwardDeclarations.h2
-rw-r--r--Eigen/src/Core/MatrixBase.h8
-rw-r--r--Eigen/src/Core/Row.h120
-rw-r--r--bench/basicbench.cxxlist17
-rwxr-xr-xbench/bench_multi_compilers.sh2
-rw-r--r--doc/examples/class_Column.cpp8
-rw-r--r--doc/examples/class_Row.cpp8
-rw-r--r--doc/snippets/Eval_MatrixType.cpp2
-rw-r--r--test/main.cpp16
-rw-r--r--test/main.h19
14 files changed, 122 insertions, 277 deletions
diff --git a/Eigen/Core b/Eigen/Core
index f2b3639ca..68a1e5e5c 100644
--- a/Eigen/Core
+++ b/Eigen/Core
@@ -22,8 +22,6 @@ namespace Eigen {
#include "src/Core/CwiseBinaryOp.h"
#include "src/Core/CwiseUnaryOp.h"
#include "src/Core/Product.h"
-#include "src/Core/Row.h"
-#include "src/Core/Column.h"
#include "src/Core/Block.h"
#include "src/Core/Minor.h"
#include "src/Core/Transpose.h"
diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h
index 8db636ece..a2a581aac 100644
--- a/Eigen/src/Core/Block.h
+++ b/Eigen/src/Core/Block.h
@@ -79,6 +79,24 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
typedef typename MatrixType::AsArg MatRef;
+ /** Column or Row constructor
+ */
+ Block(const MatRef& matrix, int i)
+ : m_matrix(matrix),
+ // It is a row if and only if BlockRows==1 and BlockCols==MatrixType::ColsAtCompileTime,
+ // and it is a column if and only if BlockRows==MatrixType::RowsAtCompileTime and BlockCols==1,
+ // all other cases are invalid.
+ // The case a 1x1 matrix looks ambibuous, but the result is the same anyway.
+ m_startRow( (BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0),
+ m_startCol( (BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
+ m_blockRows(matrix.rows()), // if it is a row, then m_blockRows has a fixed-size of 1, so no pb to try to overwrite it
+ m_blockCols(matrix.cols()) // same for m_blockCols
+ {
+ assert( (i>=0) && (
+ ((BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) && i<matrix.rows())
+ ||((BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) && i<matrix.cols())));
+ }
+
/** Fixed-size constructor
*/
Block(const MatRef& matrix, int startRow, int startCol)
@@ -354,4 +372,46 @@ const Block<Derived, BlockRows, BlockCols> MatrixBase<Derived>
return Block<Derived, BlockRows, BlockCols>(asArg(), startRow, startCol);
}
+/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.
+ *
+ * Example: \include MatrixBase_col.cpp
+ * Output: \verbinclude MatrixBase_col.out
+ *
+ * \sa row(), class Block */
+template<typename Derived>
+Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1>
+MatrixBase<Derived>::col(int i)
+{
+ return Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1>(asArg(), i);
+}
+
+/** This is the const version of col(). */
+template<typename Derived>
+const Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1>
+MatrixBase<Derived>::col(int i) const
+{
+ return Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1>(asArg(), i);
+}
+
+/** \returns an expression of the \a i-th row of *this. Note that the numbering starts at 0.
+ *
+ * Example: \include MatrixBase_row.cpp
+ * Output: \verbinclude MatrixBase_row.out
+ *
+ * \sa col(), class Block */
+template<typename Derived>
+Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime>
+MatrixBase<Derived>::row(int i)
+{
+ return Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime>(asArg(), i);
+}
+
+/** This is the const version of row(). */
+template<typename Derived>
+const Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime>
+MatrixBase<Derived>::row(int i) const
+{
+ return Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime>(asArg(), i);
+}
+
#endif // EIGEN_BLOCK_H
diff --git a/Eigen/src/Core/Column.h b/Eigen/src/Core/Column.h
deleted file mode 100644
index 943095671..000000000
--- a/Eigen/src/Core/Column.h
+++ /dev/null
@@ -1,119 +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@math.jussieu.fr>
-//
-// 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_COLUMN_H
-#define EIGEN_COLUMN_H
-
-/** \class Column
- *
- * \brief Expression of a column
- *
- * \param MatrixType the type of the object in which we are taking a column
- *
- * This class represents an expression of a column. It is the return
- * type of MatrixBase::col() and most of the time this is the only way it
- * is used.
- *
- * However, if you want to directly maniputate column expressions,
- * for instance if you want to write a function returning such an expression, you
- * will need to use this class.
- *
- * Here is an example illustrating this:
- * \include class_Column.cpp
- * Output: \verbinclude class_Column.out
- *
- * \sa MatrixBase::col()
- */
-template<typename MatrixType>
-struct ei_traits<Column<MatrixType> >
-{
- typedef typename MatrixType::Scalar Scalar;
- enum {
- RowsAtCompileTime = MatrixType::RowsAtCompileTime,
- ColsAtCompileTime = 1,
- MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
- MaxColsAtCompileTime = 1
- };
-};
-
-template<typename MatrixType> class Column
- : public MatrixBase<Column<MatrixType> >
-{
- public:
-
- EIGEN_BASIC_PUBLIC_INTERFACE(Column)
-
- typedef typename MatrixType::AsArg MatRef;
-
- Column(const MatRef& matrix, int col)
- : m_matrix(matrix), m_col(col)
- {
- assert(col >= 0 && col < matrix.cols());
- }
-
- EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
-
- private:
-
- const Column& _asArg() const { return *this; }
- int _rows() const { return m_matrix.rows(); }
- int _cols() const { return 1; }
-
- Scalar& _coeffRef(int row, int)
- {
- return m_matrix.coeffRef(row, m_col);
- }
-
- Scalar _coeff(int row, int) const
- {
- return m_matrix.coeff(row, m_col);
- }
-
- protected:
- MatRef m_matrix;
- const int m_col;
-};
-
-/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.
- *
- * Example: \include MatrixBase_col.cpp
- * Output: \verbinclude MatrixBase_col.out
- *
- * \sa row(), class Column */
-template<typename Derived>
-Column<Derived>
-MatrixBase<Derived>::col(int i)
-{
- return Column<Derived>(asArg(), i);
-}
-
-/** This is the const version of col(). */
-template<typename Derived>
-const Column<Derived>
-MatrixBase<Derived>::col(int i) const
-{
- return Column<Derived>(asArg(), i);
-}
-
-#endif // EIGEN_COLUMN_H
diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h
index 5456eb7c6..c7a292437 100644
--- a/Eigen/src/Core/CommaInitializer.h
+++ b/Eigen/src/Core/CommaInitializer.h
@@ -52,8 +52,11 @@ struct MatrixBase<Derived>::CommaInitializer
m_row+=m_currentBlockRows;
m_col = 0;
m_currentBlockRows = 1;
+ assert(m_row<m_matrix.rows()
+ && "Too many rows passed to MatrixBase::operator<<");
}
- assert(m_col<m_matrix.cols() && "Too many coefficients passed to Matrix::operator<<");
+ assert(m_col<m_matrix.cols()
+ && "Too many coefficients passed to MatrixBase::operator<<");
assert(m_currentBlockRows==1);
m_matrix.coeffRef(m_row, m_col++) = s;
return *this;
@@ -67,10 +70,17 @@ struct MatrixBase<Derived>::CommaInitializer
m_row+=m_currentBlockRows;
m_col = 0;
m_currentBlockRows = other.rows();
+ assert(m_row+m_currentBlockRows<=m_matrix.rows()
+ && "Too many rows passed to MatrixBase::operator<<");
}
- assert(m_col<m_matrix.cols() && "Too many coefficients passed to Matrix::operator<<");
+ assert(m_col<m_matrix.cols()
+ && "Too many coefficients passed to MatrixBase::operator<<");
assert(m_currentBlockRows==other.rows());
- m_matrix.block(m_row, m_col, other.rows(), other.cols()) = other;
+ if (OtherDerived::RowsAtCompileTime>0 && OtherDerived::ColsAtCompileTime>0)
+ m_matrix.block< (OtherDerived::RowsAtCompileTime>0?OtherDerived::RowsAtCompileTime:1) ,
+ (OtherDerived::ColsAtCompileTime>0?OtherDerived::ColsAtCompileTime:1) >(m_row, m_col) = other;
+ else
+ m_matrix.block(m_row, m_col, other.rows(), other.cols()) = other;
m_col += other.cols();
return *this;
}
diff --git a/Eigen/src/Core/ForwardDeclarations.h b/Eigen/src/Core/ForwardDeclarations.h
index a548cd475..a43a34745 100644
--- a/Eigen/src/Core/ForwardDeclarations.h
+++ b/Eigen/src/Core/ForwardDeclarations.h
@@ -29,8 +29,6 @@ template<typename T> struct ei_traits;
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> class Matrix;
template<typename MatrixType> class MatrixRef;
-template<typename MatrixType> class Row;
-template<typename MatrixType> class Column;
template<typename MatrixType> class Minor;
template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic> class Block;
template<typename MatrixType> class Transpose;
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 62dfc6bee..18ffdd00f 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -193,11 +193,11 @@ template<typename Derived> class MatrixBase
/// \name sub-matrices
//@{
- Row<Derived> row(int i);
- const Row<Derived> row(int i) const;
+ Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime> row(int i);
+ const Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime> row(int i) const;
- Column<Derived> col(int i);
- const Column<Derived> col(int i) const;
+ Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1> col(int i);
+ const Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1> col(int i) const;
Minor<Derived> minor(int row, int col);
const Minor<Derived> minor(int row, int col) const;
diff --git a/Eigen/src/Core/Row.h b/Eigen/src/Core/Row.h
deleted file mode 100644
index 57a56852c..000000000
--- a/Eigen/src/Core/Row.h
+++ /dev/null
@@ -1,120 +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@math.jussieu.fr>
-//
-// 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_ROW_H
-#define EIGEN_ROW_H
-
-/** \class Row
- *
- * \brief Expression of a row
- *
- * \param MatrixType the type of the object in which we are taking a row
- *
- * This class represents an expression of a row. It is the return
- * type of MatrixBase::row() and most of the time this is the only way it
- * is used.
- *
- * However, if you want to directly maniputate row expressions,
- * for instance if you want to write a function returning such an expression, you
- * will need to use this class.
- *
- * Here is an example illustrating this:
- * \include class_Row.cpp
- * Output: \verbinclude class_Row.out
- *
- * \sa MatrixBase::row()
- */
-template<typename MatrixType>
-struct ei_traits<Row<MatrixType> >
-{
- typedef typename MatrixType::Scalar Scalar;
- enum {
- RowsAtCompileTime = 1,
- ColsAtCompileTime = MatrixType::ColsAtCompileTime,
- MaxRowsAtCompileTime = 1,
- MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
- };
-};
-
-template<typename MatrixType> class Row
- : public MatrixBase<Row<MatrixType> >
-{
- public:
-
- EIGEN_BASIC_PUBLIC_INTERFACE(Row)
-
- typedef typename MatrixType::AsArg MatRef;
-
- Row(const MatRef& matrix, int row)
- : m_matrix(matrix), m_row(row)
- {
- assert(row >= 0 && row < matrix.rows());
- }
-
- EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
-
- private:
-
- const Row& _asArg() const { return *this; }
-
- int _rows() const { return 1; }
- int _cols() const { return m_matrix.cols(); }
-
- Scalar& _coeffRef(int, int col)
- {
- return m_matrix.coeffRef(m_row, col);
- }
-
- Scalar _coeff(int, int col) const
- {
- return m_matrix.coeff(m_row, col);
- }
-
- protected:
- MatRef m_matrix;
- const int m_row;
-};
-
-/** \returns an expression of the \a i-th row of *this. Note that the numbering starts at 0.
- *
- * Example: \include MatrixBase_row.cpp
- * Output: \verbinclude MatrixBase_row.out
- *
- * \sa col(), class Row */
-template<typename Derived>
-Row<Derived>
-MatrixBase<Derived>::row(int i)
-{
- return Row<Derived>(asArg(), i);
-}
-
-/** This is the const version of row(). */
-template<typename Derived>
-const Row<Derived>
-MatrixBase<Derived>::row(int i) const
-{
- return Row<Derived>(asArg(), i);
-}
-
-#endif // EIGEN_ROW_H
diff --git a/bench/basicbench.cxxlist b/bench/basicbench.cxxlist
index 93266aaf2..5d670ef4b 100644
--- a/bench/basicbench.cxxlist
+++ b/bench/basicbench.cxxlist
@@ -1,12 +1,21 @@
#!/bin/bash
-CLIST[((g++))]="g++-4.1 -O3 -DNDEBUG"
+# CLIST[((g++))]="g++-3.4 -O3 -DNDEBUG"
+# CLIST[((g++))]="g++-3.4 -O3 -DNDEBUG -finline-limit=20000"
+
+# CLIST[((g++))]="g++-4.1 -O3 -DNDEBUG"
CLIST[((g++))]="g++-4.1 -O3 -DNDEBUG -finline-limit=20000"
-CLIST[((g++))]="g++-4.2 -O3 -DNDEBUG"
+# CLIST[((g++))]="g++-4.2 -O3 -DNDEBUG"
CLIST[((g++))]="g++-4.2 -O3 -DNDEBUG -finline-limit=20000"
+# CLIST[((g++))]="g++-4.2 -O3 -DNDEBUG -finline-limit=20000 -fprofile-generate"
+# CLIST[((g++))]="g++-4.2 -O3 -DNDEBUG -finline-limit=20000 -fprofile-use"
-CLIST[((g++))]="g++-4.3 -O3 -DNDEBUG"
+# CLIST[((g++))]="g++-4.3 -O3 -DNDEBUG"
CLIST[((g++))]="g++-4.3 -O3 -DNDEBUG -finline-limit=20000"
+# CLIST[((g++))]="g++-4.3 -O3 -DNDEBUG -finline-limit=20000 -fprofile-generate"
+# CLIST[((g++))]="g++-4.3 -O3 -DNDEBUG -finline-limit=20000 -fprofile-use"
-CLIST[((g++))]="icpc -fast -DNDEBUG -fno-exceptions -no-inline-max-size" \ No newline at end of file
+# CLIST[((g++))]="icpc -fast -DNDEBUG -fno-exceptions -no-inline-max-size"
+# CLIST[((g++))]="icpc -fast -DNDEBUG -fno-exceptions -no-inline-max-size -prof-genx"
+# CLIST[((g++))]="icpc -fast -DNDEBUG -fno-exceptions -no-inline-max-size -prof-use" \ No newline at end of file
diff --git a/bench/bench_multi_compilers.sh b/bench/bench_multi_compilers.sh
index ce5586fb9..27e91f1d5 100755
--- a/bench/bench_multi_compilers.sh
+++ b/bench/bench_multi_compilers.sh
@@ -17,7 +17,7 @@ for (( i=0 ; i<g ; ++i )) ; do
if [ -e `which $compiler` ]; then
echo "${CLIST[$i]}"
# echo "${CLIST[$i]} $benchfile -I.. -o bench~"
- if [ -e ./.bench ] ; then rm .bench; fi
+# if [ -e ./.bench ] ; then rm .bench; fi
${CLIST[$i]} $benchfile -I.. -o .bench && ./.bench 2> /dev/null
echo ""
else
diff --git a/doc/examples/class_Column.cpp b/doc/examples/class_Column.cpp
index 22f95e22d..fbaaa7a87 100644
--- a/doc/examples/class_Column.cpp
+++ b/doc/examples/class_Column.cpp
@@ -3,17 +3,17 @@ USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Derived>
-Eigen::Column<Derived>
+Eigen::Block<Derived,Derived::RowsAtCompileTime,1>
firstColumn(MatrixBase<Derived>& m)
{
- return Eigen::Column<Derived>(m.asArg(), 0);
+ return typename Eigen::Block<Derived,Derived::RowsAtCompileTime,1>(m.asArg(), 0);
}
template<typename Derived>
-const Eigen::Column<Derived>
+const Eigen::Block<Derived,Derived::RowsAtCompileTime,1>
firstColumn(const MatrixBase<Derived>& m)
{
- return Eigen::Column<Derived>(m.asArg(), 0);
+ return typename Eigen::Block<Derived,Derived::RowsAtCompileTime,1>(m.asArg(), 0);
}
int main(int, char**)
diff --git a/doc/examples/class_Row.cpp b/doc/examples/class_Row.cpp
index 4071b8c0d..5138b2e7c 100644
--- a/doc/examples/class_Row.cpp
+++ b/doc/examples/class_Row.cpp
@@ -3,17 +3,17 @@ USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Derived>
-Eigen::Row<Derived>
+Eigen::Block<Derived,1,Derived::ColsAtCompileTime>
firstRow(MatrixBase<Derived>& m)
{
- return Eigen::Row<Derived>(m.asArg(), 0);
+ return Eigen::Block<Derived,1,Derived::ColsAtCompileTime>(m.asArg(), 0);
}
template<typename Derived>
-const Eigen::Row<Derived>
+const Eigen::Block<Derived,1,Derived::ColsAtCompileTime>
firstRow(const MatrixBase<Derived>& m)
{
- return Eigen::Row<Derived>(m.asArg(), 0);
+ return Eigen::Block<Derived,1,Derived::ColsAtCompileTime>(m.asArg(), 0);
}
int main(int, char**)
diff --git a/doc/snippets/Eval_MatrixType.cpp b/doc/snippets/Eval_MatrixType.cpp
index 0af4c64e4..ccff677ac 100644
--- a/doc/snippets/Eval_MatrixType.cpp
+++ b/doc/snippets/Eval_MatrixType.cpp
@@ -1,7 +1,7 @@
typedef Matrix3i MyMatrixType;
MyMatrixType m = MyMatrixType::random(3, 3);
cout << "Here's the matrix m:" << endl << m << endl;
-typedef Eigen::Eval<Eigen::Row<MyMatrixType> >::MatrixType MyRowType;
+typedef Eigen::Eval<Eigen::Block<MyMatrixType,1,MyMatrixType::ColsAtCompileTime> >::MatrixType MyRowType;
// now MyRowType is just the same typedef as RowVector3i
MyRowType r = m.row(0);
cout << "Here's r:" << endl << r << endl;
diff --git a/test/main.cpp b/test/main.cpp
index 486023ab6..f4361f3a5 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -5,12 +5,12 @@
//
// 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
+// 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
+// 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
@@ -18,7 +18,7 @@
// 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
+// 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/>.
@@ -27,13 +27,13 @@
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
-
+
bool has_set_repeat = false;
bool has_set_seed = false;
bool need_help = false;
unsigned int seed;
int repeat;
-
+
QStringList args = QCoreApplication::instance()->arguments();
args.takeFirst(); // throw away the first argument (path to executable)
foreach(QString arg, args)
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
need_help = true;
}
}
-
+
if(need_help)
{
qDebug() << "This test application takes the following optional arguments:";
@@ -82,10 +82,10 @@ int main(int argc, char *argv[])
qDebug() << " sN Use N as seed for random numbers (default: based on current time)";
return 1;
}
-
+
if(!has_set_seed) seed = (unsigned int) time(NULL);
if(!has_set_repeat) repeat = DEFAULT_REPEAT;
-
+
qDebug() << "Initializing random number generator with seed" << seed;
srand(seed);
qDebug() << "Repeating each test" << repeat << "times";
diff --git a/test/main.h b/test/main.h
index 946572046..6ef98b73a 100644
--- a/test/main.h
+++ b/test/main.h
@@ -29,6 +29,7 @@
#include <cstdlib>
#include <ctime>
+#include <iostream>
#define DEFAULT_REPEAT 50
@@ -36,9 +37,14 @@
namespace Eigen
{
- struct ei_assert_exception
- {};
static const bool should_raise_an_assert = false;
+
+ // Used to avoid to raise two exceptions at the time in which
+ // case the exception is not properly catched.
+ // This may happen when a second exceptions is raise in a destructor.
+ static bool no_more_assert = false;
+
+ struct ei_assert_exception {};
}
#define EI_PP_MAKE_STRING2(S) #S
@@ -64,7 +70,7 @@
}
#define assert(a) if (!(a)) { throw Eigen::ei_assert_exception();} \
- else if (Eigen::ei_push_assert) {ei_assert_list.push_back( std::string(EI_PP_MAKE_STRING(__FILE__)) + " (" + EI_PP_MAKE_STRING(__LINE__) + ") : " + #a );}
+ else if (Eigen::ei_push_assert) {ei_assert_list.push_back( std::string(EI_PP_MAKE_STRING(__FILE__)" ("EI_PP_MAKE_STRING(__LINE__)") : "#a) );}
#define VERIFY_RAISES_ASSERT(a) {\
try { \
@@ -80,10 +86,13 @@
#else // EIGEN_DEBUG_ASSERTS
- #define assert(a) if (!(a)) { throw Eigen::ei_assert_exception();}
+ #define assert(a) if( (!(a)) && (!no_more_assert) ) { \
+ Eigen::no_more_assert = true; \
+ throw Eigen::ei_assert_exception(); \
+ }
#define VERIFY_RAISES_ASSERT(a) {\
- try {a; QVERIFY(Eigen::should_raise_an_assert && # a); } \
+ try { a; QVERIFY(Eigen::should_raise_an_assert && # a); } \
catch (Eigen::ei_assert_exception e) { QVERIFY(true);} }
#endif // EIGEN_DEBUG_ASSERTS