* 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

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

View File

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

View File

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

View File

@@ -6,12 +6,12 @@
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -44,7 +44,7 @@
* Here is an example illustrating this:
* \include class_CwiseBinaryOp.cpp
*
* \sa class CwiseProductOp, class CwiseQuotientOp
* \sa class ScalarProductOp, class ScalarQuotientOp
*/
template<typename BinaryOp, typename Lhs, typename Rhs>
class CwiseBinaryOp : NoOperatorEquals,
@@ -55,6 +55,7 @@ class CwiseBinaryOp : NoOperatorEquals,
typedef typename Lhs::Ref LhsRef;
typedef typename Rhs::Ref RhsRef;
friend class MatrixBase<Scalar, CwiseBinaryOp>;
friend class MatrixBase<Scalar, CwiseBinaryOp>::Traits;
typedef MatrixBase<Scalar, CwiseBinaryOp> Base;
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));
}
protected:
const LhsRef m_lhs;
const RhsRef m_rhs;
@@ -105,7 +106,7 @@ struct CwiseDifferenceOp {
*
* \sa class CwiseBinaryOp, MatrixBase::cwiseProduct()
*/
struct CwiseProductOp {
struct ScalarProductOp {
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()
*/
struct CwiseQuotientOp {
struct ScalarQuotientOp {
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 OtherDerived>
const CwiseBinaryOp<CwiseProductOp, Derived, OtherDerived>
const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
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 OtherDerived>
const CwiseBinaryOp<CwiseQuotientOp, Derived, OtherDerived>
const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
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:
* \code
* template <typename MatrixType> void foo(const MatrixType& m1, const MatrixType& m2) {
* m1.template cwise<CwiseProductOp>(m2);
* m1.template cwise<ScalarProductOp>(m2);
* }
* \endcode
*

View File

@@ -47,6 +47,7 @@ class CwiseUnaryOp : NoOperatorEquals,
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, CwiseUnaryOp>;
friend class MatrixBase<Scalar, CwiseUnaryOp>::Traits;
typedef MatrixBase<Scalar, CwiseUnaryOp> Base;
CwiseUnaryOp(const MatRef& mat) : m_matrix(mat) {}
@@ -76,7 +77,7 @@ class CwiseUnaryOp : NoOperatorEquals,
*
* \sa class CwiseUnaryOp, MatrixBase::operator-
*/
struct CwiseOppositeOp {
struct ScalarOppositeOp {
template<typename Scalar> static Scalar op(const Scalar& a) { return -a; }
};
@@ -84,7 +85,7 @@ struct CwiseOppositeOp {
*
* \sa class CwiseUnaryOp, MatrixBase::cwiseAbs
*/
struct CwiseAbsOp {
struct ScalarAbsOp {
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
*/
template<typename Scalar, typename Derived>
const CwiseUnaryOp<CwiseOppositeOp,Derived>
const CwiseUnaryOp<ScalarOppositeOp,Derived>
MatrixBase<Scalar, Derived>::operator-() const
{
return CwiseUnaryOp<CwiseOppositeOp,Derived>(ref());
return CwiseUnaryOp<ScalarOppositeOp,Derived>(ref());
}
/** \returns an expression of the opposite of \c *this
*/
template<typename Scalar, typename Derived>
const CwiseUnaryOp<CwiseAbsOp,Derived>
const CwiseUnaryOp<ScalarAbsOp,Derived>
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:
* \code
* template <typename MatrixType> void foo(const MatrixType& m) {
* m.template cwise<CwiseAbsOp>();
* m.template cwise<ScalarAbsOp>();
* }
* \endcode
*
@@ -152,7 +153,7 @@ MatrixBase<Scalar, Derived>::cwise() const
*
* \sa class CwiseUnaryOp, MatrixBase::conjugate()
*/
struct ConjugateOp {
struct ScalarConjugateOp {
template<typename Scalar> static Scalar op(const Scalar& a) { return ei_conj(a); }
};
@@ -160,10 +161,10 @@ struct ConjugateOp {
*
* \sa adjoint(), class Conjugate */
template<typename Scalar, typename Derived>
const CwiseUnaryOp<ConjugateOp, Derived>
const CwiseUnaryOp<ScalarConjugateOp, Derived>
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
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -18,7 +18,7 @@
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
@@ -44,12 +44,13 @@ template<typename MatrixType> class DiagonalCoeffs
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef;
friend class MatrixBase<Scalar, DiagonalCoeffs>;
friend class MatrixBase<Scalar, DiagonalCoeffs>::Traits;
typedef MatrixBase<Scalar, DiagonalCoeffs> Base;
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
private:
enum {
RowsAtCompileTime = MatrixType::Traits::SizeAtCompileTime == Dynamic ? Dynamic
@@ -65,17 +66,17 @@ template<typename MatrixType> class DiagonalCoeffs
const DiagonalCoeffs& _ref() const { return *this; }
int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
int _cols() const { return 1; }
Scalar& _coeffRef(int row, int)
{
return m_matrix.coeffRef(row, row);
}
Scalar _coeff(int row, int) const
{
return m_matrix.coeff(row, row);
}
protected:
MatRef m_matrix;
};

View File

@@ -5,12 +5,12 @@
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -18,7 +18,7 @@
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
@@ -47,6 +47,7 @@ class DiagonalMatrix : NoOperatorEquals,
typedef typename CoeffsVectorType::Scalar Scalar;
typedef typename CoeffsVectorType::Ref CoeffsVecRef;
friend class MatrixBase<Scalar, DiagonalMatrix>;
friend class MatrixBase<Scalar, DiagonalMatrix>::Traits;
typedef MatrixBase<Scalar, DiagonalMatrix> Base;
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
@@ -54,7 +55,7 @@ class DiagonalMatrix : NoOperatorEquals,
assert(CoeffsVectorType::Traits::IsVectorAtCompileTime
&& coeffs.size() > 0);
}
private:
enum {
RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime,
@@ -62,16 +63,16 @@ class DiagonalMatrix : NoOperatorEquals,
MaxRowsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime,
MaxColsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime
};
const DiagonalMatrix& _ref() const { return *this; }
int _rows() const { return m_coeffs.size(); }
int _cols() const { return m_coeffs.size(); }
Scalar _coeff(int row, int col) const
{
return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0);
}
protected:
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 Conjugate;
template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp;
struct CwiseProductOp;
struct CwiseQuotientOp;
template<typename UnaryOp, typename MatrixType> class CwiseUnaryOp;
struct CwiseOppositeOp;
struct ConjugateOp;
struct CwiseAbsOp;
template<typename Lhs, typename Rhs> class Product;
template<typename MatrixType> class ScalarMultiple;
template<typename MatrixType> class Random;
@@ -52,6 +47,12 @@ template<typename MatrixType> class Identity;
template<typename MatrixType> class Map;
template<typename Derived> class Eval;
struct ScalarProductOp;
struct ScalarQuotientOp;
struct ScalarOppositeOp;
struct ScalarConjugateOp;
struct ScalarAbsOp;
template<typename T> struct Reference
{
typedef T Type;

View File

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

View File

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

View File

@@ -5,12 +5,12 @@
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -18,7 +18,7 @@
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
@@ -79,13 +79,14 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
{
public:
friend class MatrixBase<_Scalar, Matrix>;
friend class MatrixBase<_Scalar, Matrix>::Traits;
friend class Map<Matrix>;
typedef MatrixBase<_Scalar, Matrix> Base;
typedef _Scalar Scalar;
typedef MatrixRef<Matrix> Ref;
friend class MatrixRef<Matrix>;
private:
enum {
RowsAtCompileTime = _Rows,
@@ -103,7 +104,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
Ref _ref() const { return Ref(*this); }
int _rows() const { return m_storage.rows(); }
int _cols() const { return m_storage.cols(); }
const Scalar& _coeff(int row, int col) const
{
if(StorageOrder == ColumnMajor)
@@ -111,7 +112,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
else // RowMajor
return m_storage.data()[col + row * m_storage.cols()];
}
Scalar& _coeffRef(int row, int col)
{
if(StorageOrder == ColumnMajor)
@@ -119,12 +120,12 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
else // RowMajor
return m_storage.data()[col + row * m_storage.cols()];
}
public:
/** \returns a const pointer to the data array of this matrix */
const Scalar *data() const
{ return m_storage.data(); }
/** \returns a pointer to the data array of this matrix */
Scalar *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
* row-vectors remain row-vectors and vectors remain vectors.
*/
template<typename OtherDerived>
template<typename OtherDerived>
Matrix& operator=(const MatrixBase<Scalar, OtherDerived>& other)
{
if(RowsAtCompileTime == 1)
@@ -164,7 +165,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
else resize(other.rows(), other.cols());
return Base::operator=(other);
}
/** This is a special case of the templated operator=. Its purpose is to
* 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);
}
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=)
EIGEN_INHERIT_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 size);
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 size);
static Map<Matrix> map(Scalar* array);
/** Default constructor, does nothing. Only for fixed-size matrices.
* 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.
@@ -193,7 +194,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
{
assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0);
}
/** 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,
@@ -208,7 +209,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
|| (ColsAtCompileTime == 1
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == dim)));
}
/** 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
@@ -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 size);
explicit Matrix(const Scalar *data);
/** Constructor copying the value of the expression \a other */
template<typename OtherDerived>
Matrix(const MatrixBase<Scalar, OtherDerived>& other)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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