aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-15 13:55:47 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-15 13:55:47 +0000
commitc67e717404258d3625a74c67f50be34939af6d95 (patch)
tree2eab0b2e520acb2ccbd88fa8242a2c9c9ea8b980 /Eigen
parent9c9a42cc49f9c7f0e0d87c827734262cc5f5fbc3 (diff)
alpha 3.1. in this commit:
- finally get the Eval stuff right. get back to having Eval as a subclass of Matrix with limited functionality, and then, add a typedef MatrixType to get the actual matrix type. - add swap(), findBiggestCoeff() - bugfix by Ramon in Transpose - new demo: doc/echelon.cpp
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/Core3
-rw-r--r--Eigen/src/Core/Block.h5
-rw-r--r--Eigen/src/Core/Cast.h3
-rw-r--r--Eigen/src/Core/Column.h3
-rw-r--r--Eigen/src/Core/Conjugate.h3
-rw-r--r--Eigen/src/Core/DiagonalCoeffs.h5
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h5
-rw-r--r--Eigen/src/Core/Difference.h3
-rw-r--r--Eigen/src/Core/Eval.h58
-rw-r--r--Eigen/src/Core/FixedBlock.h5
-rw-r--r--Eigen/src/Core/ForwardDeclarations.h8
-rw-r--r--Eigen/src/Core/Identity.h5
-rw-r--r--Eigen/src/Core/Map.h3
-rw-r--r--Eigen/src/Core/Matrix.h13
-rw-r--r--Eigen/src/Core/MatrixBase.h28
-rw-r--r--Eigen/src/Core/MatrixRef.h1
-rw-r--r--Eigen/src/Core/Minor.h3
-rw-r--r--Eigen/src/Core/Ones.h5
-rw-r--r--Eigen/src/Core/Opposite.h5
-rw-r--r--Eigen/src/Core/Product.h5
-rw-r--r--Eigen/src/Core/Random.h12
-rw-r--r--Eigen/src/Core/Row.h3
-rw-r--r--Eigen/src/Core/ScalarMultiple.h3
-rw-r--r--Eigen/src/Core/Sum.h1
-rw-r--r--Eigen/src/Core/Swap.h64
-rw-r--r--Eigen/src/Core/Transpose.h7
-rw-r--r--Eigen/src/Core/Util.h6
-rw-r--r--Eigen/src/Core/Zero.h3
28 files changed, 176 insertions, 92 deletions
diff --git a/Eigen/Core b/Eigen/Core
index 12b55b0da..a897e4f45 100644
--- a/Eigen/Core
+++ b/Eigen/Core
@@ -4,8 +4,8 @@
namespace Eigen {
-#include "src/Core/Util.h"
#include "src/Core/ForwardDeclarations.h"
+#include "src/Core/Util.h"
#include "src/Core/NumTraits.h"
#include "src/Core/MathFunctions.h"
#include "src/Core/MatrixBase.h"
@@ -38,5 +38,6 @@ namespace Eigen {
#include "src/Core/Fuzzy.h"
#include "src/Core/Map.h"
#include "src/Core/IO.h"
+#include "src/Core/Swap.h"
} // namespace Eigen
diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h
index c09004832..6be263938 100644
--- a/Eigen/src/Core/Block.h
+++ b/Eigen/src/Core/Block.h
@@ -56,8 +56,9 @@ template<typename MatrixType> class Block
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Block<MatrixType> >;
-
+ friend class MatrixBase<Scalar, Block>;
+ typedef MatrixBase<Scalar, Block> Base;
+
Block(const MatRef& matrix,
int startRow, int startCol,
int blockRows, int blockCols)
diff --git a/Eigen/src/Core/Cast.h b/Eigen/src/Core/Cast.h
index 433be3ad7..962bb862f 100644
--- a/Eigen/src/Core/Cast.h
+++ b/Eigen/src/Core/Cast.h
@@ -52,7 +52,8 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
public:
typedef NewScalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Cast<Scalar, MatrixType> >;
+ friend class MatrixBase<Scalar, Cast>;
+ typedef MatrixBase<Scalar, Cast> Base;
Cast(const MatRef& matrix) : m_matrix(matrix) {}
diff --git a/Eigen/src/Core/Column.h b/Eigen/src/Core/Column.h
index bb92c3b11..9945ff4c0 100644
--- a/Eigen/src/Core/Column.h
+++ b/Eigen/src/Core/Column.h
@@ -52,7 +52,8 @@ template<typename MatrixType> class Column
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Column<MatrixType> >;
+ friend class MatrixBase<Scalar, Column>;
+ typedef MatrixBase<Scalar, Column> Base;
Column(const MatRef& matrix, int col)
: m_matrix(matrix), m_col(col)
diff --git a/Eigen/src/Core/Conjugate.h b/Eigen/src/Core/Conjugate.h
index 16cebccb6..839a43bc7 100644
--- a/Eigen/src/Core/Conjugate.h
+++ b/Eigen/src/Core/Conjugate.h
@@ -44,7 +44,8 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals,
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Conjugate<MatrixType> >;
+ friend class MatrixBase<Scalar, Conjugate>;
+ typedef MatrixBase<Scalar, Conjugate> Base;
Conjugate(const MatRef& matrix) : m_matrix(matrix) {}
diff --git a/Eigen/src/Core/DiagonalCoeffs.h b/Eigen/src/Core/DiagonalCoeffs.h
index 80f402305..ea7043dc3 100644
--- a/Eigen/src/Core/DiagonalCoeffs.h
+++ b/Eigen/src/Core/DiagonalCoeffs.h
@@ -44,8 +44,9 @@ template<typename MatrixType> class DiagonalCoeffs
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, DiagonalCoeffs<MatrixType> >;
-
+ friend class MatrixBase<Scalar, DiagonalCoeffs>;
+ typedef MatrixBase<Scalar, DiagonalCoeffs> Base;
+
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h
index 7c55db920..b8ce5d2d5 100644
--- a/Eigen/src/Core/DiagonalMatrix.h
+++ b/Eigen/src/Core/DiagonalMatrix.h
@@ -47,8 +47,9 @@ class DiagonalMatrix : NoOperatorEquals,
public:
typedef typename CoeffsVectorType::Scalar Scalar;
typedef typename CoeffsVectorType::Ref CoeffsVecRef;
- friend class MatrixBase<Scalar, DiagonalMatrix<CoeffsVectorType> >;
-
+ friend class MatrixBase<Scalar, DiagonalMatrix>;
+ typedef MatrixBase<Scalar, DiagonalMatrix> Base;
+
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
{
assert(CoeffsVectorType::Traits::IsVectorAtCompileTime
diff --git a/Eigen/src/Core/Difference.h b/Eigen/src/Core/Difference.h
index 99cf5674f..645de9151 100644
--- a/Eigen/src/Core/Difference.h
+++ b/Eigen/src/Core/Difference.h
@@ -47,7 +47,8 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals,
typedef typename Lhs::Ref LhsRef;
typedef typename Rhs::Ref RhsRef;
friend class MatrixBase<Scalar, Difference>;
-
+ typedef MatrixBase<Scalar, Difference> Base;
+
Difference(const LhsRef& lhs, const RhsRef& rhs)
: m_lhs(lhs), m_rhs(rhs)
{
diff --git a/Eigen/src/Core/Eval.h b/Eigen/src/Core/Eval.h
index f4ffca655..46f6ced73 100644
--- a/Eigen/src/Core/Eval.h
+++ b/Eigen/src/Core/Eval.h
@@ -45,53 +45,33 @@
*
* \sa MatrixBase::eval()
*/
-template<typename ExpressionType> class Eval
- : public MatrixBase<typename ExpressionType::Scalar, Eval<ExpressionType> >
+template<typename ExpressionType> class Eval : NoOperatorEquals,
+ public Matrix< typename ExpressionType::Scalar,
+ ExpressionType::Traits::RowsAtCompileTime,
+ ExpressionType::Traits::ColsAtCompileTime,
+ EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
+ ExpressionType::Traits::MaxRowsAtCompileTime,
+ ExpressionType::Traits::MaxColsAtCompileTime>
{
public:
typedef typename ExpressionType::Scalar Scalar;
- friend class MatrixBase<Scalar, Eval>;
- typedef MatrixBase<Scalar, Eval> Base;
- friend class MatrixRef<Eval>;
- typedef MatrixRef<Eval> Ref;
-
- private:
- enum {
- RowsAtCompileTime = ExpressionType::Traits::RowsAtCompileTime,
- ColsAtCompileTime = ExpressionType::Traits::ColsAtCompileTime,
- MaxRowsAtCompileTime = ExpressionType::Traits::MaxRowsAtCompileTime,
- MaxColsAtCompileTime = ExpressionType::Traits::MaxColsAtCompileTime
- };
- typedef Matrix<typename ExpressionType::Scalar,
+
+ /** The actual matrix type to evaluate to. This type can be used independently
+ * of the rest of this class to get the actual matrix type to evaluate and store
+ * the value of an expression.
+ *
+ * Here is an example illustrating this:
+ * \include Eval_MatrixType.cpp
+ * Output: \verbinclude Eval_MatrixType.out
+ */
+ typedef Matrix<Scalar,
ExpressionType::Traits::RowsAtCompileTime,
ExpressionType::Traits::ColsAtCompileTime,
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
ExpressionType::Traits::MaxRowsAtCompileTime,
ExpressionType::Traits::MaxColsAtCompileTime> MatrixType;
- int _rows() const { return m_matrix.rows(); }
- int _cols() const { return m_matrix.cols(); }
- Ref _ref() const { return Ref(*this); }
-
- const Scalar& _coeff(int row, int col) const
- {
- return m_matrix._coeff(row, col);
- }
-
- Scalar& _coeffRef(int row, int col)
- {
- return m_matrix._coeffRef(row, col);
- }
-
- public:
- template<typename Derived>
- Eval(const MatrixBase<Scalar, Derived>& other) : m_matrix(other) {}
- ~Eval() {}
-
- EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Eval)
-
- protected:
- MatrixType m_matrix;
+ explicit Eval(const ExpressionType& expr) : MatrixType(expr) {}
};
/** Evaluates *this, which can be any expression, and returns the obtained matrix.
@@ -110,7 +90,7 @@ template<typename ExpressionType> class Eval
template<typename Scalar, typename Derived>
const Eval<Derived> MatrixBase<Scalar, Derived>::eval() const
{
- return Eval<Derived>(ref());
+ return Eval<Derived>(*static_cast<const Derived*>(this));
}
#endif // EIGEN_EVAL_H
diff --git a/Eigen/src/Core/FixedBlock.h b/Eigen/src/Core/FixedBlock.h
index 95639fcfe..2f5d3fa84 100644
--- a/Eigen/src/Core/FixedBlock.h
+++ b/Eigen/src/Core/FixedBlock.h
@@ -55,8 +55,9 @@ template<typename MatrixType, int BlockRows, int BlockCols> class FixedBlock
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, FixedBlock<MatrixType, BlockRows, BlockCols> >;
-
+ friend class MatrixBase<Scalar, FixedBlock>;
+ typedef MatrixBase<Scalar, FixedBlock> Base;
+
FixedBlock(const MatRef& matrix, int startRow, int startCol)
: m_matrix(matrix), m_startRow(startRow), m_startCol(startCol)
{
diff --git a/Eigen/src/Core/ForwardDeclarations.h b/Eigen/src/Core/ForwardDeclarations.h
index 834a99f55..123899702 100644
--- a/Eigen/src/Core/ForwardDeclarations.h
+++ b/Eigen/src/Core/ForwardDeclarations.h
@@ -47,8 +47,8 @@ template<typename MatrixType> class Ones;
template<typename CoeffsVectorType> class DiagonalMatrix;
template<typename MatrixType> class DiagonalCoeffs;
template<typename MatrixType> class Identity;
-template<typename ExpressionType> class Eval;
template<typename MatrixType> class Map;
+template<typename Derived> class Eval;
template<typename T> struct Reference
{
@@ -61,10 +61,4 @@ struct Reference<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols
typedef MatrixRef<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > Type;
};
-template<typename ExpressionType>
-struct Reference<Eval<ExpressionType> >
-{
- typedef MatrixRef<Eval<ExpressionType> > Type;
-};
-
#endif // EIGEN_FORWARDDECLARATIONS_H
diff --git a/Eigen/src/Core/Identity.h b/Eigen/src/Core/Identity.h
index f5b4edcfc..a74ad0247 100644
--- a/Eigen/src/Core/Identity.h
+++ b/Eigen/src/Core/Identity.h
@@ -37,8 +37,9 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
{
public:
typedef typename MatrixType::Scalar Scalar;
- friend class MatrixBase<Scalar, Identity<MatrixType> >;
-
+ friend class MatrixBase<Scalar, Identity>;
+ typedef MatrixBase<Scalar, Identity> Base;
+
Identity(int rows, int cols) : m_rows(rows), m_cols(cols)
{
assert(rows > 0
diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h
index 6b342491d..aa22037fb 100644
--- a/Eigen/src/Core/Map.h
+++ b/Eigen/src/Core/Map.h
@@ -44,7 +44,8 @@ template<typename MatrixType> class Map
{
public:
typedef typename MatrixType::Scalar Scalar;
- friend class MatrixBase<Scalar, Map<MatrixType> >;
+ friend class MatrixBase<Scalar, Map>;
+ typedef MatrixBase<Scalar, Map> Base;
private:
enum {
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 3dba1f5da..6a1d22fda 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -111,13 +111,11 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
typedef _Scalar Scalar;
typedef MatrixRef<Matrix> Ref;
friend class MatrixRef<Matrix>;
- template<typename ExpressionType> friend class Eval;
private:
enum {
RowsAtCompileTime = _Rows,
ColsAtCompileTime = _Cols,
- SizeAtCompileTime = _Rows == Dynamic || _Cols == Dynamic ? Dynamic : _Rows * _Cols,
StorageOrder = _StorageOrder,
MaxRowsAtCompileTime = _MaxRows,
MaxColsAtCompileTime = _MaxCols,
@@ -167,14 +165,9 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
&& cols > 0
&& (MaxColsAtCompileTime == Dynamic || MaxColsAtCompileTime >= cols)
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
- if(SizeAtCompileTime == Dynamic)
- {
- const int size = rows * cols;
- if(size > m_rows.value() * m_cols.value())
- m_array.resize(size);
- m_rows.setValue(rows);
- m_cols.setValue(cols);
- }
+ m_rows.setValue(rows);
+ m_cols.setValue(cols);
+ m_array.resize(rows * cols);
}
/** Copies the value of the expression \a other into *this.
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 193a86263..fce3a441d 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -304,6 +304,34 @@ template<typename Scalar, typename Derived> class MatrixBase
Scalar& w();
const Eval<Derived> eval() const EIGEN_ALWAYS_INLINE;
+
+ /** puts in *row and *col the location of the coefficient of *this
+ * which has the biggest absolute value.
+ */
+ void findBiggestCoeff(int *row, int *col) const
+ {
+ RealScalar biggest = 0;
+ for(int j = 0; j < cols(); j++)
+ for(int i = 0; i < rows(); i++)
+ {
+ RealScalar x = abs(coeff(i,j));
+ if(x > biggest)
+ {
+ biggest = x;
+ *row = i;
+ *col = j;
+ }
+ }
+ }
+
+ /** swaps *this with the expression \a other.
+ *
+ * \note \a other is only marked const because I couln't find another way
+ * to get g++ 4.2 to accept that template parameter resolution. It gets const_cast'd
+ * of course. TODO: get rid of const here.
+ */
+ template<typename OtherDerived>
+ void swap(const MatrixBase<Scalar, OtherDerived>& other);
};
#endif // EIGEN_MATRIXBASE_H
diff --git a/Eigen/src/Core/MatrixRef.h b/Eigen/src/Core/MatrixRef.h
index ae5c6d1a7..5606ad352 100644
--- a/Eigen/src/Core/MatrixRef.h
+++ b/Eigen/src/Core/MatrixRef.h
@@ -32,6 +32,7 @@ template<typename MatrixType> class MatrixRef
public:
typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, MatrixRef>;
+ typedef MatrixBase<Scalar, MatrixRef> Base;
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
~MatrixRef() {}
diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h
index 1e50f039e..8a8e9910a 100644
--- a/Eigen/src/Core/Minor.h
+++ b/Eigen/src/Core/Minor.h
@@ -44,7 +44,8 @@ template<typename MatrixType> class Minor
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Minor<MatrixType> >;
+ friend class MatrixBase<Scalar, Minor>;
+ typedef MatrixBase<Scalar, Minor> Base;
Minor(const MatRef& matrix,
int row, int col)
diff --git a/Eigen/src/Core/Ones.h b/Eigen/src/Core/Ones.h
index 02011ec48..4e5a2e7ca 100644
--- a/Eigen/src/Core/Ones.h
+++ b/Eigen/src/Core/Ones.h
@@ -38,8 +38,9 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
{
public:
typedef typename MatrixType::Scalar Scalar;
- friend class MatrixBase<Scalar, Ones<MatrixType> >;
-
+ friend class MatrixBase<Scalar, Ones>;
+ typedef MatrixBase<Scalar, Ones> Base;
+
private:
enum {
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
diff --git a/Eigen/src/Core/Opposite.h b/Eigen/src/Core/Opposite.h
index 6e38b5f6c..7be19cd22 100644
--- a/Eigen/src/Core/Opposite.h
+++ b/Eigen/src/Core/Opposite.h
@@ -44,8 +44,9 @@ template<typename MatrixType> class Opposite : NoOperatorEquals,
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Opposite<MatrixType> >;
-
+ friend class MatrixBase<Scalar, Opposite>;
+ typedef MatrixBase<Scalar, Opposite> Base;
+
Opposite(const MatRef& matrix) : m_matrix(matrix) {}
private:
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h
index 0e3bd9b0c..69b1415a8 100644
--- a/Eigen/src/Core/Product.h
+++ b/Eigen/src/Core/Product.h
@@ -1,4 +1,4 @@
-// This file is part of Eigen, a lightweight C++ template library
+// // 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>
@@ -81,7 +81,8 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
typedef typename Lhs::Ref LhsRef;
typedef typename Rhs::Ref RhsRef;
friend class MatrixBase<Scalar, Product>;
-
+ typedef MatrixBase<Scalar, Product> Base;
+
Product(const LhsRef& lhs, const RhsRef& rhs)
: m_lhs(lhs), m_rhs(rhs)
{
diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h
index 0b6892d2e..89febe4f3 100644
--- a/Eigen/src/Core/Random.h
+++ b/Eigen/src/Core/Random.h
@@ -38,7 +38,8 @@ template<typename MatrixType> class Random : NoOperatorEquals,
{
public:
typedef typename MatrixType::Scalar Scalar;
- friend class MatrixBase<Scalar, Random<MatrixType> >;
+ friend class MatrixBase<Scalar, Random>;
+ typedef MatrixBase<Scalar, Random> Base;
private:
enum {
@@ -86,7 +87,8 @@ template<typename MatrixType> class Random : NoOperatorEquals,
* \sa random(), random(int)
*/
template<typename Scalar, typename Derived>
-const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int rows, int cols)
+const Eval<Random<Derived> >
+MatrixBase<Scalar, Derived>::random(int rows, int cols)
{
return Random<Derived>(rows, cols).eval();
}
@@ -108,7 +110,8 @@ const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int rows, int c
* \sa random(), random(int,int)
*/
template<typename Scalar, typename Derived>
-const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int size)
+const Eval<Random<Derived> >
+MatrixBase<Scalar, Derived>::random(int size)
{
assert(Traits::IsVectorAtCompileTime);
if(Traits::RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
@@ -127,7 +130,8 @@ const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int size)
* \sa random(int), random(int,int)
*/
template<typename Scalar, typename Derived>
-const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random()
+const Eval<Random<Derived> >
+MatrixBase<Scalar, Derived>::random()
{
return Random<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval();
}
diff --git a/Eigen/src/Core/Row.h b/Eigen/src/Core/Row.h
index 55def78f3..379442dea 100644
--- a/Eigen/src/Core/Row.h
+++ b/Eigen/src/Core/Row.h
@@ -52,7 +52,8 @@ template<typename MatrixType> class Row
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Row<MatrixType> >;
+ friend class MatrixBase<Scalar, Row>;
+ typedef MatrixBase<Scalar, Row> Base;
Row(const MatRef& matrix, int row)
: m_matrix(matrix), m_row(row)
diff --git a/Eigen/src/Core/ScalarMultiple.h b/Eigen/src/Core/ScalarMultiple.h
index 1df09eee2..b2b2ddaab 100644
--- a/Eigen/src/Core/ScalarMultiple.h
+++ b/Eigen/src/Core/ScalarMultiple.h
@@ -43,7 +43,8 @@ template<typename FactorType, typename MatrixType> class ScalarMultiple : NoOper
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, ScalarMultiple<FactorType, MatrixType> >;
+ friend class MatrixBase<Scalar, ScalarMultiple>;
+ typedef MatrixBase<Scalar, ScalarMultiple> Base;
ScalarMultiple(const MatRef& matrix, FactorType factor)
: m_matrix(matrix), m_factor(factor) {}
diff --git a/Eigen/src/Core/Sum.h b/Eigen/src/Core/Sum.h
index 325125956..53c30d018 100644
--- a/Eigen/src/Core/Sum.h
+++ b/Eigen/src/Core/Sum.h
@@ -47,6 +47,7 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals,
typedef typename Lhs::Ref LhsRef;
typedef typename Rhs::Ref RhsRef;
friend class MatrixBase<Scalar, Sum>;
+ typedef MatrixBase<Scalar, Sum> Base;
Sum(const LhsRef& lhs, const RhsRef& rhs)
: m_lhs(lhs), m_rhs(rhs)
diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h
new file mode 100644
index 000000000..cc1b2092b
--- /dev/null
+++ b/Eigen/src/Core/Swap.h
@@ -0,0 +1,64 @@
+// 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 General Public License as published by the Free Software
+// Foundation; either version 2 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 General Public License for more
+// details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Eigen; if not, write to the Free Software Foundation, Inc., 51
+// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. This exception does not invalidate any other reasons why a work
+// based on this file might be covered by the GNU General Public License.
+
+#ifndef EIGEN_SWAP_H
+#define EIGEN_SWAP_H
+
+template<typename Scalar, typename Derived>
+template<typename OtherDerived>
+void MatrixBase<Scalar, Derived>::swap(const MatrixBase<Scalar, OtherDerived>& other)
+{
+ MatrixBase<Scalar, OtherDerived> *_other = const_cast<MatrixBase<Scalar, OtherDerived>*>(&other);
+ if(Traits::SizeAtCompileTime == Dynamic)
+ {
+ Scalar tmp;
+ if(Traits::IsVectorAtCompileTime)
+ {
+ assert(OtherDerived::Traits::IsVectorAtCompileTime && size() == _other->size());
+ for(int i = 0; i < size(); i++)
+ {
+ tmp = coeff(i);
+ coeffRef(i) = _other->coeff(i);
+ _other->coeffRef(i) = tmp;
+ }
+ }
+ else
+ for(int j = 0; j < cols(); j++)
+ for(int i = 0; i < rows(); i++)
+ {
+ tmp = coeff(i, j);
+ coeffRef(i, j) = _other->coeff(i, j);
+ _other->coeffRef(i, j) = tmp;
+ }
+ }
+ else // SizeAtCompileTime != Dynamic
+ {
+ typename Eval<Derived>::MatrixType buf(*this);
+ *this = other;
+ *_other = buf;
+ }
+}
+
+#endif // EIGEN_SWAP_H
diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h
index 87da4e39d..8dc7763fc 100644
--- a/Eigen/src/Core/Transpose.h
+++ b/Eigen/src/Core/Transpose.h
@@ -44,7 +44,8 @@ template<typename MatrixType> class Transpose
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
- friend class MatrixBase<Scalar, Transpose<MatrixType> >;
+ friend class MatrixBase<Scalar, Transpose>;
+ typedef MatrixBase<Scalar, Transpose> Base;
Transpose(const MatRef& matrix) : m_matrix(matrix) {}
@@ -54,8 +55,8 @@ template<typename MatrixType> class Transpose
enum {
RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
ColsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
- MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
- MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
+ MaxRowsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime,
+ MaxColsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime
};
const Transpose& _ref() const { return *this; }
diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h
index 8104201e6..11b06c55a 100644
--- a/Eigen/src/Core/Util.h
+++ b/Eigen/src/Core/Util.h
@@ -67,18 +67,18 @@ using Eigen::MatrixBase;
template<typename OtherScalar, typename OtherDerived> \
Derived& operator Op(const MatrixBase<OtherScalar, OtherDerived>& other) \
{ \
- return MatrixBase<Scalar, Derived>::operator Op(other); \
+ return Base::operator Op(other); \
} \
Derived& operator Op(const Derived& other) \
{ \
- return MatrixBase<Scalar, Derived>::operator Op(other); \
+ return Base::operator Op(other); \
}
#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename Other> \
Derived& operator Op(const Other& scalar) \
{ \
- return MatrixBase<Scalar, Derived>::operator Op(scalar); \
+ return Base::operator Op(scalar); \
}
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
diff --git a/Eigen/src/Core/Zero.h b/Eigen/src/Core/Zero.h
index c0fdcffe3..625804059 100644
--- a/Eigen/src/Core/Zero.h
+++ b/Eigen/src/Core/Zero.h
@@ -38,7 +38,8 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
{
public:
typedef typename MatrixType::Scalar Scalar;
- friend class MatrixBase<Scalar, Zero<MatrixType> >;
+ friend class MatrixBase<Scalar, Zero>;
+ typedef MatrixBase<Scalar, Zero> Base;
private:
enum {