36 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_BLOCK_MATRIX_HPP
37 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_BLOCK_MATRIX_HPP
46 #include <boost/shared_ptr.hpp>
47 #include <boost/foreach.hpp>
51 template<
typename DataType,
typename InnerMatrixType>
52 class NekMatrix<NekMatrix<DataType, InnerMatrixType>, BlockMatrixTag> :
public ConstMatrix<typename NekMatrix<DataType, InnerMatrixType>::NumberType>
55 typedef NekMatrix<DataType, InnerMatrixType>
InnerType;
56 typedef NekMatrix<InnerType, BlockMatrixTag>
ThisType;
67 template<
typename MatrixType>
75 iterator_base(
MatrixType& m,
unsigned int curRow,
unsigned int curCol) :
84 m_curRow(std::numeric_limits<unsigned int>::max()),
85 m_curColumn(std::numeric_limits<unsigned int>::max())
89 iterator_base(
const iterator_base<MatrixType>& rhs) :
90 m_matrix(rhs.m_matrix),
91 m_curRow(rhs.m_curRow),
92 m_curColumn(rhs.m_curColumn)
98 if( m_curRow != std::numeric_limits<unsigned int>::max() )
100 boost::tie(m_curRow, m_curColumn) = StoragePolicy::Advance(
101 m_matrix.GetRows(), m_matrix.GetColumns(), m_curRow, m_curColumn);
107 return m_matrix(m_curRow, m_curColumn);
112 return m_curRow == rhs.m_curRow && m_curColumn == rhs.m_curColumn;
117 return !(*
this == rhs);
121 iterator_base<MatrixType>& operator=(
const iterator_base<MatrixType>& rhs);
136 LIB_UTILITIES_EXPORT NekMatrix(
unsigned int numberOfBlockRows,
unsigned int numberOfBlockColumns,
137 unsigned int rowsPerBlock,
unsigned int columnsPerBlock,
140 LIB_UTILITIES_EXPORT NekMatrix(
unsigned int numberOfBlockRows,
unsigned int numberOfBlockColumns,
141 const unsigned int* rowsPerBlock,
const unsigned int* columnsPerBlock,
144 LIB_UTILITIES_EXPORT NekMatrix(
unsigned int numberOfBlockRows,
unsigned int numberOfBlockColumns,
145 const Array<OneD, const unsigned int>& rowsPerBlock,
const Array<OneD, const unsigned int>& columnsPerBlock,
149 const Array<OneD, const unsigned int>& columnsPerBlock,
156 LIB_UTILITIES_EXPORT unsigned int CalculateBlockIndex(
unsigned int row,
unsigned int column)
const;
160 LIB_UTILITIES_EXPORT boost::shared_ptr<const InnerType> GetBlock(
unsigned int row,
unsigned int column)
const;
162 LIB_UTILITIES_EXPORT boost::shared_ptr<InnerType>& GetBlock(
unsigned int row,
unsigned int column);
164 LIB_UTILITIES_EXPORT void SetBlock(
unsigned int row,
unsigned int column, boost::shared_ptr<InnerType>& m);
188 LIB_UTILITIES_EXPORT static boost::shared_ptr<ThisType> CreateWrapper(
const boost::shared_ptr<ThisType>& rhs);
192 LIB_UTILITIES_EXPORT static unsigned int GetNumberOfElementsInBlock(
unsigned int block,
unsigned int totalBlocks,
const Array<OneD, unsigned int>& sizes);
194 LIB_UTILITIES_EXPORT void Initialize(
const unsigned int* rowsPerBlock,
const unsigned int* columnsPerBlock);
196 LIB_UTILITIES_EXPORT virtual typename boost::call_traits<NumberType>::value_type v_GetValue(
unsigned int row,
unsigned int column)
const;
204 Array<OneD, boost::shared_ptr<InnerType> >
m_data;
215 template<
typename DataType,
typename InnerMatrixType>
216 typename NekMatrix<NekMatrix<DataType, InnerMatrixType>, BlockMatrixTag>::NumberType
217 NekMatrix<NekMatrix<DataType, InnerMatrixType>, BlockMatrixTag>::m_zeroElement(0);
219 template<
typename InnerMatrixType>
220 NekMatrix<InnerMatrixType, BlockMatrixTag>
221 Transpose(NekMatrix<InnerMatrixType, BlockMatrixTag>& rhs)
223 NekMatrix<InnerMatrixType, BlockMatrixTag> result(rhs);
230 #endif //NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_BLOCK_MATRIX_HPP