mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-01 18:26:24 +08:00
some cleaning in DenseStorageBase
This commit is contained in:
parent
ebb2878829
commit
5ca90e1b0c
@ -25,42 +25,13 @@
|
||||
#ifndef EIGEN_ARRAY_H
|
||||
#define EIGEN_ARRAY_H
|
||||
|
||||
|
||||
|
||||
// template<typename MatrixType, typename OtherDerived, bool SwapPointers>
|
||||
// struct ei_matrix_swap_impl
|
||||
// {
|
||||
// static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
|
||||
// {
|
||||
// matrix.base().swap(other);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// template<typename MatrixType, typename OtherDerived>
|
||||
// struct ei_matrix_swap_impl<MatrixType, OtherDerived, true>
|
||||
// {
|
||||
// static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
|
||||
// {
|
||||
// matrix.m_storage.swap(other.derived().m_storage);
|
||||
// }
|
||||
// };
|
||||
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// template<typename OtherDerived>
|
||||
// inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
|
||||
// {
|
||||
// enum { SwapPointers = ei_is_same_type<Matrix, OtherDerived>::ret && Base::SizeAtCompileTime==Dynamic };
|
||||
// ei_matrix_swap_impl<Matrix, OtherDerived, bool(SwapPointers)>::run(*this, *const_cast<MatrixBase<OtherDerived>*>(&other));
|
||||
// }
|
||||
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
class Array
|
||||
: public DenseStorageBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, ArrayBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
|
||||
: public DenseStorageBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, ArrayBase, _Options>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef DenseStorageBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, ArrayBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> Base;
|
||||
typedef DenseStorageBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, ArrayBase, _Options> Base;
|
||||
_EIGEN_DENSE_PUBLIC_INTERFACE(Array)
|
||||
|
||||
enum { Options = _Options };
|
||||
|
@ -136,13 +136,13 @@ inline Derived& DenseBase<Derived>::setRandom()
|
||||
*
|
||||
* \sa MatrixBase::setRandom(), setRandom(int,int), class CwiseNullaryOp, MatrixBase::Random()
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int size)
|
||||
// {
|
||||
// resize(size);
|
||||
// return setRandom();
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setRandom(int size)
|
||||
{
|
||||
resize(size);
|
||||
return setRandom();
|
||||
}
|
||||
|
||||
/** Resizes to the given size, and sets all coefficients in this expression to random values.
|
||||
*
|
||||
@ -154,12 +154,12 @@ inline Derived& DenseBase<Derived>::setRandom()
|
||||
*
|
||||
* \sa MatrixBase::setRandom(), setRandom(int), class CwiseNullaryOp, MatrixBase::Random()
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int rows, int cols)
|
||||
// {
|
||||
// resize(rows, cols);
|
||||
// return setRandom();
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setRandom(int rows, int cols)
|
||||
{
|
||||
resize(rows, cols);
|
||||
return setRandom();
|
||||
}
|
||||
|
||||
#endif // EIGEN_RANDOM_H
|
||||
|
@ -278,13 +278,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& value
|
||||
*
|
||||
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int size, const Scalar& value)
|
||||
// {
|
||||
// resize(size);
|
||||
// return setConstant(value);
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setConstant(int size, const Scalar& value)
|
||||
{
|
||||
resize(size);
|
||||
return setConstant(value);
|
||||
}
|
||||
|
||||
/** Resizes to the given size, and sets all coefficients in this expression to the given \a value.
|
||||
*
|
||||
@ -296,13 +296,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& value
|
||||
*
|
||||
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int rows, int cols, const Scalar& value)
|
||||
// {
|
||||
// resize(rows, cols);
|
||||
// return setConstant(value);
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setConstant(int rows, int cols, const Scalar& value)
|
||||
{
|
||||
resize(rows, cols);
|
||||
return setConstant(value);
|
||||
}
|
||||
|
||||
|
||||
// zero:
|
||||
@ -408,13 +408,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero()
|
||||
*
|
||||
* \sa DenseBase::setZero(), setZero(int,int), class CwiseNullaryOp, DenseBase::Zero()
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int size)
|
||||
// {
|
||||
// resize(size);
|
||||
// return setConstant(Scalar(0));
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setZero(int size)
|
||||
{
|
||||
resize(size);
|
||||
return setConstant(Scalar(0));
|
||||
}
|
||||
|
||||
/** Resizes to the given size, and sets all coefficients in this expression to zero.
|
||||
*
|
||||
@ -426,13 +426,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero()
|
||||
*
|
||||
* \sa DenseBase::setZero(), setZero(int), class CwiseNullaryOp, DenseBase::Zero()
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int rows, int cols)
|
||||
// {
|
||||
// resize(rows, cols);
|
||||
// return setConstant(Scalar(0));
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setZero(int rows, int cols)
|
||||
{
|
||||
resize(rows, cols);
|
||||
return setConstant(Scalar(0));
|
||||
}
|
||||
|
||||
// ones:
|
||||
|
||||
@ -534,13 +534,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes()
|
||||
*
|
||||
* \sa MatrixBase::setOnes(), setOnes(int,int), class CwiseNullaryOp, MatrixBase::Ones()
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int size)
|
||||
// {
|
||||
// resize(size);
|
||||
// return setConstant(Scalar(1));
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setOnes(int size)
|
||||
{
|
||||
resize(size);
|
||||
return setConstant(Scalar(1));
|
||||
}
|
||||
|
||||
/** Resizes to the given size, and sets all coefficients in this expression to one.
|
||||
*
|
||||
@ -552,13 +552,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes()
|
||||
*
|
||||
* \sa MatrixBase::setOnes(), setOnes(int), class CwiseNullaryOp, MatrixBase::Ones()
|
||||
*/
|
||||
// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
|
||||
// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int rows, int cols)
|
||||
// {
|
||||
// resize(rows, cols);
|
||||
// return setConstant(Scalar(1));
|
||||
// }
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
EIGEN_STRONG_INLINE Derived&
|
||||
DenseStorageBase<Derived,_Base,_Options>::setOnes(int rows, int cols)
|
||||
{
|
||||
resize(rows, cols);
|
||||
return setConstant(Scalar(1));
|
||||
}
|
||||
|
||||
// Identity:
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
template <typename Derived, typename OtherDerived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct ei_conservative_resize_like_impl;
|
||||
template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct ei_matrix_swap_impl;
|
||||
|
||||
template<typename Derived, template<typename> class _Base, typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
template<typename Derived, template<typename> class _Base, int _Options>
|
||||
class DenseStorageBase : public _Base<Derived>
|
||||
{
|
||||
public:
|
||||
@ -402,60 +402,20 @@ class DenseStorageBase : public _Base<Derived>
|
||||
//@}
|
||||
|
||||
using Base::setConstant;
|
||||
/** Resizes to the given \a size, and sets all coefficients in this expression to the given \a value.
|
||||
*
|
||||
* \only_for_vectors
|
||||
*
|
||||
* Example: \include Matrix_setConstant_int.cpp
|
||||
* Output: \verbinclude Matrix_setConstant_int.out
|
||||
*
|
||||
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
|
||||
*/
|
||||
Derived& setConstant(int size, const Scalar& value)
|
||||
{
|
||||
resize(size);
|
||||
return setConstant(value);
|
||||
}
|
||||
|
||||
/** Resizes to the given size, and sets all coefficients in this expression to the given \a value.
|
||||
*
|
||||
* \param rows the new number of rows
|
||||
* \param cols the new number of columns
|
||||
*
|
||||
* Example: \include Matrix_setConstant_int_int.cpp
|
||||
* Output: \verbinclude Matrix_setConstant_int_int.out
|
||||
*
|
||||
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
|
||||
*/
|
||||
Derived& setConstant(int rows, int cols, const Scalar& value)
|
||||
{
|
||||
resize(rows, cols);
|
||||
return setConstant(value);
|
||||
}
|
||||
Derived& setConstant(int size, const Scalar& value);
|
||||
Derived& setConstant(int rows, int cols, const Scalar& value);
|
||||
|
||||
using Base::setZero;
|
||||
Derived& setZero(int size)
|
||||
{ return setConstant(size, Scalar(0)); }
|
||||
Derived& setZero(int rows, int cols)
|
||||
{ return setConstant(rows, cols, Scalar(0)); }
|
||||
Derived& setZero(int size);
|
||||
Derived& setZero(int rows, int cols);
|
||||
|
||||
using Base::setOnes;
|
||||
Derived& setOnes(int size)
|
||||
{ return setConstant(size, Scalar(1)); }
|
||||
Derived& setOnes(int rows, int cols)
|
||||
{ return setConstant(rows, cols, Scalar(1)); }
|
||||
Derived& setOnes(int size);
|
||||
Derived& setOnes(int rows, int cols);
|
||||
|
||||
using Base::setRandom;
|
||||
Derived& setRandom(int size)
|
||||
{
|
||||
resize(size);
|
||||
return setRandom();
|
||||
}
|
||||
Derived& setRandom(int rows, int cols)
|
||||
{
|
||||
resize(rows, cols);
|
||||
return setRandom();
|
||||
}
|
||||
Derived& setRandom(int size);
|
||||
Derived& setRandom(int rows, int cols);
|
||||
|
||||
#ifdef EIGEN_DENSESTORAGEBASE_PLUGIN
|
||||
#include EIGEN_DENSESTORAGEBASE_PLUGIN
|
||||
@ -524,15 +484,15 @@ class DenseStorageBase : public _Base<Derived>
|
||||
EIGEN_DEBUG_MATRIX_CTOR;
|
||||
#endif
|
||||
|
||||
EIGEN_STATIC_ASSERT(((_Rows >= _MaxRows)
|
||||
&& (_Cols >= _MaxCols)
|
||||
&& (_MaxRows >= 0)
|
||||
&& (_MaxCols >= 0)
|
||||
&& (_Rows <= Dynamic)
|
||||
&& (_Cols <= Dynamic)
|
||||
&& (_MaxRows == _Rows || _Rows==Dynamic)
|
||||
&& (_MaxCols == _Cols || _Cols==Dynamic)
|
||||
&& ((_MaxRows==Dynamic?1:_MaxRows)*(_MaxCols==Dynamic?1:_MaxCols)<Dynamic)
|
||||
EIGEN_STATIC_ASSERT(((RowsAtCompileTime >= MaxRowsAtCompileTime)
|
||||
&& (ColsAtCompileTime >= MaxColsAtCompileTime)
|
||||
&& (MaxRowsAtCompileTime >= 0)
|
||||
&& (MaxColsAtCompileTime >= 0)
|
||||
&& (RowsAtCompileTime <= Dynamic)
|
||||
&& (ColsAtCompileTime <= Dynamic)
|
||||
&& (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic)
|
||||
&& (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic)
|
||||
&& ((MaxRowsAtCompileTime==Dynamic?1:MaxRowsAtCompileTime)*(MaxColsAtCompileTime==Dynamic?1:MaxColsAtCompileTime)<Dynamic)
|
||||
&& (_Options & (DontAlign|RowMajor)) == _Options),
|
||||
INVALID_MATRIX_TEMPLATE_PARAMETERS)
|
||||
}
|
||||
|
@ -124,12 +124,11 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||
class Matrix
|
||||
: public DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
|
||||
// : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
|
||||
: public DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Options>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> Base;
|
||||
typedef DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Options> Base;
|
||||
_EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
|
||||
|
||||
enum { Options = _Options };
|
||||
|
Loading…
Reference in New Issue
Block a user