51 template<
typename SparseStorageType>
54 sparseStoragePtrVector):
57 m_rowoffset(sparseStoragePtrVector.num_elements()+1, 0.0),
59 m_submatrix(sparseStoragePtrVector.num_elements(),sparseStoragePtrVector)
61 for (
int i = 0; i < sparseStoragePtrVector.num_elements(); i++)
63 const IndexType rows = sparseStoragePtrVector[i]->GetRows();
65 m_cols += sparseStoragePtrVector[i]->GetColumns();
70 template<
typename SparseStorageType>
80 template<
typename SparseStorageType>
85 template<
typename SparseStorageType>
91 template<
typename SparseStorageType>
98 template<
typename SparseStorageType>
105 template<
typename SparseStorageType>
111 template<
typename SparseStorageType>
117 template<
typename SparseStorageType>
121 for (
int i = 0; i <
m_submatrix.num_elements(); i++)
129 template<
typename SparseStorageType>
135 template<
typename SparseStorageType>
141 template<
typename SparseStorageType>
146 for (
int i = 0; i <
m_submatrix.num_elements(); i++)
155 template<
typename SparseStorageType>
158 return m_submatrix[block]->GetValue(loc_row, loc_column);
161 template<
typename SparseStorageType>
162 typename boost::call_traits<typename SparseStorageType::DataType>::const_reference
167 static DataType defaultReturnValue = 0;
169 signed int local_row = glob_row;
170 signed int local_col = glob_column;
180 if (local_col < 0)
return defaultReturnValue;
182 return m_submatrix[i]->GetValue(local_row, local_col);
186 template<
typename SparseStorageType>
191 for (
int i = 0; i <
m_submatrix.num_elements(); ++i)
198 template<
typename SparseStorageType>
202 for (
int i = 0; i <
m_submatrix.num_elements(); ++i)
209 template<
typename SparseStorageType>
219 template<
typename SparseStorageType>
224 sizeof(
unsigned long) +
229 for (
int i = 0; i <
m_submatrix.num_elements(); i++)
236 template<
typename SparseStorageType>
242 template<
typename SparseStorageType>
248 template<
typename SparseStorageType>
252 for (
int i = 0; i <
m_submatrix.num_elements(); i++)
260 template<
typename SparseStorageType>
267 template<
typename SparseStorageType>
271 for (
int i = 0; i <
m_submatrix.num_elements(); i++)
273 typename SparseStorageType::const_iterator entry =
m_submatrix[i]->begin();
276 bandwidth = (std::max)(static_cast<int>(bandwidth),
277 2*abs( static_cast<int>(entry->first.first - entry->first.second)+1));
283 template<
typename SparseStorageType>
287 typename SparseStorageType::const_iterator entry =
m_submatrix[i]->begin();
290 bandwidth = (std::max)(static_cast<int>(bandwidth),
291 2*abs( static_cast<int>(entry->first.first - entry->first.second)+1));
296 template<
typename SparseStorageType>
300 typename SparseStorageType::const_iterator entry =
m_submatrix[i]->begin();
305 (*coo)[std::make_pair(loc_row, loc_col) ] = entry->second;
310 template<
typename SparseStorageType>
318 typename SparseStorageType::const_iterator entry =
m_submatrix[i]->begin();
323 (*coo)[std::make_pair(loc_row + row_offset, loc_col + col_offset) ] = entry->second;
338 template<
typename SparseStorageType>
344 const int matRows =
m_submatrix[subMatrixIdx]->GetRows();
345 const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
346 const int gridCols = gridRows;
348 std::vector< std::vector<int> > grid (gridRows);
349 for (
int row = 0; row < gridRows; row++)
351 grid[row].resize(gridCols,0.0);
354 typename SparseStorageType::const_iterator entry =
356 typename SparseStorageType::const_iterator stop =
358 for (; entry != stop; ++entry)
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]++;
367 for (
int row = 0; row < gridRows; row++)
369 for (
int col = 0; col < gridCols; col++)
371 out << grid[row][col] <<
" ";
377 template<
typename SparseStorageType>
383 const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
384 const int gridCols = gridRows;
386 std::vector< std::vector<int> > grid (gridRows);
387 for (
int row = 0; row < gridRows; row++)
389 grid[row].resize(gridCols,0.0);
394 for (
int i = 0; i <
m_submatrix.num_elements(); i++)
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)
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]++;
410 for (
int row = 0; row < gridRows; row++)
412 for (
int col = 0; col < gridCols; col++)
414 out << grid[row][col] <<
" ";
426 template<
typename SparseStorageType>
435 std::vector< std::vector<int> > grid (blockSize);
436 for (
int row = 0; row < blockSize; row++)
438 grid[row].resize(blockSize,0.0);
441 typename SparseStorageType::const_iterator entry =
443 typename SparseStorageType::const_iterator stop =
445 for (; entry != stop; ++entry)
447 const IndexType row = entry->first.first;
448 const IndexType col = entry->first.second;
450 if (blk_row != row / blockSize )
continue;
451 if (blk_col != col / blockSize )
continue;
452 grid[row % blockSize][col % blockSize]++;
455 for (
int row = 0; row < blockSize; row++)
457 for (
int col = 0; col < blockSize; col++)
459 out << grid[row][col] <<
" ";
465 template<
typename SparseStorageType>
472 blockSize = (std::min)(blockSize,
GetRows());
473 std::vector< std::vector<int> > grid (blockSize);
474 for (
int row = 0; row < blockSize; row++)
476 grid[row].resize(blockSize,0.0);
481 for (
int i = 0; i <
m_submatrix.num_elements(); i++)
483 typename SparseStorageType::const_iterator entry =
485 typename SparseStorageType::const_iterator stop =
487 for (; entry != stop; ++entry)
489 const IndexType row = entry->first.first + row_offset;
490 const IndexType col = entry->first.second + col_offset;
492 if (blk_row != row / blockSize )
continue;
493 if (blk_col != col / blockSize )
continue;
494 grid[row % blockSize][col % blockSize]++;
500 for (
int row = 0; row < blockSize; row++)
502 for (
int col = 0; col < blockSize; col++)
504 out << grid[row][col] <<
" ";
IndexType GetNumberOfMatrixBlocks() const
std::map< CoordType, NekDouble > COOMatType
COOMatTypeSharedPtr GetCooStorage()
size_t GetMemoryFootprint()
SparseStorageSharedPtrVector m_submatrix
Array< OneD, IndexType > IndexVector
boost::call_traits< DataType >::const_reference operator()(const IndexType row, const IndexType column) const
void MultiplySubMatrix(const IndexType blockNum, DataType *in, DataType *out)
DataType GetAvgRowDensity()
unsigned long m_mulCallsCounter
SparseStorageType::DataType DataType
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 en...
DataType GetFillInRatio() const
void writeBlockSparsityPatternTo(std::ostream &out, const IndexType blk_row=0, const IndexType blk_col=0, IndexType blockSize=64)
void Multiply(const DataVectorType &in, DataVectorType &out)
IndexType GetRows() const
std::shared_ptr< COOMatType > COOMatTypeSharedPtr
void writeSparsityPatternTo(std::ostream &out, IndexType blockSize=64)
std::shared_ptr< SparseStorageType > SparseStorageSharedPtr
unsigned long GetMulCallsCounter() const
IndexType GetNumNonZeroEntries()
void writeSubmatrixSparsityPatternTo(std::ostream &out, const IndexType subMatrixIdx, IndexType blockSize=64)
Array< OneD, SparseStorageSharedPtr > SparseStorageSharedPtrVector
IndexType GetColumns() const
~NekSparseDiagBlkMatrix()
NekSparseDiagBlkMatrix(const SparseStorageSharedPtrVector &sparseStoragePtrVector)