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 60 of file SparseDiagBlkMatrix.hpp.

Member Typedef Documentation

◆ ConstDataVectorType

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

Definition at line 67 of file SparseDiagBlkMatrix.hpp.

◆ DataType

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

Definition at line 64 of file SparseDiagBlkMatrix.hpp.

◆ DataVectorType

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

Definition at line 66 of file SparseDiagBlkMatrix.hpp.

◆ SparseStorageSharedPtr

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

Definition at line 65 of file SparseDiagBlkMatrix.hpp.

◆ SparseStorageSharedPtrVector

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

Definition at line 68 of file SparseDiagBlkMatrix.hpp.

◆ StorageType

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

Definition at line 63 of file SparseDiagBlkMatrix.hpp.

Constructor & Destructor Documentation

◆ NekSparseDiagBlkMatrix() [1/2]

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

Definition at line 52 of file SparseDiagBlkMatrix.cpp.

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

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

◆ NekSparseDiagBlkMatrix() [2/2]

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

Definition at line 68 of file SparseDiagBlkMatrix.cpp.

70  : m_rows(src.m_rows), m_cols(src.m_cols), m_rowoffset(src.m_rowoffset),
71  m_mulCallsCounter(src.m_mulCallsCounter), m_submatrix(src.m_submatrix)
72 {
73 }

◆ ~NekSparseDiagBlkMatrix()

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

Definition at line 76 of file SparseDiagBlkMatrix.cpp.

77 {
78 }

Member Function Documentation

◆ GetAvgRowDensity() [1/2]

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

Definition at line 250 of file SparseDiagBlkMatrix.cpp.

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

◆ GetAvgRowDensity() [2/2]

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

Definition at line 263 of file SparseDiagBlkMatrix.cpp.

264 {
265  return (DataType)m_submatrix[i]->GetNumNonZeroEntries() /
267 }

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetNumNonZeroEntries().

◆ GetBandwidth() [1/2]

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

Definition at line 270 of file SparseDiagBlkMatrix.cpp.

271 {
272  IndexType bandwidth = 0;
273  for (int i = 0; i < m_submatrix.size(); i++)
274  {
275  typename SparseStorageType::const_iterator entry =
276  m_submatrix[i]->begin();
277  for (; entry != m_submatrix[i]->end(); ++entry)
278  {
279  bandwidth =
280  (std::max)(static_cast<int>(bandwidth),
281  2 * abs(static_cast<int>(entry->first.first -
282  entry->first.second) +
283  1));
284  }
285  }
286  return bandwidth;
287 }
scalarT< T > abs(scalarT< T > in)
Definition: scalar.hpp:298

References tinysimd::abs().

◆ GetBandwidth() [2/2]

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

Definition at line 290 of file SparseDiagBlkMatrix.cpp.

291 {
292  IndexType bandwidth = 0;
293  typename SparseStorageType::const_iterator entry = m_submatrix[i]->begin();
294  for (; entry != m_submatrix[i]->end(); ++entry)
295  {
296  bandwidth = (std::max)(
297  static_cast<int>(bandwidth),
298  2 * abs(static_cast<int>(entry->first.first - entry->first.second) +
299  1));
300  }
301  return bandwidth;
302 }

References tinysimd::abs().

◆ GetColumns() [1/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetColumns

Definition at line 87 of file SparseDiagBlkMatrix.cpp.

88 {
89  return m_cols;
90 }

Referenced by Nektar::operator<<().

◆ GetColumns() [2/2]

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

number of columns at i-th submatrix

Definition at line 101 of file SparseDiagBlkMatrix.cpp.

102 {
103  return m_submatrix[i]->GetColumns();
104 }

◆ GetCooStorage() [1/2]

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

Definition at line 320 of file SparseDiagBlkMatrix.cpp.

321 {
322  COOMatTypeSharedPtr coo(new COOMatType());
323  IndexType row_offset = 0;
324  IndexType col_offset = 0;
325  for (IndexType i = 0; i < m_submatrix.size(); i++)
326  {
327  typename SparseStorageType::const_iterator entry =
328  m_submatrix[i]->begin();
329  for (; entry != m_submatrix[i]->end(); entry++)
330  {
331  IndexType loc_row = entry->first.first;
332  IndexType loc_col = entry->first.second;
333  (*coo)[std::make_pair(loc_row + row_offset, loc_col + col_offset)] =
334  entry->second;
335  }
336  row_offset += m_submatrix[i]->GetRows();
337  col_offset += m_submatrix[i]->GetColumns();
338  }
339  return coo;
340 }
std::shared_ptr< COOMatType > COOMatTypeSharedPtr
std::map< CoordType, NekDouble > COOMatType

◆ GetCooStorage() [2/2]

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

Definition at line 305 of file SparseDiagBlkMatrix.cpp.

307 {
308  COOMatTypeSharedPtr coo(new COOMatType());
309  typename SparseStorageType::const_iterator entry = m_submatrix[i]->begin();
310  for (; entry != m_submatrix[i]->end(); entry++)
311  {
312  IndexType loc_row = entry->first.first;
313  IndexType loc_col = entry->first.second;
314  (*coo)[std::make_pair(loc_row, loc_col)] = entry->second;
315  }
316  return coo;
317 }

◆ GetFillInRatio() [1/2]

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

Definition at line 141 of file SparseDiagBlkMatrix.cpp.

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

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetNumNonZeroEntries().

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

◆ GetFillInRatio() [2/2]

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

Definition at line 134 of file SparseDiagBlkMatrix.cpp.

135 {
136  return m_submatrix[i]->GetFillInRatio();
137 }

References Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetFillInRatio().

◆ GetMemoryFootprint() [1/2]

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

Definition at line 219 of file SparseDiagBlkMatrix.cpp.

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

◆ GetMemoryFootprint() [2/2]

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

Definition at line 235 of file SparseDiagBlkMatrix.cpp.

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

◆ GetMulCallsCounter()

template<typename SparseStorageType >
unsigned long Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetMulCallsCounter

Definition at line 242 of file SparseDiagBlkMatrix.cpp.

244 {
245  return m_mulCallsCounter;
246 }

◆ GetNumberOfMatrixBlocks()

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetNumberOfMatrixBlocks

Definition at line 107 of file SparseDiagBlkMatrix.cpp.

109 {
110  return m_submatrix.size();
111 }

◆ GetNumNonZeroEntries() [1/2]

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

Definition at line 114 of file SparseDiagBlkMatrix.cpp.

115 {
116  IndexType nnz = 0;
117  for (int i = 0; i < m_submatrix.size(); i++)
118  {
119  nnz += m_submatrix[i]->GetNumNonZeroEntries();
120  }
121  return nnz;
122 }

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

◆ GetNumNonZeroEntries() [2/2]

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

Definition at line 126 of file SparseDiagBlkMatrix.cpp.

128 {
129  return m_submatrix[i]->GetNumNonZeroEntries();
130 }

◆ GetRows() [1/2]

template<typename SparseStorageType >
IndexType Nektar::NekSparseDiagBlkMatrix< SparseStorageType >::GetRows

Definition at line 81 of file SparseDiagBlkMatrix.cpp.

82 {
83  return m_rows;
84 }

Referenced by Nektar::operator<<().

◆ GetRows() [2/2]

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

number of rows at i-th submatrix

Definition at line 94 of file SparseDiagBlkMatrix.cpp.

95 {
96  return m_submatrix[i]->GetRows();
97 }

◆ Multiply() [1/2]

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

Definition at line 199 of file SparseDiagBlkMatrix.cpp.

201 {
202  for (int i = 0; i < m_submatrix.size(); ++i)
203  {
204  m_submatrix[i]->Multiply(&in[m_rowoffset[i]], &out[m_rowoffset[i]]);
205  }
207 }

◆ Multiply() [2/2]

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

Definition at line 188 of file SparseDiagBlkMatrix.cpp.

190 {
191  for (int i = 0; i < m_submatrix.size(); ++i)
192  {
193  m_submatrix[i]->Multiply(&in[m_rowoffset[i]], &out[m_rowoffset[i]]);
194  }
196 }

◆ MultiplySubMatrix()

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

Definition at line 210 of file SparseDiagBlkMatrix.cpp.

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

◆ operator()() [1/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.

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

◆ operator()() [2/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 165 of file SparseDiagBlkMatrix.cpp.

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

◆ 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 477 of file SparseDiagBlkMatrix.cpp.

480 {
481  blockSize = (std::min)(blockSize, GetRows());
482  std::vector<std::vector<int>> grid(blockSize);
483  for (int row = 0; row < blockSize; row++)
484  {
485  grid[row].resize(blockSize, 0.0);
486  }
487 
488  IndexType row_offset = 0;
489  IndexType col_offset = 0;
490  for (int i = 0; i < m_submatrix.size(); i++)
491  {
492  typename SparseStorageType::const_iterator entry =
493  m_submatrix[i]->begin();
494  typename SparseStorageType::const_iterator stop = m_submatrix[i]->end();
495  for (; entry != stop; ++entry)
496  {
497  const IndexType row = entry->first.first + row_offset;
498  const IndexType col = entry->first.second + col_offset;
499 
500  if (blk_row != row / blockSize)
501  continue;
502  if (blk_col != col / blockSize)
503  continue;
504  grid[row % blockSize][col % blockSize]++;
505  }
506  row_offset += m_submatrix[i]->GetRows();
507  col_offset += m_submatrix[i]->GetColumns();
508  }
509 
510  for (int row = 0; row < blockSize; row++)
511  {
512  for (int col = 0; col < blockSize; col++)
513  {
514  out << grid[row][col] << " ";
515  }
516  out << std::endl;
517  }
518 }

◆ writeSparsityPatternTo()

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

Definition at line 387 of file SparseDiagBlkMatrix.cpp.

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

◆ 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 436 of file SparseDiagBlkMatrix.cpp.

442 {
443  blockSize = (std::min)(blockSize, m_submatrix[subMatrixIdx]->GetRows());
444  std::vector<std::vector<int>> grid(blockSize);
445  for (int row = 0; row < blockSize; row++)
446  {
447  grid[row].resize(blockSize, 0.0);
448  }
449 
450  typename SparseStorageType::const_iterator entry =
451  m_submatrix[subMatrixIdx]->begin();
452  typename SparseStorageType::const_iterator stop =
453  m_submatrix[subMatrixIdx]->end();
454  for (; entry != stop; ++entry)
455  {
456  const IndexType row = entry->first.first;
457  const IndexType col = entry->first.second;
458 
459  if (blk_row != row / blockSize)
460  continue;
461  if (blk_col != col / blockSize)
462  continue;
463  grid[row % blockSize][col % blockSize]++;
464  }
465 
466  for (int row = 0; row < blockSize; row++)
467  {
468  for (int col = 0; col < blockSize; col++)
469  {
470  out << grid[row][col] << " ";
471  }
472  out << std::endl;
473  }
474 }

◆ writeSubmatrixSparsityPatternTo()

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

Definition at line 350 of file SparseDiagBlkMatrix.cpp.

352 {
353  const int matRows = m_submatrix[subMatrixIdx]->GetRows();
354  const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
355  const int gridCols = gridRows;
356 
357  std::vector<std::vector<int>> grid(gridRows);
358  for (int row = 0; row < gridRows; row++)
359  {
360  grid[row].resize(gridCols, 0.0);
361  }
362 
363  typename SparseStorageType::const_iterator entry =
364  m_submatrix[subMatrixIdx]->begin();
365  typename SparseStorageType::const_iterator stop =
366  m_submatrix[subMatrixIdx]->end();
367  for (; entry != stop; ++entry)
368  {
369  const IndexType row = entry->first.first;
370  const IndexType col = entry->first.second;
371  const int gridRow = row / blockSize;
372  const int gridCol = col / blockSize;
373  grid[gridRow][gridCol]++;
374  }
375 
376  for (int row = 0; row < gridRows; row++)
377  {
378  for (int col = 0; col < gridCols; col++)
379  {
380  out << grid[row][col] << " ";
381  }
382  out << std::endl;
383  }
384 }

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

Definition at line 130 of file SparseDiagBlkMatrix.hpp.

◆ 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

Definition at line 131 of file SparseDiagBlkMatrix.hpp.