* Eigen compiles with any GCC versions from, at least, 3.3 without the previous ugly hack :)

* Renamed the scalar functors with the "Scalar" prefix (instead of "Cwise")
This commit is contained in:
Gael Guennebaud 2008-03-04 12:34:58 +00:00
parent 46885d33bf
commit f65cca5d1d
23 changed files with 248 additions and 240 deletions

View File

@ -4,14 +4,6 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#if ((defined __GNUC__) && ( (__GNUC__==3) || (__GNUC__==4) && __GNUC_MINOR__==0))
/* This very ugly hack to fix a bug of gcc <4.1 with the Curiously recurring template pattern and friend class.
Note that gcc-4.0.1 is still the default compiler on MACOSX Leopard.
*/
#define private public
#warning "Your compiler (gcc<4.1) has issue with friend and CRT, all private members of Eigen's classes are made public"
#endif
namespace Eigen { namespace Eigen {
#include "src/Core/Util.h" #include "src/Core/Util.h"
@ -50,6 +42,3 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#if ((defined __GNUC__) && (__GNUC_MINOR__==0))
#undef private
#endif

View File

@ -6,12 +6,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
@ -65,6 +65,7 @@ template<typename MatrixType,
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, Block>; friend class MatrixBase<Scalar, Block>;
friend class MatrixBase<Scalar, Block>::Traits;
typedef MatrixBase<Scalar, Block> Base; typedef MatrixBase<Scalar, Block> Base;
/** Fixed-size constructor /** Fixed-size constructor

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -52,10 +52,11 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
typedef NewScalar Scalar; typedef NewScalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, Cast>; friend class MatrixBase<Scalar, Cast>;
friend class MatrixBase<Scalar, Cast>::Traits;
typedef MatrixBase<Scalar, Cast> Base; typedef MatrixBase<Scalar, Cast> Base;
Cast(const MatRef& matrix) : m_matrix(matrix) {} Cast(const MatRef& matrix) : m_matrix(matrix) {}
private: private:
enum { enum {
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
@ -66,12 +67,12 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
const Cast& _ref() const { return *this; } const Cast& _ref() const { return *this; }
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
int _cols() const { return m_matrix.cols(); } int _cols() const { return m_matrix.cols(); }
NewScalar _coeff(int row, int col) const NewScalar _coeff(int row, int col) const
{ {
return static_cast<NewScalar>(m_matrix.coeff(row, col)); return static_cast<NewScalar>(m_matrix.coeff(row, col));
} }
protected: protected:
const MatRef m_matrix; const MatRef m_matrix;
}; };

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -52,16 +52,17 @@ template<typename MatrixType> class Column
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, Column>; friend class MatrixBase<Scalar, Column>;
friend class MatrixBase<Scalar, Column>::Traits;
typedef MatrixBase<Scalar, Column> Base; typedef MatrixBase<Scalar, Column> Base;
Column(const MatRef& matrix, int col) Column(const MatRef& matrix, int col)
: m_matrix(matrix), m_col(col) : m_matrix(matrix), m_col(col)
{ {
assert(col >= 0 && col < matrix.cols()); assert(col >= 0 && col < matrix.cols());
} }
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
private: private:
enum { enum {
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
@ -69,21 +70,21 @@ template<typename MatrixType> class Column
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
MaxColsAtCompileTime = 1 MaxColsAtCompileTime = 1
}; };
const Column& _ref() const { return *this; } const Column& _ref() const { return *this; }
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
int _cols() const { return 1; } int _cols() const { return 1; }
Scalar& _coeffRef(int row, int) Scalar& _coeffRef(int row, int)
{ {
return m_matrix.coeffRef(row, m_col); return m_matrix.coeffRef(row, m_col);
} }
Scalar _coeff(int row, int) const Scalar _coeff(int row, int) const
{ {
return m_matrix.coeff(row, m_col); return m_matrix.coeff(row, m_col);
} }
protected: protected:
MatRef m_matrix; MatRef m_matrix;
const int m_col; const int m_col;

View File

@ -6,12 +6,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
@ -44,7 +44,7 @@
* Here is an example illustrating this: * Here is an example illustrating this:
* \include class_CwiseBinaryOp.cpp * \include class_CwiseBinaryOp.cpp
* *
* \sa class CwiseProductOp, class CwiseQuotientOp * \sa class ScalarProductOp, class ScalarQuotientOp
*/ */
template<typename BinaryOp, typename Lhs, typename Rhs> template<typename BinaryOp, typename Lhs, typename Rhs>
class CwiseBinaryOp : NoOperatorEquals, class CwiseBinaryOp : NoOperatorEquals,
@ -55,6 +55,7 @@ class CwiseBinaryOp : NoOperatorEquals,
typedef typename Lhs::Ref LhsRef; typedef typename Lhs::Ref LhsRef;
typedef typename Rhs::Ref RhsRef; typedef typename Rhs::Ref RhsRef;
friend class MatrixBase<Scalar, CwiseBinaryOp>; friend class MatrixBase<Scalar, CwiseBinaryOp>;
friend class MatrixBase<Scalar, CwiseBinaryOp>::Traits;
typedef MatrixBase<Scalar, CwiseBinaryOp> Base; typedef MatrixBase<Scalar, CwiseBinaryOp> Base;
CwiseBinaryOp(const LhsRef& lhs, const RhsRef& rhs) CwiseBinaryOp(const LhsRef& lhs, const RhsRef& rhs)
@ -79,7 +80,7 @@ class CwiseBinaryOp : NoOperatorEquals,
{ {
return BinaryOp::template op<Scalar>(m_lhs.coeff(row, col), m_rhs.coeff(row, col)); return BinaryOp::template op<Scalar>(m_lhs.coeff(row, col), m_rhs.coeff(row, col));
} }
protected: protected:
const LhsRef m_lhs; const LhsRef m_lhs;
const RhsRef m_rhs; const RhsRef m_rhs;
@ -105,7 +106,7 @@ struct CwiseDifferenceOp {
* *
* \sa class CwiseBinaryOp, MatrixBase::cwiseProduct() * \sa class CwiseBinaryOp, MatrixBase::cwiseProduct()
*/ */
struct CwiseProductOp { struct ScalarProductOp {
template<typename Scalar> static Scalar op(const Scalar& a, const Scalar& b) { return a * b; } template<typename Scalar> static Scalar op(const Scalar& a, const Scalar& b) { return a * b; }
}; };
@ -113,7 +114,7 @@ struct CwiseProductOp {
* *
* \sa class CwiseBinaryOp, MatrixBase::cwiseQuotient() * \sa class CwiseBinaryOp, MatrixBase::cwiseQuotient()
*/ */
struct CwiseQuotientOp { struct ScalarQuotientOp {
template<typename Scalar> static Scalar op(const Scalar& a, const Scalar& b) { return a / b; } template<typename Scalar> static Scalar op(const Scalar& a, const Scalar& b) { return a / b; }
}; };
@ -175,10 +176,10 @@ MatrixBase<Scalar, Derived>::operator+=(const MatrixBase<Scalar, OtherDerived>&
*/ */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
const CwiseBinaryOp<CwiseProductOp, Derived, OtherDerived> const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
MatrixBase<Scalar, Derived>::cwiseProduct(const MatrixBase<Scalar, OtherDerived> &other) const MatrixBase<Scalar, Derived>::cwiseProduct(const MatrixBase<Scalar, OtherDerived> &other) const
{ {
return CwiseBinaryOp<CwiseProductOp, Derived, OtherDerived>(ref(), other.ref()); return CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>(ref(), other.ref());
} }
@ -188,10 +189,10 @@ MatrixBase<Scalar, Derived>::cwiseProduct(const MatrixBase<Scalar, OtherDerived>
*/ */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
const CwiseBinaryOp<CwiseQuotientOp, Derived, OtherDerived> const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
MatrixBase<Scalar, Derived>::cwiseQuotient(const MatrixBase<Scalar, OtherDerived> &other) const MatrixBase<Scalar, Derived>::cwiseQuotient(const MatrixBase<Scalar, OtherDerived> &other) const
{ {
return CwiseBinaryOp<CwiseQuotientOp, Derived, OtherDerived>(ref(), other.ref()); return CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>(ref(), other.ref());
} }
@ -220,7 +221,7 @@ cwise(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived
* the keyword template as to be used if the matrix type is also a template parameter: * the keyword template as to be used if the matrix type is also a template parameter:
* \code * \code
* template <typename MatrixType> void foo(const MatrixType& m1, const MatrixType& m2) { * template <typename MatrixType> void foo(const MatrixType& m1, const MatrixType& m2) {
* m1.template cwise<CwiseProductOp>(m2); * m1.template cwise<ScalarProductOp>(m2);
* } * }
* \endcode * \endcode
* *

View File

@ -47,6 +47,7 @@ class CwiseUnaryOp : NoOperatorEquals,
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, CwiseUnaryOp>; friend class MatrixBase<Scalar, CwiseUnaryOp>;
friend class MatrixBase<Scalar, CwiseUnaryOp>::Traits;
typedef MatrixBase<Scalar, CwiseUnaryOp> Base; typedef MatrixBase<Scalar, CwiseUnaryOp> Base;
CwiseUnaryOp(const MatRef& mat) : m_matrix(mat) {} CwiseUnaryOp(const MatRef& mat) : m_matrix(mat) {}
@ -76,7 +77,7 @@ class CwiseUnaryOp : NoOperatorEquals,
* *
* \sa class CwiseUnaryOp, MatrixBase::operator- * \sa class CwiseUnaryOp, MatrixBase::operator-
*/ */
struct CwiseOppositeOp { struct ScalarOppositeOp {
template<typename Scalar> static Scalar op(const Scalar& a) { return -a; } template<typename Scalar> static Scalar op(const Scalar& a) { return -a; }
}; };
@ -84,7 +85,7 @@ struct CwiseOppositeOp {
* *
* \sa class CwiseUnaryOp, MatrixBase::cwiseAbs * \sa class CwiseUnaryOp, MatrixBase::cwiseAbs
*/ */
struct CwiseAbsOp { struct ScalarAbsOp {
template<typename Scalar> static Scalar op(const Scalar& a) { return ei_abs(a); } template<typename Scalar> static Scalar op(const Scalar& a) { return ei_abs(a); }
}; };
@ -92,19 +93,19 @@ struct CwiseAbsOp {
/** \returns an expression of the opposite of \c *this /** \returns an expression of the opposite of \c *this
*/ */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
const CwiseUnaryOp<CwiseOppositeOp,Derived> const CwiseUnaryOp<ScalarOppositeOp,Derived>
MatrixBase<Scalar, Derived>::operator-() const MatrixBase<Scalar, Derived>::operator-() const
{ {
return CwiseUnaryOp<CwiseOppositeOp,Derived>(ref()); return CwiseUnaryOp<ScalarOppositeOp,Derived>(ref());
} }
/** \returns an expression of the opposite of \c *this /** \returns an expression of the opposite of \c *this
*/ */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
const CwiseUnaryOp<CwiseAbsOp,Derived> const CwiseUnaryOp<ScalarAbsOp,Derived>
MatrixBase<Scalar, Derived>::cwiseAbs() const MatrixBase<Scalar, Derived>::cwiseAbs() const
{ {
return CwiseUnaryOp<CwiseAbsOp,Derived>(ref()); return CwiseUnaryOp<ScalarAbsOp,Derived>(ref());
} }
@ -133,7 +134,7 @@ cwise(const MatrixBase<Scalar, Derived> &mat)
* the keyword template as to be used if the matrix type is also a template parameter: * the keyword template as to be used if the matrix type is also a template parameter:
* \code * \code
* template <typename MatrixType> void foo(const MatrixType& m) { * template <typename MatrixType> void foo(const MatrixType& m) {
* m.template cwise<CwiseAbsOp>(); * m.template cwise<ScalarAbsOp>();
* } * }
* \endcode * \endcode
* *
@ -152,7 +153,7 @@ MatrixBase<Scalar, Derived>::cwise() const
* *
* \sa class CwiseUnaryOp, MatrixBase::conjugate() * \sa class CwiseUnaryOp, MatrixBase::conjugate()
*/ */
struct ConjugateOp { struct ScalarConjugateOp {
template<typename Scalar> static Scalar op(const Scalar& a) { return ei_conj(a); } template<typename Scalar> static Scalar op(const Scalar& a) { return ei_conj(a); }
}; };
@ -160,10 +161,10 @@ struct ConjugateOp {
* *
* \sa adjoint(), class Conjugate */ * \sa adjoint(), class Conjugate */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
const CwiseUnaryOp<ConjugateOp, Derived> const CwiseUnaryOp<ScalarConjugateOp, Derived>
MatrixBase<Scalar, Derived>::conjugate() const MatrixBase<Scalar, Derived>::conjugate() const
{ {
return CwiseUnaryOp<ConjugateOp, Derived>(ref()); return CwiseUnaryOp<ScalarConjugateOp, Derived>(ref());
} }

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -44,12 +44,13 @@ template<typename MatrixType> class DiagonalCoeffs
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, DiagonalCoeffs>; friend class MatrixBase<Scalar, DiagonalCoeffs>;
friend class MatrixBase<Scalar, DiagonalCoeffs>::Traits;
typedef MatrixBase<Scalar, DiagonalCoeffs> Base; typedef MatrixBase<Scalar, DiagonalCoeffs> Base;
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {} DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
private: private:
enum { enum {
RowsAtCompileTime = MatrixType::Traits::SizeAtCompileTime == Dynamic ? Dynamic RowsAtCompileTime = MatrixType::Traits::SizeAtCompileTime == Dynamic ? Dynamic
@ -65,17 +66,17 @@ template<typename MatrixType> class DiagonalCoeffs
const DiagonalCoeffs& _ref() const { return *this; } const DiagonalCoeffs& _ref() const { return *this; }
int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); } int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
int _cols() const { return 1; } int _cols() const { return 1; }
Scalar& _coeffRef(int row, int) Scalar& _coeffRef(int row, int)
{ {
return m_matrix.coeffRef(row, row); return m_matrix.coeffRef(row, row);
} }
Scalar _coeff(int row, int) const Scalar _coeff(int row, int) const
{ {
return m_matrix.coeff(row, row); return m_matrix.coeff(row, row);
} }
protected: protected:
MatRef m_matrix; MatRef m_matrix;
}; };

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -47,6 +47,7 @@ class DiagonalMatrix : NoOperatorEquals,
typedef typename CoeffsVectorType::Scalar Scalar; typedef typename CoeffsVectorType::Scalar Scalar;
typedef typename CoeffsVectorType::Ref CoeffsVecRef; typedef typename CoeffsVectorType::Ref CoeffsVecRef;
friend class MatrixBase<Scalar, DiagonalMatrix>; friend class MatrixBase<Scalar, DiagonalMatrix>;
friend class MatrixBase<Scalar, DiagonalMatrix>::Traits;
typedef MatrixBase<Scalar, DiagonalMatrix> Base; typedef MatrixBase<Scalar, DiagonalMatrix> Base;
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs) DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
@ -54,7 +55,7 @@ class DiagonalMatrix : NoOperatorEquals,
assert(CoeffsVectorType::Traits::IsVectorAtCompileTime assert(CoeffsVectorType::Traits::IsVectorAtCompileTime
&& coeffs.size() > 0); && coeffs.size() > 0);
} }
private: private:
enum { enum {
RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime, RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime,
@ -62,16 +63,16 @@ class DiagonalMatrix : NoOperatorEquals,
MaxRowsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime, MaxRowsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime,
MaxColsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime MaxColsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime
}; };
const DiagonalMatrix& _ref() const { return *this; } const DiagonalMatrix& _ref() const { return *this; }
int _rows() const { return m_coeffs.size(); } int _rows() const { return m_coeffs.size(); }
int _cols() const { return m_coeffs.size(); } int _cols() const { return m_coeffs.size(); }
Scalar _coeff(int row, int col) const Scalar _coeff(int row, int col) const
{ {
return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0); return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0);
} }
protected: protected:
const CoeffsVecRef m_coeffs; const CoeffsVecRef m_coeffs;
}; };

View File

@ -35,12 +35,7 @@ template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic> clas
template<typename MatrixType> class Transpose; template<typename MatrixType> class Transpose;
template<typename MatrixType> class Conjugate; template<typename MatrixType> class Conjugate;
template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp; template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp;
struct CwiseProductOp;
struct CwiseQuotientOp;
template<typename UnaryOp, typename MatrixType> class CwiseUnaryOp; template<typename UnaryOp, typename MatrixType> class CwiseUnaryOp;
struct CwiseOppositeOp;
struct ConjugateOp;
struct CwiseAbsOp;
template<typename Lhs, typename Rhs> class Product; template<typename Lhs, typename Rhs> class Product;
template<typename MatrixType> class ScalarMultiple; template<typename MatrixType> class ScalarMultiple;
template<typename MatrixType> class Random; template<typename MatrixType> class Random;
@ -52,6 +47,12 @@ template<typename MatrixType> class Identity;
template<typename MatrixType> class Map; template<typename MatrixType> class Map;
template<typename Derived> class Eval; template<typename Derived> class Eval;
struct ScalarProductOp;
struct ScalarQuotientOp;
struct ScalarOppositeOp;
struct ScalarConjugateOp;
struct ScalarAbsOp;
template<typename T> struct Reference template<typename T> struct Reference
{ {
typedef T Type; typedef T Type;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -37,6 +37,7 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Identity>; friend class MatrixBase<Scalar, Identity>;
friend class MatrixBase<Scalar, Identity>::Traits;
typedef MatrixBase<Scalar, Identity> Base; typedef MatrixBase<Scalar, Identity> Base;
Identity(int rows, int cols) : m_rows(rows), m_cols(cols) Identity(int rows, int cols) : m_rows(rows), m_cols(cols)
@ -46,7 +47,7 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
&& cols > 0 && cols > 0
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
} }
private: private:
enum { enum {
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
@ -54,16 +55,16 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
}; };
const Identity& _ref() const { return *this; } const Identity& _ref() const { return *this; }
int _rows() const { return m_rows.value(); } int _rows() const { return m_rows.value(); }
int _cols() const { return m_cols.value(); } int _cols() const { return m_cols.value(); }
Scalar _coeff(int row, int col) const Scalar _coeff(int row, int col) const
{ {
return row == col ? static_cast<Scalar>(1) : static_cast<Scalar>(0); return row == col ? static_cast<Scalar>(1) : static_cast<Scalar>(0);
} }
protected: protected:
const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows; const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows;
const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols; const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -44,6 +44,7 @@ template<typename MatrixType> class Map
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Map>; friend class MatrixBase<Scalar, Map>;
friend class MatrixBase<Scalar, Map>::Traits;
typedef MatrixBase<Scalar, Map> Base; typedef MatrixBase<Scalar, Map> Base;
private: private:
@ -58,7 +59,7 @@ template<typename MatrixType> class Map
const Map& _ref() const { return *this; } const Map& _ref() const { return *this; }
int _rows() const { return m_rows; } int _rows() const { return m_rows; }
int _cols() const { return m_cols; } int _cols() const { return m_cols; }
const Scalar& _coeff(int row, int col) const const Scalar& _coeff(int row, int col) const
{ {
if(Order == ColumnMajor) if(Order == ColumnMajor)
@ -66,7 +67,7 @@ template<typename MatrixType> class Map
else // RowMajor else // RowMajor
return m_data[col + row * m_cols]; return m_data[col + row * m_cols];
} }
Scalar& _coeffRef(int row, int col) Scalar& _coeffRef(int row, int col)
{ {
if(Order == ColumnMajor) if(Order == ColumnMajor)
@ -74,7 +75,7 @@ template<typename MatrixType> class Map
else // RowMajor else // RowMajor
return const_cast<Scalar*>(m_data)[col + row * m_cols]; return const_cast<Scalar*>(m_data)[col + row * m_cols];
} }
public: public:
Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols) Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols)
{ {
@ -83,9 +84,9 @@ template<typename MatrixType> class Map
&& cols > 0 && cols > 0
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
} }
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
protected: protected:
const Scalar* m_data; const Scalar* m_data;
const int m_rows, m_cols; const int m_rows, m_cols;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -79,13 +79,14 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
{ {
public: public:
friend class MatrixBase<_Scalar, Matrix>; friend class MatrixBase<_Scalar, Matrix>;
friend class MatrixBase<_Scalar, Matrix>::Traits;
friend class Map<Matrix>; friend class Map<Matrix>;
typedef MatrixBase<_Scalar, Matrix> Base; typedef MatrixBase<_Scalar, Matrix> Base;
typedef _Scalar Scalar; typedef _Scalar Scalar;
typedef MatrixRef<Matrix> Ref; typedef MatrixRef<Matrix> Ref;
friend class MatrixRef<Matrix>; friend class MatrixRef<Matrix>;
private: private:
enum { enum {
RowsAtCompileTime = _Rows, RowsAtCompileTime = _Rows,
@ -103,7 +104,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
Ref _ref() const { return Ref(*this); } Ref _ref() const { return Ref(*this); }
int _rows() const { return m_storage.rows(); } int _rows() const { return m_storage.rows(); }
int _cols() const { return m_storage.cols(); } int _cols() const { return m_storage.cols(); }
const Scalar& _coeff(int row, int col) const const Scalar& _coeff(int row, int col) const
{ {
if(StorageOrder == ColumnMajor) if(StorageOrder == ColumnMajor)
@ -111,7 +112,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
else // RowMajor else // RowMajor
return m_storage.data()[col + row * m_storage.cols()]; return m_storage.data()[col + row * m_storage.cols()];
} }
Scalar& _coeffRef(int row, int col) Scalar& _coeffRef(int row, int col)
{ {
if(StorageOrder == ColumnMajor) if(StorageOrder == ColumnMajor)
@ -119,12 +120,12 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
else // RowMajor else // RowMajor
return m_storage.data()[col + row * m_storage.cols()]; return m_storage.data()[col + row * m_storage.cols()];
} }
public: public:
/** \returns a const pointer to the data array of this matrix */ /** \returns a const pointer to the data array of this matrix */
const Scalar *data() const const Scalar *data() const
{ return m_storage.data(); } { return m_storage.data(); }
/** \returns a pointer to the data array of this matrix */ /** \returns a pointer to the data array of this matrix */
Scalar *data() Scalar *data()
{ return m_storage.data(); } { return m_storage.data(); }
@ -148,7 +149,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
* is allowed. The resizing, if any, is then done in the appropriate way so that * is allowed. The resizing, if any, is then done in the appropriate way so that
* row-vectors remain row-vectors and vectors remain vectors. * row-vectors remain row-vectors and vectors remain vectors.
*/ */
template<typename OtherDerived> template<typename OtherDerived>
Matrix& operator=(const MatrixBase<Scalar, OtherDerived>& other) Matrix& operator=(const MatrixBase<Scalar, OtherDerived>& other)
{ {
if(RowsAtCompileTime == 1) if(RowsAtCompileTime == 1)
@ -164,7 +165,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
else resize(other.rows(), other.cols()); else resize(other.rows(), other.cols());
return Base::operator=(other); return Base::operator=(other);
} }
/** This is a special case of the templated operator=. Its purpose is to /** This is a special case of the templated operator=. Its purpose is to
* prevent a default operator= from hiding the templated operator=. * prevent a default operator= from hiding the templated operator=.
*/ */
@ -172,19 +173,19 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
{ {
return operator=<Matrix>(other); return operator=<Matrix>(other);
} }
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=) EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=)
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=) EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=)
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=) EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=)
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=) EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=)
static const Map<Matrix> map(const Scalar* array, int rows, int cols); static const Map<Matrix> map(const Scalar* array, int rows, int cols);
static const Map<Matrix> map(const Scalar* array, int size); static const Map<Matrix> map(const Scalar* array, int size);
static const Map<Matrix> map(const Scalar* array); static const Map<Matrix> map(const Scalar* array);
static Map<Matrix> map(Scalar* array, int rows, int cols); static Map<Matrix> map(Scalar* array, int rows, int cols);
static Map<Matrix> map(Scalar* array, int size); static Map<Matrix> map(Scalar* array, int size);
static Map<Matrix> map(Scalar* array); static Map<Matrix> map(Scalar* array);
/** Default constructor, does nothing. Only for fixed-size matrices. /** Default constructor, does nothing. Only for fixed-size matrices.
* For dynamic-size matrices and vectors, this constructor is forbidden (guarded by * For dynamic-size matrices and vectors, this constructor is forbidden (guarded by
* an assertion) because it would leave the matrix without an allocated data buffer. * an assertion) because it would leave the matrix without an allocated data buffer.
@ -193,7 +194,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
{ {
assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0); assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0);
} }
/** Constructs a vector or row-vector with given dimension. \only_for_vectors /** Constructs a vector or row-vector with given dimension. \only_for_vectors
* *
* Note that this is only useful for dynamic-size vectors. For fixed-size vectors, * Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
@ -208,7 +209,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
|| (ColsAtCompileTime == 1 || (ColsAtCompileTime == 1
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == dim))); && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == dim)));
} }
/** This constructor has two very different behaviors, depending on the type of *this. /** This constructor has two very different behaviors, depending on the type of *this.
* *
* \li When Matrix is a fixed-size vector type of size 2, this constructor constructs * \li When Matrix is a fixed-size vector type of size 2, this constructor constructs
@ -271,7 +272,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
Matrix(const Scalar *data, int rows, int cols); Matrix(const Scalar *data, int rows, int cols);
Matrix(const Scalar *data, int size); Matrix(const Scalar *data, int size);
explicit Matrix(const Scalar *data); explicit Matrix(const Scalar *data);
/** Constructor copying the value of the expression \a other */ /** Constructor copying the value of the expression \a other */
template<typename OtherDerived> template<typename OtherDerived>
Matrix(const MatrixBase<Scalar, OtherDerived>& other) Matrix(const MatrixBase<Scalar, OtherDerived>& other)

View File

@ -143,8 +143,8 @@ template<typename Scalar, typename Derived> class MatrixBase
* \sa class NumTraits * \sa class NumTraits
*/ */
typedef typename NumTraits<Scalar>::Real RealScalar; typedef typename NumTraits<Scalar>::Real RealScalar;
/// \name a - matrix properties /// \name matrix properties
//@{ //@{
/** \returns the number of rows. \sa cols(), Traits::RowsAtCompileTime */ /** \returns the number of rows. \sa cols(), Traits::RowsAtCompileTime */
int rows() const { return static_cast<const Derived *>(this)->_rows(); } int rows() const { return static_cast<const Derived *>(this)->_rows(); }
@ -163,12 +163,12 @@ template<typename Scalar, typename Derived> class MatrixBase
/** \returns a Ref to *this. \sa Ref */ /** \returns a Ref to *this. \sa Ref */
Ref ref() const Ref ref() const
{ return static_cast<const Derived *>(this)->_ref(); } { return static_cast<const Derived *>(this)->_ref(); }
//@{ //@{
/** Copies \a other into *this. \returns a reference to *this. */ /** Copies \a other into *this. \returns a reference to *this. */
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator=(const MatrixBase<Scalar, OtherDerived>& other); Derived& operator=(const MatrixBase<Scalar, OtherDerived>& other);
/** Special case of the template operator=, in order to prevent the compiler /** Special case of the template operator=, in order to prevent the compiler
* from generating a default operator= (issue hit with g++ 4.1) * from generating a default operator= (issue hit with g++ 4.1)
*/ */
@ -176,7 +176,7 @@ template<typename Scalar, typename Derived> class MatrixBase
{ {
return this->operator=<Derived>(other); return this->operator=<Derived>(other);
} }
/** swaps *this with the expression \a other. /** swaps *this with the expression \a other.
* *
* \note \a other is only marked const because I couln't find another way * \note \a other is only marked const because I couln't find another way
@ -186,22 +186,22 @@ template<typename Scalar, typename Derived> class MatrixBase
template<typename OtherDerived> template<typename OtherDerived>
void swap(const MatrixBase<Scalar, OtherDerived>& other); void swap(const MatrixBase<Scalar, OtherDerived>& other);
//@} //@}
/// \name c - sub-matrices /// \name sub-matrices
//@{ //@{
Row<Derived> row(int i); Row<Derived> row(int i);
const Row<Derived> row(int i) const; const Row<Derived> row(int i) const;
Column<Derived> col(int i); Column<Derived> col(int i);
const Column<Derived> col(int i) const; const Column<Derived> col(int i) const;
Minor<Derived> minor(int row, int col); Minor<Derived> minor(int row, int col);
const Minor<Derived> minor(int row, int col) const; const Minor<Derived> minor(int row, int col) const;
Block<Derived> block(int startRow, int startCol, int blockRows, int blockCols); Block<Derived> block(int startRow, int startCol, int blockRows, int blockCols);
const Block<Derived> const Block<Derived>
block(int startRow, int startCol, int blockRows, int blockCols) const; block(int startRow, int startCol, int blockRows, int blockCols) const;
Block<Derived> block(int start, int size); Block<Derived> block(int start, int size);
const Block<Derived> block(int start, int size) const; const Block<Derived> block(int start, int size) const;
@ -223,7 +223,7 @@ template<typename Scalar, typename Derived> class MatrixBase
const DiagonalCoeffs<Derived> diagonal() const; const DiagonalCoeffs<Derived> diagonal() const;
//@} //@}
/// \name d - matrix transformation /// \name matrix transformation
//@{ //@{
template<typename NewScalar> const Cast<NewScalar, Derived> cast() const; template<typename NewScalar> const Cast<NewScalar, Derived> cast() const;
@ -231,23 +231,24 @@ template<typename Scalar, typename Derived> class MatrixBase
Transpose<Derived> transpose(); Transpose<Derived> transpose();
const Transpose<Derived> transpose() const; const Transpose<Derived> transpose() const;
const CwiseUnaryOp<ConjugateOp, Derived> conjugate() const; const CwiseUnaryOp<ScalarConjugateOp, Derived> conjugate() const;
const Transpose<CwiseUnaryOp<ConjugateOp, Derived> > adjoint() const; const Transpose<CwiseUnaryOp<ScalarConjugateOp, Derived> > adjoint() const;
const ScalarMultiple<Derived> normalized() const; const ScalarMultiple<Derived> normalized() const;
//@} //@}
/// \name f - metrics (??) // FIXME not sure about the following name
/// \name metrics
//@{ //@{
Scalar trace() const; Scalar trace() const;
template<typename OtherDerived> template<typename OtherDerived>
Scalar dot(const MatrixBase<Scalar, OtherDerived>& other) const; Scalar dot(const MatrixBase<Scalar, OtherDerived>& other) const;
RealScalar norm2() const; RealScalar norm2() const;
RealScalar norm() const; RealScalar norm() const;
//@} //@}
static const Eval<Random<Derived> > random(int rows, int cols); static const Eval<Random<Derived> > random(int rows, int cols);
static const Eval<Random<Derived> > random(int size); static const Eval<Random<Derived> > random(int size);
static const Eval<Random<Derived> > random(); static const Eval<Random<Derived> > random();
@ -259,24 +260,24 @@ template<typename Scalar, typename Derived> class MatrixBase
static const Ones<Derived> ones(); static const Ones<Derived> ones();
static const Identity<Derived> identity(); static const Identity<Derived> identity();
static const Identity<Derived> identity(int rows, int cols); static const Identity<Derived> identity(int rows, int cols);
Derived& setZero(); Derived& setZero();
Derived& setOnes(); Derived& setOnes();
Derived& setRandom(); Derived& setRandom();
Derived& setIdentity(); Derived& setIdentity();
/// \name g - matrix diagnostic and comparison /// \name matrix diagnostic and comparison
//@{ //@{
bool isZero(RealScalar prec = precision<Scalar>()) const; bool isZero(RealScalar prec = precision<Scalar>()) const;
bool isOnes(RealScalar prec = precision<Scalar>()) const; bool isOnes(RealScalar prec = precision<Scalar>()) const;
bool isIdentity(RealScalar prec = precision<Scalar>()) const; bool isIdentity(RealScalar prec = precision<Scalar>()) const;
bool isDiagonal(RealScalar prec = precision<Scalar>()) const; bool isDiagonal(RealScalar prec = precision<Scalar>()) const;
template<typename OtherDerived> template<typename OtherDerived>
bool isOrtho(const MatrixBase<Scalar, OtherDerived>& other, bool isOrtho(const MatrixBase<Scalar, OtherDerived>& other,
RealScalar prec = precision<Scalar>()) const; RealScalar prec = precision<Scalar>()) const;
bool isOrtho(RealScalar prec = precision<Scalar>()) const; bool isOrtho(RealScalar prec = precision<Scalar>()) const;
template<typename OtherDerived> template<typename OtherDerived>
bool isApprox(const OtherDerived& other, bool isApprox(const OtherDerived& other,
RealScalar prec = precision<Scalar>()) const; RealScalar prec = precision<Scalar>()) const;
@ -286,10 +287,10 @@ template<typename Scalar, typename Derived> class MatrixBase
bool isMuchSmallerThan(const MatrixBase<Scalar, OtherDerived>& other, bool isMuchSmallerThan(const MatrixBase<Scalar, OtherDerived>& other,
RealScalar prec = precision<Scalar>()) const; RealScalar prec = precision<Scalar>()) const;
//@} //@}
/// \name e - arithemetic operators /// \name arithemetic operators
//@{ //@{
const CwiseUnaryOp<CwiseOppositeOp,Derived> operator-() const; const CwiseUnaryOp<ScalarOppositeOp,Derived> operator-() const;
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator+=(const MatrixBase<Scalar, OtherDerived>& other); Derived& operator+=(const MatrixBase<Scalar, OtherDerived>& other);
@ -306,38 +307,38 @@ template<typename Scalar, typename Derived> class MatrixBase
friend friend
const ScalarMultiple<Derived> operator*(const Scalar& scalar, const ScalarMultiple<Derived> operator*(const Scalar& scalar,
const MatrixBase& matrix) const MatrixBase& matrix)
{ return matrix*scalar; } { return matrix*scalar; }
template<typename OtherDerived> template<typename OtherDerived>
const Product<Derived, OtherDerived> const Product<Derived, OtherDerived>
lazyProduct(const MatrixBase<Scalar, OtherDerived>& other) const EIGEN_ALWAYS_INLINE; lazyProduct(const MatrixBase<Scalar, OtherDerived>& other) const EIGEN_ALWAYS_INLINE;
const CwiseUnaryOp<CwiseAbsOp,Derived> cwiseAbs() const; const CwiseUnaryOp<ScalarAbsOp,Derived> cwiseAbs() const;
template<typename OtherDerived> template<typename OtherDerived>
const CwiseBinaryOp<CwiseProductOp, Derived, OtherDerived> const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
cwiseProduct(const MatrixBase<Scalar, OtherDerived> &other) const; cwiseProduct(const MatrixBase<Scalar, OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
const CwiseBinaryOp<CwiseQuotientOp, Derived, OtherDerived> const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
cwiseQuotient(const MatrixBase<Scalar, OtherDerived> &other) const; cwiseQuotient(const MatrixBase<Scalar, OtherDerived> &other) const;
//@} //@}
/// \name b - coefficient accessors /// \name coefficient accessors
//@{ //@{
Scalar coeff(int row, int col) const; Scalar coeff(int row, int col) const;
Scalar operator()(int row, int col) const; Scalar operator()(int row, int col) const;
Scalar& coeffRef(int row, int col); Scalar& coeffRef(int row, int col);
Scalar& operator()(int row, int col); Scalar& operator()(int row, int col);
Scalar coeff(int index) const; Scalar coeff(int index) const;
Scalar operator[](int index) const; Scalar operator[](int index) const;
Scalar& coeffRef(int index); Scalar& coeffRef(int index);
Scalar& operator[](int index); Scalar& operator[](int index);
Scalar x() const; Scalar x() const;
Scalar y() const; Scalar y() const;
Scalar z() const; Scalar z() const;
@ -348,7 +349,7 @@ template<typename Scalar, typename Derived> class MatrixBase
Scalar& w(); Scalar& w();
//@} //@}
/// \name h - special functions /// \name special functions
//@{ //@{
const Eval<Derived> eval() const EIGEN_ALWAYS_INLINE; const Eval<Derived> eval() const EIGEN_ALWAYS_INLINE;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -31,8 +31,9 @@ template<typename MatrixType> class MatrixRef
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, MatrixRef>; friend class MatrixBase<Scalar, MatrixRef>;
friend class MatrixBase<Scalar, MatrixRef>::Traits;
typedef MatrixBase<Scalar, MatrixRef> Base; typedef MatrixBase<Scalar, MatrixRef> Base;
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {} MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
~MatrixRef() {} ~MatrixRef() {}
@ -54,7 +55,7 @@ template<typename MatrixType> class MatrixRef
{ {
return m_matrix._coeff(row, col); return m_matrix._coeff(row, col);
} }
Scalar& _coeffRef(int row, int col) Scalar& _coeffRef(int row, int col)
{ {
return const_cast<MatrixType*>(&m_matrix)->_coeffRef(row, col); return const_cast<MatrixType*>(&m_matrix)->_coeffRef(row, col);

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -44,8 +44,9 @@ template<typename MatrixType> class Minor
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, Minor>; friend class MatrixBase<Scalar, Minor>;
friend class MatrixBase<Scalar, Minor>::Traits;
typedef MatrixBase<Scalar, Minor> Base; typedef MatrixBase<Scalar, Minor> Base;
Minor(const MatRef& matrix, Minor(const MatRef& matrix,
int row, int col) int row, int col)
: m_matrix(matrix), m_row(row), m_col(col) : m_matrix(matrix), m_row(row), m_col(col)
@ -53,9 +54,9 @@ template<typename MatrixType> class Minor
assert(row >= 0 && row < matrix.rows() assert(row >= 0 && row < matrix.rows()
&& col >= 0 && col < matrix.cols()); && col >= 0 && col < matrix.cols());
} }
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
private: private:
enum { enum {
RowsAtCompileTime = (MatrixType::Traits::RowsAtCompileTime != Dynamic) ? RowsAtCompileTime = (MatrixType::Traits::RowsAtCompileTime != Dynamic) ?
@ -71,17 +72,17 @@ template<typename MatrixType> class Minor
const Minor& _ref() const { return *this; } const Minor& _ref() const { return *this; }
int _rows() const { return m_matrix.rows() - 1; } int _rows() const { return m_matrix.rows() - 1; }
int _cols() const { return m_matrix.cols() - 1; } int _cols() const { return m_matrix.cols() - 1; }
Scalar& _coeffRef(int row, int col) Scalar& _coeffRef(int row, int col)
{ {
return m_matrix.coeffRef(row + (row >= m_row), col + (col >= m_col)); return m_matrix.coeffRef(row + (row >= m_row), col + (col >= m_col));
} }
Scalar _coeff(int row, int col) const Scalar _coeff(int row, int col) const
{ {
return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col)); return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
} }
protected: protected:
MatRef m_matrix; MatRef m_matrix;
const int m_row, m_col; const int m_row, m_col;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -38,6 +38,7 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Ones>; friend class MatrixBase<Scalar, Ones>;
friend class MatrixBase<Scalar, Ones>::Traits;
typedef MatrixBase<Scalar, Ones> Base; typedef MatrixBase<Scalar, Ones> Base;
private: private:
@ -47,16 +48,16 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
}; };
const Ones& _ref() const { return *this; } const Ones& _ref() const { return *this; }
int _rows() const { return m_rows.value(); } int _rows() const { return m_rows.value(); }
int _cols() const { return m_cols.value(); } int _cols() const { return m_cols.value(); }
Scalar _coeff(int, int) const Scalar _coeff(int, int) const
{ {
return static_cast<Scalar>(1); return static_cast<Scalar>(1);
} }
public: public:
Ones(int rows, int cols) : m_rows(rows), m_cols(cols) Ones(int rows, int cols) : m_rows(rows), m_cols(cols)
{ {
@ -65,7 +66,7 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
&& cols > 0 && cols > 0
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
} }
protected: protected:
const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows; const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows;
const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols; const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -80,14 +80,15 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
typedef typename Lhs::Ref LhsRef; typedef typename Lhs::Ref LhsRef;
typedef typename Rhs::Ref RhsRef; typedef typename Rhs::Ref RhsRef;
friend class MatrixBase<Scalar, Product>; friend class MatrixBase<Scalar, Product>;
friend class MatrixBase<Scalar, Product>::Traits;
typedef MatrixBase<Scalar, Product> Base; typedef MatrixBase<Scalar, Product> Base;
Product(const LhsRef& lhs, const RhsRef& rhs) Product(const LhsRef& lhs, const RhsRef& rhs)
: m_lhs(lhs), m_rhs(rhs) : m_lhs(lhs), m_rhs(rhs)
{ {
assert(lhs.cols() == rhs.rows()); assert(lhs.cols() == rhs.rows());
} }
private: private:
enum { enum {
RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime, RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
@ -99,7 +100,7 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
const Product& _ref() const { return *this; } const Product& _ref() const { return *this; }
int _rows() const { return m_lhs.rows(); } int _rows() const { return m_lhs.rows(); }
int _cols() const { return m_rhs.cols(); } int _cols() const { return m_rhs.cols(); }
Scalar _coeff(int row, int col) const Scalar _coeff(int row, int col) const
{ {
Scalar res; Scalar res;
@ -117,7 +118,7 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
} }
return res; return res;
} }
protected: protected:
const LhsRef m_lhs; const LhsRef m_lhs;
const RhsRef m_rhs; const RhsRef m_rhs;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -38,8 +38,9 @@ template<typename MatrixType> class Random : NoOperatorEquals,
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Random>; friend class MatrixBase<Scalar, Random>;
friend class MatrixBase<Scalar, Random>::Traits;
typedef MatrixBase<Scalar, Random> Base; typedef MatrixBase<Scalar, Random> Base;
private: private:
enum { enum {
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
@ -47,16 +48,16 @@ template<typename MatrixType> class Random : NoOperatorEquals,
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
}; };
const Random& _ref() const { return *this; } const Random& _ref() const { return *this; }
int _rows() const { return m_rows.value(); } int _rows() const { return m_rows.value(); }
int _cols() const { return m_cols.value(); } int _cols() const { return m_cols.value(); }
Scalar _coeff(int, int) const Scalar _coeff(int, int) const
{ {
return ei_random<Scalar>(); return ei_random<Scalar>();
} }
public: public:
Random(int rows, int cols) : m_rows(rows), m_cols(cols) Random(int rows, int cols) : m_rows(rows), m_cols(cols)
{ {
@ -65,7 +66,7 @@ template<typename MatrixType> class Random : NoOperatorEquals,
&& cols > 0 && cols > 0
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
} }
protected: protected:
const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows; const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows;
const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols; const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -52,6 +52,7 @@ template<typename MatrixType> class Row
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, Row>; friend class MatrixBase<Scalar, Row>;
friend class MatrixBase<Scalar, Row>::Traits;
typedef MatrixBase<Scalar, Row> Base; typedef MatrixBase<Scalar, Row> Base;
Row(const MatRef& matrix, int row) Row(const MatRef& matrix, int row)
@ -59,15 +60,15 @@ template<typename MatrixType> class Row
{ {
assert(row >= 0 && row < matrix.rows()); assert(row >= 0 && row < matrix.rows());
} }
template<typename OtherDerived> template<typename OtherDerived>
Row& operator=(const MatrixBase<Scalar, OtherDerived>& other) Row& operator=(const MatrixBase<Scalar, OtherDerived>& other)
{ {
return MatrixBase<Scalar, Row<MatrixType> >::operator=(other); return MatrixBase<Scalar, Row<MatrixType> >::operator=(other);
} }
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
private: private:
enum { enum {
RowsAtCompileTime = 1, RowsAtCompileTime = 1,
@ -77,20 +78,20 @@ template<typename MatrixType> class Row
}; };
const Row& _ref() const { return *this; } const Row& _ref() const { return *this; }
int _rows() const { return 1; } int _rows() const { return 1; }
int _cols() const { return m_matrix.cols(); } int _cols() const { return m_matrix.cols(); }
Scalar& _coeffRef(int, int col) Scalar& _coeffRef(int, int col)
{ {
return m_matrix.coeffRef(m_row, col); return m_matrix.coeffRef(m_row, col);
} }
Scalar _coeff(int, int col) const Scalar _coeff(int, int col) const
{ {
return m_matrix.coeff(m_row, col); return m_matrix.coeff(m_row, col);
} }
protected: protected:
MatRef m_matrix; MatRef m_matrix;
const int m_row; const int m_row;

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -43,6 +43,7 @@ template<typename MatrixType> class ScalarMultiple : NoOperatorEquals,
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, ScalarMultiple>; friend class MatrixBase<Scalar, ScalarMultiple>;
friend class MatrixBase<Scalar, ScalarMultiple>::Traits;
typedef MatrixBase<Scalar, ScalarMultiple> Base; typedef MatrixBase<Scalar, ScalarMultiple> Base;
ScalarMultiple(const MatRef& matrix, Scalar factor) ScalarMultiple(const MatRef& matrix, Scalar factor)
@ -70,37 +71,37 @@ template<typename MatrixType> class ScalarMultiple : NoOperatorEquals,
const Scalar m_factor; const Scalar m_factor;
}; };
/** relates MatrixBase sa class ScalarMultiple */ /** relates MatrixBase sa class ScalarMultiple */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
const ScalarMultiple<Derived> const ScalarMultiple<Derived>
MatrixBase<Scalar, Derived>::operator*(const Scalar& scalar) const MatrixBase<Scalar, Derived>::operator*(const Scalar& scalar) const
{ {
return ScalarMultiple<Derived>(ref(), scalar); return ScalarMultiple<Derived>(ref(), scalar);
}
/** \relates MatrixBase \sa class ScalarMultiple */
template<typename Scalar, typename Derived>
const ScalarMultiple<Derived>
MatrixBase<Scalar, Derived>::operator/(const Scalar& scalar) const
{
assert(NumTraits<Scalar>::HasFloatingPoint);
return ScalarMultiple<Derived>(ref(), static_cast<Scalar>(1) / scalar);
} }
/** \sa ScalarMultiple */ /** \relates MatrixBase \sa class ScalarMultiple */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
Derived& const ScalarMultiple<Derived>
MatrixBase<Scalar, Derived>::operator*=(const Scalar& other) MatrixBase<Scalar, Derived>::operator/(const Scalar& scalar) const
{ {
return *this = *this * other; assert(NumTraits<Scalar>::HasFloatingPoint);
} return ScalarMultiple<Derived>(ref(), static_cast<Scalar>(1) / scalar);
}
/** \sa ScalarMultiple */
template<typename Scalar, typename Derived> /** \sa ScalarMultiple */
Derived& template<typename Scalar, typename Derived>
MatrixBase<Scalar, Derived>::operator/=(const Scalar& other) Derived&
{ MatrixBase<Scalar, Derived>::operator*=(const Scalar& other)
return *this = *this / other; {
return *this = *this * other;
}
/** \sa ScalarMultiple */
template<typename Scalar, typename Derived>
Derived&
MatrixBase<Scalar, Derived>::operator/=(const Scalar& other)
{
return *this = *this / other;
} }
#endif // EIGEN_SCALARMULTIPLE_H #endif // EIGEN_SCALARMULTIPLE_H

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -44,12 +44,13 @@ template<typename MatrixType> class Transpose
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, Transpose>; friend class MatrixBase<Scalar, Transpose>;
friend class MatrixBase<Scalar, Transpose>::Traits;
typedef MatrixBase<Scalar, Transpose> Base; typedef MatrixBase<Scalar, Transpose> Base;
Transpose(const MatRef& matrix) : m_matrix(matrix) {} Transpose(const MatRef& matrix) : m_matrix(matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
private: private:
enum { enum {
RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime, RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
@ -61,17 +62,17 @@ template<typename MatrixType> class Transpose
const Transpose& _ref() const { return *this; } const Transpose& _ref() const { return *this; }
int _rows() const { return m_matrix.cols(); } int _rows() const { return m_matrix.cols(); }
int _cols() const { return m_matrix.rows(); } int _cols() const { return m_matrix.rows(); }
Scalar& _coeffRef(int row, int col) Scalar& _coeffRef(int row, int col)
{ {
return m_matrix.coeffRef(col, row); return m_matrix.coeffRef(col, row);
} }
Scalar _coeff(int row, int col) const Scalar _coeff(int row, int col) const
{ {
return m_matrix.coeff(col, row); return m_matrix.coeff(col, row);
} }
protected: protected:
MatRef m_matrix; MatRef m_matrix;
}; };
@ -102,9 +103,9 @@ MatrixBase<Scalar, Derived>::transpose() const
* Example: \include MatrixBase_adjoint.cpp * Example: \include MatrixBase_adjoint.cpp
* Output: \verbinclude MatrixBase_adjoint.out * Output: \verbinclude MatrixBase_adjoint.out
* *
* \sa transpose(), conjugate(), class Transpose, class ConjugateOp */ * \sa transpose(), conjugate(), class Transpose, class ScalarConjugateOp */
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
const Transpose<CwiseUnaryOp<ConjugateOp, Derived> > const Transpose<CwiseUnaryOp<ScalarConjugateOp, Derived> >
MatrixBase<Scalar, Derived>::adjoint() const MatrixBase<Scalar, Derived>::adjoint() const
{ {
return conjugate().transpose(); return conjugate().transpose();

View File

@ -5,12 +5,12 @@
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 3 of the License, or (at your option) any later version.
// //
// Alternatively, you can redistribute it and/or // Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // 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. // the License, or (at your option) any later version.
// //
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // 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 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details. // 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 // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
@ -38,8 +38,9 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Zero>; friend class MatrixBase<Scalar, Zero>;
friend class MatrixBase<Scalar, Zero>::Traits;
typedef MatrixBase<Scalar, Zero> Base; typedef MatrixBase<Scalar, Zero> Base;
private: private:
enum { enum {
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
@ -51,12 +52,12 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
const Zero& _ref() const { return *this; } const Zero& _ref() const { return *this; }
int _rows() const { return m_rows.value(); } int _rows() const { return m_rows.value(); }
int _cols() const { return m_cols.value(); } int _cols() const { return m_cols.value(); }
Scalar _coeff(int, int) const Scalar _coeff(int, int) const
{ {
return static_cast<Scalar>(0); return static_cast<Scalar>(0);
} }
public: public:
Zero(int rows, int cols) : m_rows(rows), m_cols(cols) Zero(int rows, int cols) : m_rows(rows), m_cols(cols)
{ {
@ -65,7 +66,7 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
&& cols > 0 && cols > 0
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
} }
protected: protected:
const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows; const IntAtRunTimeIfDynamic<RowsAtCompileTime> m_rows;
const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols; const IntAtRunTimeIfDynamic<ColsAtCompileTime> m_cols;

View File

@ -69,12 +69,10 @@ The To-do wiki for Eigen is here: <a href="http://techbase.kde.org/index.php?tit
<a name="compiler_support"></a> <a name="compiler_support"></a>
<h2>Compiler Support</h2> <h2>Compiler Support</h2>
Eigen is standard C++98 and so should theoretically be compatible with any compliant compiler. Of course, in practice, things are slightly different. Eigen is standard C++98 and so should theoretically be compatible with any compliant compiler. Of course, in practice, things might be slightly different. At least, Eigen is known to compile with any version of GCC from 3.3 to 4.3 as well as with recent versions of ICC.
Eigen is well tested with recent versions of GCC and ICC. Both GCC 4.2 and ICC gives very good performance. ICC might provide even better performance when the auto-vectorization makes sense. For some reason the performance is not so great with GCC 4.1. Eigen is well tested with recent versions of GCC and ICC. Both GCC 4.2 and ICC gives very good performance. ICC might provide even better performance when the auto-vectorization makes sense. For some reason the performance is not so great with GCC 4.1.
Eigen is also known to compile with GCC 3.4 and 4.0. However, these later ones seems to not correctly handle friend class with the CRT design pattern. Therefore, at the moment, for any GCC versions earlier than 4.1, all private members of Eigen's classes are made public. It is up to the user to take care to access public members only.
For best performance, we recommend the following compilation flags: For best performance, we recommend the following compilation flags:
<ul> <ul>
<li>\b GCC: \c -O3 \c -DNDEBUG \c -finline-limit=10000 \c -falign-functions=64 </li> <li>\b GCC: \c -O3 \c -DNDEBUG \c -finline-limit=10000 \c -falign-functions=64 </li>