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

55  : m_rows(0), m_cols(0), m_rowoffset(sparseStoragePtrVector.size() + 1, 0.0),
57  m_submatrix(sparseStoragePtrVector.size(), sparseStoragePtrVector)
58 {
59  for (int i = 0; i < sparseStoragePtrVector.size(); i++)
60  {
61  const IndexType rows = sparseStoragePtrVector[i]->GetRows();
62  m_rows += rows;
63  m_cols += sparseStoragePtrVector[i]->GetColumns();
64  m_rowoffset[i + 1] = m_rowoffset[i] + rows;
65  }
66 }
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 69 of file SparseDiagBlkMatrix.cpp.

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

◆ ~NekSparseDiagBlkMatrix()

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

Definition at line 77 of file SparseDiagBlkMatrix.cpp.

78 {
79 }

Member Function Documentation

◆ GetAvgRowDensity() [1/2]

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

Definition at line 251 of file SparseDiagBlkMatrix.cpp.

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

◆ GetAvgRowDensity() [2/2]

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

Definition at line 264 of file SparseDiagBlkMatrix.cpp.

265 {
266  return (DataType)m_submatrix[i]->GetNumNonZeroEntries() /
268 }

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

◆ GetBandwidth() [1/2]

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

Definition at line 271 of file SparseDiagBlkMatrix.cpp.

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

References tinysimd::abs().

◆ GetBandwidth() [2/2]

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

Definition at line 291 of file SparseDiagBlkMatrix.cpp.

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

References tinysimd::abs().

◆ GetColumns() [1/2]

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

Definition at line 88 of file SparseDiagBlkMatrix.cpp.

89 {
90  return m_cols;
91 }

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

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

◆ GetCooStorage() [1/2]

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

Definition at line 321 of file SparseDiagBlkMatrix.cpp.

322 {
323  COOMatTypeSharedPtr coo(new COOMatType());
324  IndexType row_offset = 0;
325  IndexType col_offset = 0;
326  for (IndexType i = 0; i < m_submatrix.size(); i++)
327  {
328  typename SparseStorageType::const_iterator entry =
329  m_submatrix[i]->begin();
330  for (; entry != m_submatrix[i]->end(); entry++)
331  {
332  IndexType loc_row = entry->first.first;
333  IndexType loc_col = entry->first.second;
334  (*coo)[std::make_pair(loc_row + row_offset, loc_col + col_offset)] =
335  entry->second;
336  }
337  row_offset += m_submatrix[i]->GetRows();
338  col_offset += m_submatrix[i]->GetColumns();
339  }
340  return coo;
341 }
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 306 of file SparseDiagBlkMatrix.cpp.

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

◆ GetFillInRatio() [1/2]

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

Definition at line 142 of file SparseDiagBlkMatrix.cpp.

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

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

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

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

◆ GetMemoryFootprint() [1/2]

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

Definition at line 220 of file SparseDiagBlkMatrix.cpp.

221 {
222  size_t bytes = sizeof(IndexType) * 2 + // sizes
223  sizeof(unsigned long) + // mulCallsCounter
224  sizeof(IndexVector) +
225  sizeof(IndexType) * m_rowoffset.capacity() +
227  sizeof(SparseStorageSharedPtr) * m_submatrix.capacity();
228  for (int i = 0; i < m_submatrix.size(); i++)
229  {
230  bytes += m_submatrix[i]->GetMemoryUsage();
231  }
232  return bytes;
233 }
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 236 of file SparseDiagBlkMatrix.cpp.

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

◆ GetMulCallsCounter()

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

Definition at line 243 of file SparseDiagBlkMatrix.cpp.

245 {
246  return m_mulCallsCounter;
247 }

◆ GetNumberOfMatrixBlocks()

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

Definition at line 108 of file SparseDiagBlkMatrix.cpp.

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

◆ GetNumNonZeroEntries() [1/2]

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

Definition at line 115 of file SparseDiagBlkMatrix.cpp.

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

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

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

◆ GetRows() [1/2]

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

Definition at line 82 of file SparseDiagBlkMatrix.cpp.

83 {
84  return m_rows;
85 }

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

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

◆ Multiply() [1/2]

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

Definition at line 200 of file SparseDiagBlkMatrix.cpp.

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

◆ Multiply() [2/2]

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

Definition at line 189 of file SparseDiagBlkMatrix.cpp.

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

◆ MultiplySubMatrix()

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

Definition at line 211 of file SparseDiagBlkMatrix.cpp.

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

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

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

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

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

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

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

◆ writeSparsityPatternTo()

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

Definition at line 388 of file SparseDiagBlkMatrix.cpp.

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

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

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

◆ writeSubmatrixSparsityPatternTo()

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

Definition at line 351 of file SparseDiagBlkMatrix.cpp.

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

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.