mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
expand unit-tests and fix const-qualifaction bugs thus discovered
This commit is contained in:
@@ -58,7 +58,7 @@ template<typename NewScalar, typename MatrixType> class Cast : NoDefaultOperator
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename NewScalar>
|
||||
Cast<NewScalar, Derived>
|
||||
const Cast<NewScalar, Derived>
|
||||
MatrixBase<Scalar, Derived>::cast() const
|
||||
{
|
||||
return Cast<NewScalar, Derived>(static_cast<const Derived*>(this)->ref());
|
||||
|
||||
@@ -57,7 +57,7 @@ template<typename MatrixType> class Conjugate : NoDefaultOperatorEquals,
|
||||
};
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
Conjugate<Derived>
|
||||
const Conjugate<Derived>
|
||||
MatrixBase<Scalar, Derived>::conjugate() const
|
||||
{
|
||||
return Conjugate<Derived>(static_cast<const Derived*>(this)->ref());
|
||||
|
||||
@@ -63,7 +63,7 @@ template<typename Lhs, typename Rhs> class Difference : NoDefaultOperatorEquals,
|
||||
};
|
||||
|
||||
template<typename Scalar, typename Derived1, typename Derived2>
|
||||
Difference<Derived1, Derived2>
|
||||
const Difference<Derived1, Derived2>
|
||||
operator-(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived2> &mat2)
|
||||
{
|
||||
return Difference<Derived1, Derived2>(mat1.ref(), mat2.ref());
|
||||
|
||||
@@ -58,7 +58,7 @@ template<typename MatrixType> class Identity : NoDefaultOperatorEquals,
|
||||
};
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
Identity<Derived> MatrixBase<Scalar, Derived>::identity(int rows)
|
||||
const Identity<Derived> MatrixBase<Scalar, Derived>::identity(int rows)
|
||||
{
|
||||
return Identity<Derived>(rows);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
return this->operator=<Derived>(other);
|
||||
}
|
||||
|
||||
template<typename NewScalar> Cast<NewScalar, Derived> cast() const;
|
||||
template<typename NewScalar> const Cast<NewScalar, Derived> cast() const;
|
||||
|
||||
Row<Derived> row(int i) const;
|
||||
Column<Derived> col(int i) const;
|
||||
@@ -69,8 +69,9 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
Block<Derived, BlockRows, BlockCols> block(int startRow, int startCol) const;
|
||||
|
||||
Transpose<Derived> transpose() const;
|
||||
Conjugate<Derived> conjugate() const;
|
||||
Transpose<Conjugate<Derived> > adjoint() const { return conjugate().transpose(); }
|
||||
const Conjugate<Derived> conjugate() const;
|
||||
const Transpose<Conjugate<Derived> > adjoint() const
|
||||
{ return conjugate().transpose(); }
|
||||
Scalar trace() const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
@@ -81,9 +82,9 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
|
||||
static Eval<Random<Derived> >
|
||||
random(int rows = RowsAtCompileTime, int cols = ColsAtCompileTime);
|
||||
static Zero<Derived>
|
||||
static const Zero<Derived>
|
||||
zero(int rows = RowsAtCompileTime, int cols = ColsAtCompileTime);
|
||||
static Identity<Derived>
|
||||
static const Identity<Derived>
|
||||
identity(int rows = RowsAtCompileTime);
|
||||
static FromArray<Derived>
|
||||
fromArray(const Scalar* array, int rows = RowsAtCompileTime, int cols = ColsAtCompileTime);
|
||||
@@ -107,7 +108,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
const Product<Derived, OtherDerived>
|
||||
lazyProduct(const MatrixBase<Scalar, OtherDerived>& other) const EIGEN_ALWAYS_INLINE;
|
||||
|
||||
Opposite<Derived> operator-() const;
|
||||
const Opposite<Derived> operator-() const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
Derived& operator+=(const MatrixBase<Scalar, OtherDerived>& other);
|
||||
|
||||
@@ -57,7 +57,7 @@ template<typename MatrixType> class Opposite : NoDefaultOperatorEquals,
|
||||
};
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
Opposite<Derived>
|
||||
const Opposite<Derived>
|
||||
MatrixBase<Scalar, Derived>::operator-() const
|
||||
{
|
||||
return Opposite<Derived>(static_cast<const Derived*>(this)->ref());
|
||||
|
||||
@@ -58,42 +58,42 @@ template<typename MatrixType> class ScalarMultiple : NoDefaultOperatorEquals,
|
||||
const Scalar m_scalar;
|
||||
};
|
||||
|
||||
#define EIGEN_MAKE_SCALAR_OPS(OtherScalar) \
|
||||
#define EIGEN_MAKE_SCALAR_OPS(OtherScalar) \
|
||||
template<typename Scalar, typename Derived> \
|
||||
ScalarMultiple<Derived> \
|
||||
operator*(const MatrixBase<Scalar, Derived>& matrix, \
|
||||
const ScalarMultiple<Derived> \
|
||||
operator*(const MatrixBase<Scalar, Derived>& matrix, \
|
||||
OtherScalar scalar) \
|
||||
{ \
|
||||
return ScalarMultiple<Derived>(matrix.ref(), scalar); \
|
||||
return ScalarMultiple<Derived>(matrix.ref(), scalar); \
|
||||
} \
|
||||
\
|
||||
template<typename Scalar, typename Derived> \
|
||||
ScalarMultiple<Derived> \
|
||||
const ScalarMultiple<Derived> \
|
||||
operator*(OtherScalar scalar, \
|
||||
const MatrixBase<Scalar, Derived>& matrix) \
|
||||
const MatrixBase<Scalar, Derived>& matrix) \
|
||||
{ \
|
||||
return ScalarMultiple<Derived>(matrix.ref(), scalar); \
|
||||
return ScalarMultiple<Derived>(matrix.ref(), scalar); \
|
||||
} \
|
||||
\
|
||||
template<typename Scalar, typename Derived> \
|
||||
ScalarMultiple<Derived> \
|
||||
operator/(const MatrixBase<Scalar, Derived>& matrix, \
|
||||
const ScalarMultiple<Derived> \
|
||||
operator/(const MatrixBase<Scalar, Derived>& matrix, \
|
||||
OtherScalar scalar) \
|
||||
{ \
|
||||
assert(NumTraits<Scalar>::HasFloatingPoint); \
|
||||
assert(NumTraits<Scalar>::HasFloatingPoint); \
|
||||
return matrix * (static_cast<Scalar>(1) / scalar); \
|
||||
} \
|
||||
\
|
||||
template<typename Scalar, typename Derived> \
|
||||
Derived & \
|
||||
MatrixBase<Scalar, Derived>::operator*=(const OtherScalar &other) \
|
||||
MatrixBase<Scalar, Derived>::operator*=(const OtherScalar &other) \
|
||||
{ \
|
||||
return *this = *this * other; \
|
||||
} \
|
||||
\
|
||||
template<typename Scalar, typename Derived> \
|
||||
Derived & \
|
||||
MatrixBase<Scalar, Derived>::operator/=(const OtherScalar &other) \
|
||||
MatrixBase<Scalar, Derived>::operator/=(const OtherScalar &other) \
|
||||
{ \
|
||||
return *this = *this / other; \
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ template<typename Lhs, typename Rhs> class Sum : NoDefaultOperatorEquals,
|
||||
};
|
||||
|
||||
template<typename Scalar, typename Derived1, typename Derived2>
|
||||
Sum<Derived1, Derived2>
|
||||
const Sum<Derived1, Derived2>
|
||||
operator+(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived2> &mat2)
|
||||
{
|
||||
return Sum<Derived1, Derived2>(mat1.ref(), mat2.ref());
|
||||
|
||||
@@ -56,7 +56,7 @@ template<typename MatrixType> class Zero : NoDefaultOperatorEquals,
|
||||
};
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
Zero<Derived> MatrixBase<Scalar, Derived>::zero(int rows, int cols)
|
||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int rows, int cols)
|
||||
{
|
||||
return Zero<Derived>(rows, cols);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user