File indexing completed on 2025-01-18 09:57:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_SPARSE_BLOCKFORDYNAMICMATRIX_H
0011 #define EIGEN_SPARSE_BLOCKFORDYNAMICMATRIX_H
0012
0013 namespace Eigen {
0014
0015 #if 0
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 template<typename _Scalar, int _Options, typename _Index, int Size>
0026 class SparseInnerVectorSet<DynamicSparseMatrix<_Scalar, _Options, _Index>, Size>
0027 : public SparseMatrixBase<SparseInnerVectorSet<DynamicSparseMatrix<_Scalar, _Options, _Index>, Size> >
0028 {
0029 typedef DynamicSparseMatrix<_Scalar, _Options, _Index> MatrixType;
0030 public:
0031
0032 enum { IsRowMajor = internal::traits<SparseInnerVectorSet>::IsRowMajor };
0033
0034 EIGEN_SPARSE_PUBLIC_INTERFACE(SparseInnerVectorSet)
0035 class InnerIterator: public MatrixType::InnerIterator
0036 {
0037 public:
0038 inline InnerIterator(const SparseInnerVectorSet& xpr, Index outer)
0039 : MatrixType::InnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
0040 {}
0041 inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
0042 inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
0043 protected:
0044 Index m_outer;
0045 };
0046
0047 inline SparseInnerVectorSet(const MatrixType& matrix, Index outerStart, Index outerSize)
0048 : m_matrix(matrix), m_outerStart(outerStart), m_outerSize(outerSize)
0049 {
0050 eigen_assert( (outerStart>=0) && ((outerStart+outerSize)<=matrix.outerSize()) );
0051 }
0052
0053 inline SparseInnerVectorSet(const MatrixType& matrix, Index outer)
0054 : m_matrix(matrix), m_outerStart(outer), m_outerSize(Size)
0055 {
0056 eigen_assert(Size!=Dynamic);
0057 eigen_assert( (outer>=0) && (outer<matrix.outerSize()) );
0058 }
0059
0060 template<typename OtherDerived>
0061 inline SparseInnerVectorSet& operator=(const SparseMatrixBase<OtherDerived>& other)
0062 {
0063 if (IsRowMajor != ((OtherDerived::Flags&RowMajorBit)==RowMajorBit))
0064 {
0065
0066 DynamicSparseMatrix<Scalar,IsRowMajor?RowMajorBit:0> aux(other);
0067 *this = aux.markAsRValue();
0068 }
0069 else
0070 {
0071
0072 for (Index j=0; j<m_outerSize.value(); ++j)
0073 {
0074 SparseVector<Scalar,IsRowMajor ? RowMajorBit : 0> aux(other.innerVector(j));
0075 m_matrix.const_cast_derived()._data()[m_outerStart+j].swap(aux._data());
0076 }
0077 }
0078 return *this;
0079 }
0080
0081 inline SparseInnerVectorSet& operator=(const SparseInnerVectorSet& other)
0082 {
0083 return operator=<SparseInnerVectorSet>(other);
0084 }
0085
0086 Index nonZeros() const
0087 {
0088 Index count = 0;
0089 for (Index j=0; j<m_outerSize.value(); ++j)
0090 count += m_matrix._data()[m_outerStart+j].size();
0091 return count;
0092 }
0093
0094 const Scalar& lastCoeff() const
0095 {
0096 EIGEN_STATIC_ASSERT_VECTOR_ONLY(SparseInnerVectorSet);
0097 eigen_assert(m_matrix.data()[m_outerStart].size()>0);
0098 return m_matrix.data()[m_outerStart].vale(m_matrix.data()[m_outerStart].size()-1);
0099 }
0100
0101
0102
0103
0104
0105
0106
0107 EIGEN_STRONG_INLINE Index rows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }
0108 EIGEN_STRONG_INLINE Index cols() const { return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }
0109
0110 protected:
0111
0112 const typename MatrixType::Nested m_matrix;
0113 Index m_outerStart;
0114 const internal::variable_if_dynamic<Index, Size> m_outerSize;
0115
0116 };
0117
0118 #endif
0119
0120 }
0121
0122 #endif