MOAB  4.9.3pre
Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols > Class Template Reference

#include <SparseBlock.h>

Inheritance diagram for Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >:
Collaboration diagram for Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >:

List of all members.

Public Types

enum  { IsRowMajor = internal::traits<BlockType>::IsRowMajor }

Public Member Functions

 sparse_matrix_block_impl (SparseMatrixType &xpr, Index i)
 sparse_matrix_block_impl (SparseMatrixType &xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
template<typename OtherDerived >
BlockTypeoperator= (const SparseMatrixBase< OtherDerived > &other)
BlockTypeoperator= (const BlockType &other)
const ScalarvaluePtr () const
ScalarvaluePtr ()
const StorageIndexinnerIndexPtr () const
StorageIndexinnerIndexPtr ()
const StorageIndexouterIndexPtr () const
StorageIndexouterIndexPtr ()
const StorageIndexinnerNonZeroPtr () const
StorageIndexinnerNonZeroPtr ()
bool isCompressed () const
ScalarcoeffRef (Index row, Index col)
const Scalar coeff (Index row, Index col) const
const Scalar coeff (Index index) const
const ScalarlastCoeff () const
EIGEN_STRONG_INLINE Index rows () const
EIGEN_STRONG_INLINE Index cols () const
const SparseMatrixType & nestedExpression () const
SparseMatrixType & nestedExpression ()
Index startRow () const
Index startCol () const
Index blockRows () const
Index blockCols () const

Protected Types

enum  { OuterSize = IsRowMajor ? BlockRows : BlockCols }
typedef Base::IndexVector IndexVector

Protected Attributes

internal::ref_selector
< SparseMatrixType >
::non_const_type 
m_matrix
Index m_outerStart
const
internal::variable_if_dynamic
< Index, OuterSize
m_outerSize

Private Types

typedef internal::remove_all
< typename
SparseMatrixType::Nested >
::type 
_MatrixTypeNested
typedef Block
< SparseMatrixType, BlockRows,
BlockCols, true > 
BlockType
typedef SparseCompressedBase
< Block< SparseMatrixType,
BlockRows, BlockCols, true > > 
Base

Detailed Description

template<typename SparseMatrixType, int BlockRows, int BlockCols>
class Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >

Definition at line 96 of file SparseBlock.h.


Member Typedef Documentation

template<typename SparseMatrixType, int BlockRows, int BlockCols>
typedef internal::remove_all<typename SparseMatrixType::Nested>::type Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::_MatrixTypeNested [private]

Definition at line 99 of file SparseBlock.h.

template<typename SparseMatrixType, int BlockRows, int BlockCols>
typedef Block<SparseMatrixType, BlockRows, BlockCols, true> Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::BlockType [private]

Definition at line 100 of file SparseBlock.h.

template<typename SparseMatrixType, int BlockRows, int BlockCols>
typedef Base::IndexVector Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::IndexVector [protected]

Member Enumeration Documentation

template<typename SparseMatrixType, int BlockRows, int BlockCols>
anonymous enum
Enumerator:
IsRowMajor 

Definition at line 104 of file SparseBlock.h.

{ IsRowMajor = internal::traits<BlockType>::IsRowMajor };
template<typename SparseMatrixType, int BlockRows, int BlockCols>
anonymous enum [protected]
Enumerator:
OuterSize 

Definition at line 108 of file SparseBlock.h.

{ OuterSize = IsRowMajor ? BlockRows : BlockCols };

Constructor & Destructor Documentation

template<typename SparseMatrixType, int BlockRows, int BlockCols>
Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::sparse_matrix_block_impl ( SparseMatrixType &  xpr,
Index  i 
) [inline]

Definition at line 111 of file SparseBlock.h.

template<typename SparseMatrixType, int BlockRows, int BlockCols>
Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::sparse_matrix_block_impl ( SparseMatrixType &  xpr,
Index  startRow,
Index  startCol,
Index  blockRows,
Index  blockCols 
) [inline]

Member Function Documentation

template<typename SparseMatrixType, int BlockRows, int BlockCols>
Index Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::blockCols ( ) const [inline]

Definition at line 272 of file SparseBlock.h.

{ return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
Index Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::blockRows ( ) const [inline]

Definition at line 271 of file SparseBlock.h.

{ return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const Scalar Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::coeff ( Index  row,
Index  col 
) const [inline]

Definition at line 244 of file SparseBlock.h.

    {
      return m_matrix.coeff(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 :  m_outerStart));
    }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const Scalar Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::coeff ( Index  index) const [inline]

Definition at line 249 of file SparseBlock.h.

    {
      return m_matrix.coeff(IsRowMajor ? m_outerStart : index, IsRowMajor ? index :  m_outerStart);
    }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
Scalar& Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::coeffRef ( Index  row,
Index  col 
) [inline]

Definition at line 239 of file SparseBlock.h.

    {
      return m_matrix.coeffRef(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 :  m_outerStart));
    }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
EIGEN_STRONG_INLINE Index Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::cols ( void  ) const [inline]
Returns:
the number of columns.
See also:
rows()

Reimplemented from Eigen::SparseMatrixBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 265 of file SparseBlock.h.

{ return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const StorageIndex* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::innerIndexPtr ( ) const [inline]
Returns:
a const pointer to the array of inner indices. This function is aimed at interoperability with other libraries.
See also:
valuePtr(), outerIndexPtr()

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 222 of file SparseBlock.h.

    { return m_matrix.innerIndexPtr(); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
StorageIndex* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::innerIndexPtr ( ) [inline]
Returns:
a non-const pointer to the array of inner indices. This function is aimed at interoperability with other libraries.
See also:
valuePtr(), outerIndexPtr()

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 224 of file SparseBlock.h.

    { return m_matrix.innerIndexPtr(); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const StorageIndex* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::innerNonZeroPtr ( ) const [inline]
Returns:
a const pointer to the array of the number of non zeros of the inner vectors. This function is aimed at interoperability with other libraries.
Warning:
it returns the null pointer 0 in compressed mode

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 232 of file SparseBlock.h.

    { return isCompressed() ? 0 : (m_matrix.innerNonZeroPtr()+m_outerStart); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
StorageIndex* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::innerNonZeroPtr ( ) [inline]
Returns:
a non-const pointer to the array of the number of non zeros of the inner vectors. This function is aimed at interoperability with other libraries.
Warning:
it returns the null pointer 0 in compressed mode

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 234 of file SparseBlock.h.

    { return isCompressed() ? 0 : (m_matrix.innerNonZeroPtr()+m_outerStart); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
bool Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::isCompressed ( ) const [inline]
Returns:
whether *this is in compressed form.

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 237 of file SparseBlock.h.

{ return m_matrix.innerNonZeroPtr()==0; }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const Scalar& Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::lastCoeff ( ) const [inline]

Definition at line 254 of file SparseBlock.h.

    {
      EIGEN_STATIC_ASSERT_VECTOR_ONLY(sparse_matrix_block_impl);
      eigen_assert(Base::nonZeros()>0);
      if(m_matrix.isCompressed())
        return m_matrix.valuePtr()[m_matrix.outerIndexPtr()[m_outerStart+1]-1];
      else
        return m_matrix.valuePtr()[m_matrix.outerIndexPtr()[m_outerStart]+m_matrix.innerNonZeroPtr()[m_outerStart]-1];
    }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const SparseMatrixType& Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::nestedExpression ( ) const [inline]

Definition at line 267 of file SparseBlock.h.

{ return m_matrix; }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
SparseMatrixType& Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::nestedExpression ( ) [inline]

Definition at line 268 of file SparseBlock.h.

{ return m_matrix; }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
template<typename OtherDerived >
BlockType& Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::operator= ( const SparseMatrixBase< OtherDerived > &  other) [inline]

Reimplemented from Eigen::SparseMatrixBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 120 of file SparseBlock.h.

    {
      typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _NestedMatrixType;
      _NestedMatrixType& matrix = m_matrix;
      // This assignment is slow if this vector set is not empty
      // and/or it is not at the end of the nonzeros of the underlying matrix.

      // 1 - eval to a temporary to avoid transposition and/or aliasing issues
      Ref<const SparseMatrix<Scalar, IsRowMajor ? RowMajor : ColMajor, StorageIndex> > tmp(other.derived());
      eigen_internal_assert(tmp.outerSize()==m_outerSize.value());

      // 2 - let's check whether there is enough allocated memory
      Index nnz           = tmp.nonZeros();
      Index start         = m_outerStart==0 ? 0 : matrix.outerIndexPtr()[m_outerStart]; // starting position of the current block
      Index end           = m_matrix.outerIndexPtr()[m_outerStart+m_outerSize.value()]; // ending position of the current block
      Index block_size    = end - start;                                                // available room in the current block
      Index tail_size     = m_matrix.outerIndexPtr()[m_matrix.outerSize()] - end;
      
      Index free_size     = m_matrix.isCompressed()
                          ? Index(matrix.data().allocatedSize()) + block_size
                          : block_size;

      bool update_trailing_pointers = false;
      if(nnz>free_size) 
      {
        // realloc manually to reduce copies
        typename SparseMatrixType::Storage newdata(m_matrix.data().allocatedSize() - block_size + nnz);

        internal::smart_copy(m_matrix.valuePtr(),       m_matrix.valuePtr() + start,      newdata.valuePtr());
        internal::smart_copy(m_matrix.innerIndexPtr(),  m_matrix.innerIndexPtr() + start, newdata.indexPtr());

        internal::smart_copy(tmp.valuePtr(),      tmp.valuePtr() + nnz,       newdata.valuePtr() + start);
        internal::smart_copy(tmp.innerIndexPtr(), tmp.innerIndexPtr() + nnz,  newdata.indexPtr() + start);

        internal::smart_copy(matrix.valuePtr()+end,       matrix.valuePtr()+end + tail_size,      newdata.valuePtr()+start+nnz);
        internal::smart_copy(matrix.innerIndexPtr()+end,  matrix.innerIndexPtr()+end + tail_size, newdata.indexPtr()+start+nnz);
        
        newdata.resize(m_matrix.outerIndexPtr()[m_matrix.outerSize()] - block_size + nnz);

        matrix.data().swap(newdata);

        update_trailing_pointers = true;
      }
      else
      {
        if(m_matrix.isCompressed())
        {
          // no need to realloc, simply copy the tail at its respective position and insert tmp
          matrix.data().resize(start + nnz + tail_size);

          internal::smart_memmove(matrix.valuePtr()+end,      matrix.valuePtr() + end+tail_size,      matrix.valuePtr() + start+nnz);
          internal::smart_memmove(matrix.innerIndexPtr()+end, matrix.innerIndexPtr() + end+tail_size, matrix.innerIndexPtr() + start+nnz);

          update_trailing_pointers = true;
        }

        internal::smart_copy(tmp.valuePtr(),      tmp.valuePtr() + nnz,       matrix.valuePtr() + start);
        internal::smart_copy(tmp.innerIndexPtr(), tmp.innerIndexPtr() + nnz,  matrix.innerIndexPtr() + start);
      }

      // update outer index pointers and innerNonZeros
      if(IsVectorAtCompileTime)
      {
        if(!m_matrix.isCompressed())
          matrix.innerNonZeroPtr()[m_outerStart] = StorageIndex(nnz);
        matrix.outerIndexPtr()[m_outerStart] = StorageIndex(start);
      }
      else
      {
        StorageIndex p = StorageIndex(start);
        for(Index k=0; k<m_outerSize.value(); ++k)
        {
          Index nnz_k = tmp.innerVector(k).nonZeros();
          if(!m_matrix.isCompressed())
            matrix.innerNonZeroPtr()[m_outerStart+k] = StorageIndex(nnz_k);
          matrix.outerIndexPtr()[m_outerStart+k] = p;
          p += nnz_k;
        }
      }

      if(update_trailing_pointers)
      {
        StorageIndex offset = internal::convert_index<StorageIndex>(nnz - block_size);
        for(Index k = m_outerStart + m_outerSize.value(); k<=matrix.outerSize(); ++k)
        {
          matrix.outerIndexPtr()[k] += offset;
        }
      }

      return derived();
    }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
BlockType& Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::operator= ( const BlockType other) [inline]

Definition at line 212 of file SparseBlock.h.

    {
      return operator=<BlockType>(other);
    }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const StorageIndex* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::outerIndexPtr ( ) const [inline]
Returns:
a const pointer to the array of the starting positions of the inner vectors. This function is aimed at interoperability with other libraries.
Warning:
it returns the null pointer 0 for SparseVector
See also:
valuePtr(), innerIndexPtr()

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 227 of file SparseBlock.h.

    { return m_matrix.outerIndexPtr() + m_outerStart; }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
StorageIndex* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::outerIndexPtr ( ) [inline]
Returns:
a non-const pointer to the array of the starting positions of the inner vectors. This function is aimed at interoperability with other libraries.
Warning:
it returns the null pointer 0 for SparseVector
See also:
valuePtr(), innerIndexPtr()

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 229 of file SparseBlock.h.

    { return m_matrix.outerIndexPtr() + m_outerStart; }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
EIGEN_STRONG_INLINE Index Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::rows ( void  ) const [inline]
Returns:
the number of rows.
See also:
cols()

Reimplemented from Eigen::SparseMatrixBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 264 of file SparseBlock.h.

{ return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
Index Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::startCol ( ) const [inline]

Definition at line 270 of file SparseBlock.h.

{ return IsRowMajor ? 0 : m_outerStart; }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
Index Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::startRow ( ) const [inline]

Definition at line 269 of file SparseBlock.h.

{ return IsRowMajor ? m_outerStart : 0; }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
const Scalar* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::valuePtr ( ) const [inline]
Returns:
a const pointer to the array of values. This function is aimed at interoperability with other libraries.
See also:
innerIndexPtr(), outerIndexPtr()

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 217 of file SparseBlock.h.

    { return m_matrix.valuePtr(); }
template<typename SparseMatrixType, int BlockRows, int BlockCols>
Scalar* Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::valuePtr ( ) [inline]
Returns:
a non-const pointer to the array of values. This function is aimed at interoperability with other libraries.
See also:
innerIndexPtr(), outerIndexPtr()

Reimplemented from Eigen::SparseCompressedBase< Block< SparseMatrixType, BlockRows, BlockCols, true > >.

Definition at line 219 of file SparseBlock.h.

    { return m_matrix.valuePtr(); }

Member Data Documentation

template<typename SparseMatrixType, int BlockRows, int BlockCols>
internal::ref_selector<SparseMatrixType>::non_const_type Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::m_matrix [protected]

Definition at line 276 of file SparseBlock.h.

template<typename SparseMatrixType, int BlockRows, int BlockCols>
const internal::variable_if_dynamic<Index, OuterSize> Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::m_outerSize [protected]

Definition at line 278 of file SparseBlock.h.

template<typename SparseMatrixType, int BlockRows, int BlockCols>
Index Eigen::internal::sparse_matrix_block_impl< SparseMatrixType, BlockRows, BlockCols >::m_outerStart [protected]

Definition at line 277 of file SparseBlock.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines