mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-24 02:29:33 +08:00
Fix compilation of Block/SparseBlock with MSVC
This commit is contained in:
parent
23ce05971b
commit
6c8cf15c06
@ -191,7 +191,8 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H
|
|||||||
/** Fixed-size constructor
|
/** Fixed-size constructor
|
||||||
*/
|
*/
|
||||||
inline BlockImpl_dense(XprType& xpr, Index a_startRow, Index a_startCol)
|
inline BlockImpl_dense(XprType& xpr, Index a_startRow, Index a_startCol)
|
||||||
: m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol)
|
: m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol),
|
||||||
|
m_blockRows(BlockRows), m_blockCols(BlockCols)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/** Dynamic-size constructor
|
/** Dynamic-size constructor
|
||||||
@ -200,8 +201,8 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H
|
|||||||
Index a_startRow, Index a_startCol,
|
Index a_startRow, Index a_startCol,
|
||||||
Index blockRows, Index blockCols)
|
Index blockRows, Index blockCols)
|
||||||
: m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol),
|
: m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol),
|
||||||
m_blockRows(blockRows), m_blockCols(blockCols)
|
m_blockRows(blockRows), m_blockCols(blockCols)
|
||||||
{ }
|
{}
|
||||||
|
|
||||||
inline Index rows() const { return m_blockRows.value(); }
|
inline Index rows() const { return m_blockRows.value(); }
|
||||||
inline Index cols() const { return m_blockCols.value(); }
|
inline Index cols() const { return m_blockCols.value(); }
|
||||||
|
@ -75,9 +75,9 @@ template<typename _Scalar, int _Options, typename _Index, int BlockRows, int Blo
|
|||||||
class BlockImpl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true,Sparse>
|
class BlockImpl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true,Sparse>
|
||||||
: public SparseMatrixBase<Block<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true> >
|
: public SparseMatrixBase<Block<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true> >
|
||||||
{
|
{
|
||||||
typedef SparseMatrix<_Scalar, _Options, _Index> XprType;
|
typedef SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;
|
||||||
typedef typename internal::remove_all<typename XprType::Nested>::type _MatrixTypeNested;
|
typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _MatrixTypeNested;
|
||||||
typedef Block<XprType, BlockRows, BlockCols, true> BlockType;
|
typedef Block<SparseMatrixType, BlockRows, BlockCols, true> BlockType;
|
||||||
public:
|
public:
|
||||||
enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };
|
enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };
|
||||||
EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)
|
EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)
|
||||||
@ -85,22 +85,22 @@ protected:
|
|||||||
enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };
|
enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class InnerIterator: public XprType::InnerIterator
|
class InnerIterator: public SparseMatrixType::InnerIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline InnerIterator(const BlockType& xpr, Index outer)
|
inline InnerIterator(const BlockType& xpr, Index outer)
|
||||||
: XprType::InnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
|
: SparseMatrixType::InnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
|
||||||
{}
|
{}
|
||||||
inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
|
inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
|
||||||
inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
|
inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
|
||||||
protected:
|
protected:
|
||||||
Index m_outer;
|
Index m_outer;
|
||||||
};
|
};
|
||||||
class ReverseInnerIterator: public XprType::ReverseInnerIterator
|
class ReverseInnerIterator: public SparseMatrixType::ReverseInnerIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline ReverseInnerIterator(const BlockType& xpr, Index outer)
|
inline ReverseInnerIterator(const BlockType& xpr, Index outer)
|
||||||
: XprType::ReverseInnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
|
: SparseMatrixType::ReverseInnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
|
||||||
{}
|
{}
|
||||||
inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
|
inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
|
||||||
inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
|
inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
|
||||||
@ -108,18 +108,18 @@ public:
|
|||||||
Index m_outer;
|
Index m_outer;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline BlockImpl(const XprType& xpr, int i)
|
inline BlockImpl(const SparseMatrixType& xpr, int i)
|
||||||
: m_matrix(xpr), m_outerStart(i), m_outerSize(OuterSize)
|
: m_matrix(xpr), m_outerStart(i), m_outerSize(OuterSize)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline BlockImpl(const XprType& xpr, int startRow, int startCol, int blockRows, int blockCols)
|
inline BlockImpl(const SparseMatrixType& xpr, int startRow, int startCol, int blockRows, int blockCols)
|
||||||
: m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
|
: m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
inline BlockType& operator=(const SparseMatrixBase<OtherDerived>& other)
|
inline BlockType& operator=(const SparseMatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
typedef typename internal::remove_all<typename XprType::Nested>::type _NestedMatrixType;
|
typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _NestedMatrixType;
|
||||||
_NestedMatrixType& matrix = const_cast<_NestedMatrixType&>(m_matrix);;
|
_NestedMatrixType& matrix = const_cast<_NestedMatrixType&>(m_matrix);;
|
||||||
// This assignement is slow if this vector set is not empty
|
// This assignement is slow if this vector set is not empty
|
||||||
// and/or it is not at the end of the nonzeros of the underlying matrix.
|
// and/or it is not at the end of the nonzeros of the underlying matrix.
|
||||||
@ -138,7 +138,7 @@ public:
|
|||||||
if(nnz>free_size)
|
if(nnz>free_size)
|
||||||
{
|
{
|
||||||
// realloc manually to reduce copies
|
// realloc manually to reduce copies
|
||||||
typename XprType::Storage newdata(m_matrix.nonZeros() - nnz_previous + nnz);
|
typename SparseMatrixType::Storage newdata(m_matrix.nonZeros() - nnz_previous + nnz);
|
||||||
|
|
||||||
std::memcpy(&newdata.value(0), &m_matrix.data().value(0), nnz_head*sizeof(Scalar));
|
std::memcpy(&newdata.value(0), &m_matrix.data().value(0), nnz_head*sizeof(Scalar));
|
||||||
std::memcpy(&newdata.index(0), &m_matrix.data().index(0), nnz_head*sizeof(Index));
|
std::memcpy(&newdata.index(0), &m_matrix.data().index(0), nnz_head*sizeof(Index));
|
||||||
@ -236,7 +236,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typename XprType::Nested m_matrix;
|
typename SparseMatrixType::Nested m_matrix;
|
||||||
Index m_outerStart;
|
Index m_outerStart;
|
||||||
const internal::variable_if_dynamic<Index, OuterSize> m_outerSize;
|
const internal::variable_if_dynamic<Index, OuterSize> m_outerSize;
|
||||||
|
|
||||||
@ -282,8 +282,6 @@ const Block<const Derived,Dynamic,Dynamic,true> SparseMatrixBase<Derived>::inner
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
/** Generic implementation of sparse Block expression.
|
/** Generic implementation of sparse Block expression.
|
||||||
* Real-only.
|
* Real-only.
|
||||||
*/
|
*/
|
||||||
@ -401,8 +399,6 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_SPARSE_BLOCK_H
|
#endif // EIGEN_SPARSE_BLOCK_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user