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

Member Typedef Documentation

◆ ConstDataVectorType

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

Definition at line 66 of file SparseDiagBlkMatrix.hpp.

◆ DataType

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

Definition at line 63 of file SparseDiagBlkMatrix.hpp.

◆ DataVectorType

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

Definition at line 65 of file SparseDiagBlkMatrix.hpp.

◆ SparseStorageSharedPtr

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

Definition at line 64 of file SparseDiagBlkMatrix.hpp.

◆ SparseStorageSharedPtrVector

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

Definition at line 67 of file SparseDiagBlkMatrix.hpp.

◆ StorageType

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

Definition at line 62 of file SparseDiagBlkMatrix.hpp.

Constructor & Destructor Documentation

◆ NekSparseDiagBlkMatrix() [1/2]

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

Definition at line 51 of file SparseDiagBlkMatrix.cpp.

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

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

◆ ~NekSparseDiagBlkMatrix()

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

Definition at line 75 of file SparseDiagBlkMatrix.cpp.

76{
77}

Member Function Documentation

◆ GetAvgRowDensity() [1/2]

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

Definition at line 249 of file SparseDiagBlkMatrix.cpp.

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

◆ GetAvgRowDensity() [2/2]

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

Definition at line 262 of file SparseDiagBlkMatrix.cpp.

263{
264 return (DataType)m_submatrix[i]->GetNumNonZeroEntries() /
266}

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

◆ GetBandwidth() [1/2]

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

Definition at line 269 of file SparseDiagBlkMatrix.cpp.

270{
271 IndexType bandwidth = 0;
272 for (int i = 0; i < m_submatrix.size(); i++)
273 {
274 typename SparseStorageType::const_iterator entry =
275 m_submatrix[i]->begin();
276 for (; entry != m_submatrix[i]->end(); ++entry)
277 {
278 bandwidth =
279 (std::max)(static_cast<int>(bandwidth),
280 2 * abs(static_cast<int>(entry->first.first -
281 entry->first.second) +
282 1));
283 }
284 }
285 return bandwidth;
286}
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 289 of file SparseDiagBlkMatrix.cpp.

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

References tinysimd::abs().

◆ GetColumns() [1/2]

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

Definition at line 86 of file SparseDiagBlkMatrix.cpp.

87{
88 return m_cols;
89}

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

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

◆ GetCooStorage() [1/2]

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

Definition at line 319 of file SparseDiagBlkMatrix.cpp.

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

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

◆ GetFillInRatio() [1/2]

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

Definition at line 140 of file SparseDiagBlkMatrix.cpp.

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

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

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

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

◆ GetMemoryFootprint() [1/2]

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

Definition at line 218 of file SparseDiagBlkMatrix.cpp.

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

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

◆ GetMulCallsCounter()

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

Definition at line 241 of file SparseDiagBlkMatrix.cpp.

243{
244 return m_mulCallsCounter;
245}

◆ GetNumberOfMatrixBlocks()

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

Definition at line 106 of file SparseDiagBlkMatrix.cpp.

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

◆ GetNumNonZeroEntries() [1/2]

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

Definition at line 113 of file SparseDiagBlkMatrix.cpp.

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

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

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

◆ GetRows() [1/2]

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

Definition at line 80 of file SparseDiagBlkMatrix.cpp.

81{
82 return m_rows;
83}

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

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

◆ Multiply() [1/2]

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

Definition at line 198 of file SparseDiagBlkMatrix.cpp.

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

◆ Multiply() [2/2]

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

Definition at line 187 of file SparseDiagBlkMatrix.cpp.

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

◆ MultiplySubMatrix()

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

Definition at line 209 of file SparseDiagBlkMatrix.cpp.

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

◆ operator()() [1/2]

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

Definition at line 155 of file SparseDiagBlkMatrix.cpp.

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

◆ operator()() [2/2]

template<typename SparseStorageType >
boost::call_traits< typenameSparseStorageType::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.

166{
167 IndexType i = 0;
168 static DataType defaultReturnValue = 0;
169
170 signed int local_row = glob_row;
171 signed int local_col = glob_column;
172
173 while ((local_row >= m_submatrix[i]->GetRows()) && (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)
181 return defaultReturnValue;
182
183 return m_submatrix[i]->GetValue(local_row, local_col);
184}

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

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

◆ writeSparsityPatternTo()

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

Definition at line 386 of file SparseDiagBlkMatrix.cpp.

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

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

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

◆ writeSubmatrixSparsityPatternTo()

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

Definition at line 349 of file SparseDiagBlkMatrix.cpp.

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

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