53template <
typename SparseStorageType>
56 : m_mulCallsCounter(0), m_sparseStorage(sparseStoragePtr)
60template <
typename SparseStorageType>
62 : m_mulCallsCounter(src.m_mulCallsCounter),
63 m_sparseStorage(src.m_sparseStorage)
67template <
typename SparseStorageType>
72template <
typename SparseStorageType>
75 return m_sparseStorage->GetRows();
78template <
typename SparseStorageType>
81 return m_sparseStorage->GetColumns();
84template <
typename SparseStorageType>
87 return m_sparseStorage->GetNumNonZeroEntries();
90template <
typename SparseStorageType>
92 SparseStorageType>::GetFillInRatio()
const
97template <
typename SparseStorageType>
98typename boost::call_traits<
99 typename SparseStorageType::DataType>::const_reference
101 unsigned int column)
const
103 return m_sparseStorage->GetValue(row, column);
106template <
typename SparseStorageType>
108 SparseStorageType>::begin()
const
110 return m_sparseStorage->
begin();
113template <
typename SparseStorageType>
115 SparseStorageType>::end()
const
117 return m_sparseStorage->
end();
120template <
typename SparseStorageType>
124 m_sparseStorage->Multiply(in, out);
128template <
typename SparseStorageType>
132 m_sparseStorage->Multiply(in, out);
136template <
typename SparseStorageType>
140 sizeof(
unsigned long);
143template <
typename SparseStorageType>
146 return m_mulCallsCounter;
149template <
typename SparseStorageType>
151 SparseStorageType>::GetAvgRowDensity()
const
154 (
DataType)m_sparseStorage->GetRows();
157template <
typename SparseStorageType>
162 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
164 for (; entry != m_sparseStorage->end(); ++entry)
166 bandwidth = (std::max)(
168 2 *
std::abs((
int)(entry->first.first - entry->first.second + 1)));
173template <
typename SparseStorageType>
178 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
179 for (; entry != m_sparseStorage->end(); entry++)
181 (*coo)[std::make_pair(entry->first.first, entry->first.second)] =
194template <
typename SparseStorageType>
198 const int matRows = m_sparseStorage->GetRows();
199 const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
200 const int gridCols = gridRows;
202 std::vector<std::vector<int>> grid(gridRows);
203 for (
int row = 0; row < gridRows; row++)
205 grid[row].resize(gridCols, 0);
208 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
209 for (; entry != m_sparseStorage->end(); entry++)
211 const IndexType row = entry->first.first;
212 const IndexType col = entry->first.second;
213 const int gridRow = row / blockSize;
214 const int gridCol = col / blockSize;
215 grid[gridRow][gridCol]++;
218 for (
int row = 0; row < gridRows; row++)
220 for (
int col = 0; col < gridCols; col++)
222 out << grid[row][col] <<
" ";
234template <
typename SparseStorageType>
239 blockSize = (std::min)(blockSize, m_sparseStorage->GetRows());
240 std::vector<std::vector<int>> grid(blockSize);
241 for (
int row = 0; row < blockSize; row++)
243 grid[row].resize(blockSize, 0);
246 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
247 for (; entry != m_sparseStorage->end(); entry++)
249 const IndexType row = entry->first.first;
250 const IndexType col = entry->first.second;
252 if (blk_row != row / blockSize)
256 if (blk_col != col / blockSize)
260 grid[row % blockSize][col % blockSize]++;
263 for (
int row = 0; row < blockSize; row++)
265 for (
int col = 0; col < blockSize; col++)
267 out << grid[row][col] <<
" ";
void writeBlockSparsityPatternTo(std::ostream &out, 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...
unsigned long GetMulCallsCounter() const
NekSparseMatrix(const SparseStorageSharedPtr &sparseStoragePtr)
void Multiply(const DataVectorType &in, DataVectorType &out)
void writeSparsityPatternTo(std::ostream &out, IndexType blockSize=64)
IndexType GetRows() const
SparseStorageType::const_iterator begin() const
IndexType GetNumNonZeroEntries() const
size_t GetMemoryFootprint() const
SparseStorageType::DataType DataType
std::shared_ptr< SparseStorageType > SparseStorageSharedPtr
const DataType GetFillInRatio() const
COOMatTypeSharedPtr GetCooStorage()
SparseStorageType::const_iterator end() const
IndexType GetColumns() const
boost::call_traits< DataType >::const_reference operator()(const IndexType row, const IndexType column) const
std::shared_ptr< COOMatType > COOMatTypeSharedPtr
std::map< CoordType, NekDouble > COOMatType
scalarT< T > abs(scalarT< T > in)