Nektar++
Public Types | Public Member Functions | Protected Attributes | List of all members
Nektar::NekSparseDiagBlkMatrix< SparseStorageType > Class Template Reference

#include <SparseDiagBlkMatrix.hpp>

Public Types

typedef SparseStorageType StorageType
 
typedef SparseStorageType::DataType DataType
 
typedef std::shared_ptr< SparseStorageType > SparseStorageSharedPtr
 
typedef Array< OneD, DataTypeDataVectorType
 
typedef Array< OneD, const DataTypeConstDataVectorType
 
typedef Array< OneD, SparseStorageSharedPtrSparseStorageSharedPtrVector
 

Public Member Functions

 NekSparseDiagBlkMatrix (const SparseStorageSharedPtrVector &sparseStoragePtrVector)
 
 NekSparseDiagBlkMatrix (const NekSparseDiagBlkMatrix &src)
 
 ~NekSparseDiagBlkMatrix ()
 
IndexType GetRows () const
 
IndexType GetColumns () const
 
IndexType GetNumNonZeroEntries ()
 
DataType GetFillInRatio () const
 
IndexType GetRows (int i) const
 number of rows at i-th submatrix More...
 
IndexType GetColumns (int i) const
 number of columns at i-th submatrix More...
 
IndexType GetNumberOfMatrixBlocks () const
 
IndexType GetNumNonZeroEntries (int i) const
 
DataType GetFillInRatio (int i) const
 
boost::call_traits< DataType >::const_reference operator() (const IndexType row, const IndexType column) const
 
boost::call_traits< DataType >::const_reference operator() (const IndexType block, const IndexType row, const IndexType column) const
 
void Multiply (const DataVectorType &in, DataVectorType &out)
 
void Multiply (const DataType *in, DataType *out)
 
void MultiplySubMatrix (const IndexType blockNum, DataType *in, DataType *out)
 
size_t GetMemoryFootprint ()
 
size_t GetMemoryFootprint (IndexType i) const
 
unsigned long GetMulCallsCounter () const
 
DataType GetAvgRowDensity ()
 
DataType GetAvgRowDensity (IndexType i) const
 
IndexType GetBandwidth ()
 
IndexType GetBandwidth (IndexType i)
 
COOMatTypeSharedPtr GetCooStorage ()
 
COOMatTypeSharedPtr GetCooStorage (IndexType i)
 
void writeSparsityPatternTo (std::ostream &out, IndexType blockSize=64)
 
void writeSubmatrixSparsityPatternTo (std::ostream &out, const IndexType subMatrixIdx, IndexType blockSize=64)
 
void writeBlockSparsityPatternTo (std::ostream &out, const IndexType blk_row=0, const IndexType blk_col=0, IndexType blockSize=64)
 
void writeSubmatrixBlockSparsityPatternTo (std::ostream &out, const IndexType subMatrixIdx, const IndexType blk_row=0, const IndexType blk_col=0, IndexType blockSize=64)
 Complementary routine to the previous. It generates exact non-zero pattern of a given block matrix entry to *this object. E.g., for a 6x6 matrix defined as A(i,i):=i, A(i,j):=0, block size = 2 and blk_row=blk_col=2 it produces 2x2 matrix with 5 and 6 along the diagonal. More...
 

Protected Attributes

IndexType m_rows
 
IndexType m_cols
 
IndexVector m_rowoffset
 
unsigned long m_mulCallsCounter
 
SparseStorageSharedPtrVector m_submatrix
 

Detailed Description

template<typename SparseStorageType>
class Nektar::NekSparseDiagBlkMatrix< SparseStorageType >

Definition at line 61 of file SparseDiagBlkMatrix.hpp.

Member Typedef Documentation

◆ ConstDataVectorType

template<typename SparseStorageType>
typedef Array<OneD, const DataType> Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::ConstDataVectorType

Definition at line 69 of file SparseDiagBlkMatrix.hpp.

◆ DataType

template<typename SparseStorageType>
typedef SparseStorageType::DataType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::DataType

Definition at line 66 of file SparseDiagBlkMatrix.hpp.

◆ DataVectorType

template<typename SparseStorageType>
typedef Array<OneD, DataType> Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::DataVectorType

Definition at line 68 of file SparseDiagBlkMatrix.hpp.

◆ SparseStorageSharedPtr

template<typename SparseStorageType>
typedef std::shared_ptr<SparseStorageType> Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::SparseStorageSharedPtr

Definition at line 67 of file SparseDiagBlkMatrix.hpp.

◆ SparseStorageSharedPtrVector

template<typename SparseStorageType>
typedef Array<OneD, SparseStorageSharedPtr> Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::SparseStorageSharedPtrVector

Definition at line 70 of file SparseDiagBlkMatrix.hpp.

◆ StorageType

template<typename SparseStorageType>
typedef SparseStorageType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::StorageType

Definition at line 65 of file SparseDiagBlkMatrix.hpp.

Constructor & Destructor Documentation

◆ NekSparseDiagBlkMatrix() [1/2]

template<typename SparseStorageType >
Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::NekSparseDiagBlkMatrix ( const SparseStorageSharedPtrVector sparseStoragePtrVector)

Definition at line 53 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_cols, Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_rowoffset, and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_rows.

54  :
55  m_rows(0),
56  m_cols(0),
57  m_rowoffset(sparseStoragePtrVector.num_elements()+1, 0.0),
59  m_submatrix(sparseStoragePtrVector.num_elements(),sparseStoragePtrVector)
60  {
61  for (int i = 0; i < sparseStoragePtrVector.num_elements(); i++)
62  {
63  const IndexType rows = sparseStoragePtrVector[i]->GetRows();
64  m_rows += rows;
65  m_cols += sparseStoragePtrVector[i]->GetColumns();
66  m_rowoffset[i+1] = m_rowoffset[i] + rows;
67  }
68  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

◆ NekSparseDiagBlkMatrix() [2/2]

template<typename SparseStorageType >
Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::NekSparseDiagBlkMatrix ( const NekSparseDiagBlkMatrix< SparseStorageType > &  src)

Definition at line 71 of file SparseDiagBlkMatrix.cpp.

71  :
72  m_rows(src.m_rows),
73  m_cols(src.m_cols),
74  m_rowoffset(src.m_rowoffset),
75  m_mulCallsCounter(src.m_mulCallsCounter),
76  m_submatrix(src.m_submatrix)
77  {
78  }
SparseStorageSharedPtrVector m_submatrix

◆ ~NekSparseDiagBlkMatrix()

template<typename SparseStorageType >
Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::~NekSparseDiagBlkMatrix ( )

Definition at line 81 of file SparseDiagBlkMatrix.cpp.

82  {
83  }

Member Function Documentation

◆ GetAvgRowDensity() [1/2]

template<typename SparseStorageType >
SparseStorageType::DataType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetAvgRowDensity ( )

Definition at line 249 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetNumNonZeroEntries(), Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows(), and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

250  {
251  DataType avgRowDensity = 0.0;
252  for (int i = 0; i < m_submatrix.num_elements(); i++)
253  {
254  avgRowDensity += (DataType) m_submatrix[i]->GetNumNonZeroEntries() /
255  (DataType) m_submatrix[i]->GetRows();
256  }
257  return avgRowDensity / m_submatrix.num_elements();
258  }
SparseStorageSharedPtrVector m_submatrix
SparseStorageType::DataType DataType

◆ GetAvgRowDensity() [2/2]

template<typename SparseStorageType >
SparseStorageType::DataType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetAvgRowDensity ( IndexType  i) const

Definition at line 261 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows(), and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

262  {
263  return (DataType) m_submatrix[i]->GetNumNonZeroEntries() /
264  (DataType) m_submatrix[i]->GetRows();
265  }
SparseStorageSharedPtrVector m_submatrix
SparseStorageType::DataType DataType

◆ GetBandwidth() [1/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetBandwidth ( )

Definition at line 268 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

269  {
270  IndexType bandwidth = 0;
271  for (int i = 0; i < m_submatrix.num_elements(); i++)
272  {
273  typename SparseStorageType::const_iterator entry = m_submatrix[i]->begin();
274  for (; entry != m_submatrix[i]->end(); ++entry)
275  {
276  bandwidth = (std::max)(static_cast<int>(bandwidth),
277  2*abs( static_cast<int>(entry->first.first - entry->first.second)+1));
278  }
279  }
280  return bandwidth;
281  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

◆ GetBandwidth() [2/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetBandwidth ( IndexType  i)

Definition at line 284 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

285  {
286  IndexType bandwidth = 0;
287  typename SparseStorageType::const_iterator entry = m_submatrix[i]->begin();
288  for (; entry != m_submatrix[i]->end(); ++entry)
289  {
290  bandwidth = (std::max)(static_cast<int>(bandwidth),
291  2*abs( static_cast<int>(entry->first.first - entry->first.second)+1));
292  }
293  return bandwidth;
294  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

◆ GetColumns() [1/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetColumns ( ) const

◆ GetColumns() [2/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetColumns ( int  i) const

number of columns at i-th submatrix

Definition at line 106 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

107  {
108  return m_submatrix[i]->GetColumns();
109  }
SparseStorageSharedPtrVector m_submatrix

◆ GetCooStorage() [1/2]

template<typename SparseStorageType >
COOMatTypeSharedPtr Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetCooStorage ( )

Definition at line 311 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix, and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSubmatrixSparsityPatternTo().

312  {
313  COOMatTypeSharedPtr coo (new COOMatType());
314  IndexType row_offset = 0;
315  IndexType col_offset = 0;
316  for (IndexType i = 0; i < m_submatrix.num_elements(); i++)
317  {
318  typename SparseStorageType::const_iterator entry = m_submatrix[i]->begin();
319  for (; entry != m_submatrix[i]->end(); entry++)
320  {
321  IndexType loc_row = entry->first.first;
322  IndexType loc_col = entry->first.second;
323  (*coo)[std::make_pair(loc_row + row_offset, loc_col + col_offset) ] = entry->second;
324  }
325  row_offset += m_submatrix[i]->GetRows();
326  col_offset += m_submatrix[i]->GetColumns();
327  }
328  return coo;
329  }
std::map< CoordType, NekDouble > COOMatType
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType
std::shared_ptr< COOMatType > COOMatTypeSharedPtr

◆ GetCooStorage() [2/2]

template<typename SparseStorageType >
COOMatTypeSharedPtr Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetCooStorage ( IndexType  i)

Definition at line 297 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

298  {
299  COOMatTypeSharedPtr coo (new COOMatType());
300  typename SparseStorageType::const_iterator entry = m_submatrix[i]->begin();
301  for (; entry != m_submatrix[i]->end(); entry++)
302  {
303  IndexType loc_row = entry->first.first;
304  IndexType loc_col = entry->first.second;
305  (*coo)[std::make_pair(loc_row, loc_col) ] = entry->second;
306  }
307  return coo;
308  }
std::map< CoordType, NekDouble > COOMatType
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType
std::shared_ptr< COOMatType > COOMatTypeSharedPtr

◆ GetFillInRatio() [1/2]

template<typename SparseStorageType >
NekSparseDiagBlkMatrix< SparseStorageType >::DataType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetFillInRatio ( ) const

Definition at line 142 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

143  {
144  IndexType stored = 0;
145  IndexType nnz = 0;
146  for (int i = 0; i < m_submatrix.num_elements(); i++)
147  {
148  stored += m_submatrix[i]->GetNumStoredDoubles();
149  nnz += m_submatrix[i]->GetNumNonZeroEntries();
150  }
151  return (DataType)stored/(DataType)nnz;
152  }
SparseStorageSharedPtrVector m_submatrix
SparseStorageType::DataType DataType
unsigned int IndexType

◆ GetFillInRatio() [2/2]

template<typename SparseStorageType >
NekSparseDiagBlkMatrix< SparseStorageType >::DataType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetFillInRatio ( int  i) const

Definition at line 136 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

137  {
138  return m_submatrix[i]->GetFillInRatio();
139  }
SparseStorageSharedPtrVector m_submatrix

◆ GetMemoryFootprint() [1/2]

template<typename SparseStorageType >
size_t Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetMemoryFootprint ( )

Definition at line 220 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_rowoffset, and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

221  {
222  size_t bytes =
223  sizeof(IndexType)*2 + // sizes
224  sizeof(unsigned long) + // mulCallsCounter
225  sizeof(IndexVector) +
226  sizeof(IndexType)*m_rowoffset.capacity() +
228  sizeof(SparseStorageSharedPtr)*m_submatrix.capacity();
229  for (int i = 0; i < m_submatrix.num_elements(); i++)
230  {
231  bytes += m_submatrix[i]->GetMemoryUsage();
232  }
233  return bytes;
234  }
SparseStorageSharedPtrVector m_submatrix
Array< OneD, IndexType > IndexVector
unsigned int IndexType
std::shared_ptr< SparseStorageType > SparseStorageSharedPtr
Array< OneD, SparseStorageSharedPtr > SparseStorageSharedPtrVector

◆ GetMemoryFootprint() [2/2]

template<typename SparseStorageType >
size_t Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetMemoryFootprint ( IndexType  i) const

Definition at line 237 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

238  {
239  return m_submatrix[i]->GetMemoryUsage();
240  }
SparseStorageSharedPtrVector m_submatrix

◆ GetMulCallsCounter()

template<typename SparseStorageType >
unsigned long Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetMulCallsCounter ( ) const

◆ GetNumberOfMatrixBlocks()

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetNumberOfMatrixBlocks ( ) const

Definition at line 112 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

113  {
114  return m_submatrix.num_elements();
115  }
SparseStorageSharedPtrVector m_submatrix

◆ GetNumNonZeroEntries() [1/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetNumNonZeroEntries ( )

Definition at line 118 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

Referenced by Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetAvgRowDensity().

119  {
120  IndexType nnz = 0;
121  for (int i = 0; i < m_submatrix.num_elements(); i++)
122  {
123  nnz += m_submatrix[i]->GetNumNonZeroEntries();
124  }
125  return nnz;
126  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

◆ GetNumNonZeroEntries() [2/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetNumNonZeroEntries ( int  i) const

Definition at line 130 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

131  {
132  return m_submatrix[i]->GetNumNonZeroEntries();
133  }
SparseStorageSharedPtrVector m_submatrix

◆ GetRows() [1/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows ( ) const

◆ GetRows() [2/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows ( int  i) const

number of rows at i-th submatrix

Definition at line 99 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

100  {
101  return m_submatrix[i]->GetRows();
102  }
SparseStorageSharedPtrVector m_submatrix

◆ Multiply() [1/2]

template<typename SparseStorageType >
void Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::Multiply ( const DataVectorType in,
DataVectorType out 
)

◆ Multiply() [2/2]

template<typename SparseStorageType >
void Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::Multiply ( const DataType in,
DataType out 
)

◆ MultiplySubMatrix()

template<typename SparseStorageType >
void Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::MultiplySubMatrix ( const IndexType  blockNum,
DataType in,
DataType out 
)

Definition at line 211 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_rowoffset, and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

Referenced by Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::Multiply().

214  {
215  m_submatrix[blockNum]->Multiply(in + m_rowoffset[blockNum], out + m_rowoffset[blockNum]);
216  // m_mulCallsCounter++;
217  }
SparseStorageSharedPtrVector m_submatrix

◆ operator()() [1/2]

template<typename SparseStorageType >
boost::call_traits< typename SparseStorageType::DataType >::const_reference Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::operator() ( const IndexType  row,
const IndexType  column 
) const
Todo:
double check, might be a bug when local_col > local column

Definition at line 164 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows(), and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

165  {
166  IndexType i = 0;
167  static DataType defaultReturnValue = 0;
168 
169  signed int local_row = glob_row;
170  signed int local_col = glob_column;
171 
172  while ((local_row >= m_submatrix[i]->GetRows()) &&
173  (local_col >= 0))
174  {
175  local_row -= m_submatrix[i]->GetRows();
176  local_col -= m_submatrix[i]->GetColumns();
177  i++;
178  }
179  /// \todo double check, might be a bug when local_col > local column
180  if (local_col < 0) return defaultReturnValue;
181 
182  return m_submatrix[i]->GetValue(local_row, local_col);
183  }
SparseStorageSharedPtrVector m_submatrix
SparseStorageType::DataType DataType
unsigned int IndexType

◆ operator()() [2/2]

template<typename SparseStorageType >
boost::call_traits< typename SparseStorageType::DataType >::const_reference Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::operator() ( const IndexType  block,
const IndexType  row,
const IndexType  column 
) const

Definition at line 156 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

157  {
158  return m_submatrix[block]->GetValue(loc_row, loc_column);
159  }
SparseStorageSharedPtrVector m_submatrix

◆ writeBlockSparsityPatternTo()

template<typename SparseStorageType >
void Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeBlockSparsityPatternTo ( std::ostream &  out,
const IndexType  blk_row = 0,
const IndexType  blk_col = 0,
IndexType  blockSize = 64 
)

Definition at line 466 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows(), and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

471  {
472  blockSize = (std::min)(blockSize, GetRows());
473  std::vector< std::vector<int> > grid (blockSize);
474  for (int row = 0; row < blockSize; row++)
475  {
476  grid[row].resize(blockSize,0.0);
477  }
478 
479  IndexType row_offset = 0;
480  IndexType col_offset = 0;
481  for (int i = 0; i < m_submatrix.num_elements(); i++)
482  {
483  typename SparseStorageType::const_iterator entry =
484  m_submatrix[i]->begin();
485  typename SparseStorageType::const_iterator stop =
486  m_submatrix[i]->end();
487  for (; entry != stop; ++entry)
488  {
489  const IndexType row = entry->first.first + row_offset;
490  const IndexType col = entry->first.second + col_offset;
491 
492  if (blk_row != row / blockSize ) continue;
493  if (blk_col != col / blockSize ) continue;
494  grid[row % blockSize][col % blockSize]++;
495  }
496  row_offset += m_submatrix[i]->GetRows();
497  col_offset += m_submatrix[i]->GetColumns();
498  }
499 
500  for (int row = 0; row < blockSize; row++)
501  {
502  for (int col = 0; col < blockSize; col++)
503  {
504  out << grid[row][col] << " ";
505  }
506  out << std::endl;
507  }
508  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

◆ writeSparsityPatternTo()

template<typename SparseStorageType >
void Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSparsityPatternTo ( std::ostream &  out,
IndexType  blockSize = 64 
)

Definition at line 379 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows(), Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix, and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSubmatrixBlockSparsityPatternTo().

Referenced by Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSubmatrixSparsityPatternTo().

381  {
382  const int matRows = GetRows();
383  const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
384  const int gridCols = gridRows;
385 
386  std::vector< std::vector<int> > grid (gridRows);
387  for (int row = 0; row < gridRows; row++)
388  {
389  grid[row].resize(gridCols,0.0);
390  }
391 
392  IndexType row_offset = 0;
393  IndexType col_offset = 0;
394  for (int i = 0; i < m_submatrix.num_elements(); i++)
395  {
396  typename SparseStorageType::const_iterator entry = m_submatrix[i]->begin();
397  typename SparseStorageType::const_iterator stop = m_submatrix[i]->end();
398  for (; entry != stop; ++entry)
399  {
400  const IndexType row = entry->first.first + row_offset;
401  const IndexType col = entry->first.second + col_offset;
402  const int gridRow = row / blockSize;
403  const int gridCol = col / blockSize;
404  grid[gridRow][gridCol]++;
405  }
406  row_offset += m_submatrix[i]->GetRows();
407  col_offset += m_submatrix[i]->GetColumns();
408  }
409 
410  for (int row = 0; row < gridRows; row++)
411  {
412  for (int col = 0; col < gridCols; col++)
413  {
414  out << grid[row][col] << " ";
415  }
416  out << std::endl;
417  }
418  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

◆ writeSubmatrixBlockSparsityPatternTo()

template<typename SparseStorageType >
void Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSubmatrixBlockSparsityPatternTo ( std::ostream &  out,
const IndexType  subMatrixIdx,
const IndexType  blk_row = 0,
const IndexType  blk_col = 0,
IndexType  blockSize = 64 
)

Complementary routine to the previous. It generates exact non-zero pattern of a given block matrix entry to *this object. E.g., for a 6x6 matrix defined as A(i,i):=i, A(i,j):=0, block size = 2 and blk_row=blk_col=2 it produces 2x2 matrix with 5 and 6 along the diagonal.

Definition at line 428 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows(), and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix.

Referenced by Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSparsityPatternTo().

433  {
434  blockSize = (std::min)(blockSize, m_submatrix[subMatrixIdx]->GetRows());
435  std::vector< std::vector<int> > grid (blockSize);
436  for (int row = 0; row < blockSize; row++)
437  {
438  grid[row].resize(blockSize,0.0);
439  }
440 
441  typename SparseStorageType::const_iterator entry =
442  m_submatrix[subMatrixIdx]->begin();
443  typename SparseStorageType::const_iterator stop =
444  m_submatrix[subMatrixIdx]->end();
445  for (; entry != stop; ++entry)
446  {
447  const IndexType row = entry->first.first;
448  const IndexType col = entry->first.second;
449 
450  if (blk_row != row / blockSize ) continue;
451  if (blk_col != col / blockSize ) continue;
452  grid[row % blockSize][col % blockSize]++;
453  }
454 
455  for (int row = 0; row < blockSize; row++)
456  {
457  for (int col = 0; col < blockSize; col++)
458  {
459  out << grid[row][col] << " ";
460  }
461  out << std::endl;
462  }
463  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

◆ writeSubmatrixSparsityPatternTo()

template<typename SparseStorageType >
void Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSubmatrixSparsityPatternTo ( std::ostream &  out,
const IndexType  subMatrixIdx,
IndexType  blockSize = 64 
)

Definition at line 340 of file SparseDiagBlkMatrix.cpp.

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix, and Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::writeSparsityPatternTo().

Referenced by Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetCooStorage().

343  {
344  const int matRows = m_submatrix[subMatrixIdx]->GetRows();
345  const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
346  const int gridCols = gridRows;
347 
348  std::vector< std::vector<int> > grid (gridRows);
349  for (int row = 0; row < gridRows; row++)
350  {
351  grid[row].resize(gridCols,0.0);
352  }
353 
354  typename SparseStorageType::const_iterator entry =
355  m_submatrix[subMatrixIdx]->begin();
356  typename SparseStorageType::const_iterator stop =
357  m_submatrix[subMatrixIdx]->end();
358  for (; entry != stop; ++entry)
359  {
360  const IndexType row = entry->first.first;
361  const IndexType col = entry->first.second;
362  const int gridRow = row / blockSize;
363  const int gridCol = col / blockSize;
364  grid[gridRow][gridCol]++;
365  }
366 
367  for (int row = 0; row < gridRows; row++)
368  {
369  for (int col = 0; col < gridCols; col++)
370  {
371  out << grid[row][col] << " ";
372  }
373  out << std::endl;
374  }
375  }
SparseStorageSharedPtrVector m_submatrix
unsigned int IndexType

Member Data Documentation

◆ m_cols

template<typename SparseStorageType>
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_cols
protected

◆ m_mulCallsCounter

template<typename SparseStorageType>
unsigned long Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_mulCallsCounter
protected

◆ m_rowoffset

template<typename SparseStorageType>
IndexVector Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_rowoffset
protected

◆ m_rows

template<typename SparseStorageType>
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_rows
protected

◆ m_submatrix

template<typename SparseStorageType>
SparseStorageSharedPtrVector Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::m_submatrix
protected