54 template <
typename SparseStorageType>
57 : m_mulCallsCounter(0), m_sparseStorage(sparseStoragePtr)
61 template <
typename SparseStorageType>
63 : m_mulCallsCounter(src.m_mulCallsCounter),
64 m_sparseStorage(src.m_sparseStorage)
68 template <
typename SparseStorageType>
73 template <
typename SparseStorageType>
76 return m_sparseStorage->GetRows();
79 template <
typename SparseStorageType>
82 return m_sparseStorage->GetColumns();
85 template <
typename SparseStorageType>
88 return m_sparseStorage->GetNumNonZeroEntries();
91 template <
typename SparseStorageType>
93 SparseStorageType>::GetFillInRatio()
const
98 template <
typename SparseStorageType>
99 typename boost::call_traits<
100 typename SparseStorageType::DataType>::const_reference
102 unsigned int column)
const
104 return m_sparseStorage->GetValue(row, column);
107 template <
typename SparseStorageType>
109 SparseStorageType>::begin()
const
111 return m_sparseStorage->
begin();
114 template <
typename SparseStorageType>
116 SparseStorageType>::end()
const
118 return m_sparseStorage->
end();
121 template <
typename SparseStorageType>
125 m_sparseStorage->Multiply(in, out);
129 template <
typename SparseStorageType>
133 m_sparseStorage->Multiply(in, out);
137 template <
typename SparseStorageType>
141 sizeof(
unsigned long);
144 template <
typename SparseStorageType>
147 return m_mulCallsCounter;
150 template <
typename SparseStorageType>
152 SparseStorageType>::GetAvgRowDensity()
const
155 (
DataType)m_sparseStorage->GetRows();
158 template <
typename SparseStorageType>
163 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
165 for (; entry != m_sparseStorage->end(); ++entry)
167 bandwidth = (std::max)(
169 2 *
std::abs((
int)(entry->first.first - entry->first.second + 1)));
174 template <
typename SparseStorageType>
179 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
180 for (; entry != m_sparseStorage->end(); entry++)
182 (*coo)[std::make_pair(entry->first.first, entry->first.second)] =
195 template <
typename SparseStorageType>
199 const int matRows = m_sparseStorage->GetRows();
200 const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
201 const int gridCols = gridRows;
203 std::vector<std::vector<int>> grid(gridRows);
204 for (
int row = 0; row < gridRows; row++)
206 grid[row].resize(gridCols, 0);
209 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
210 for (; entry != m_sparseStorage->end(); entry++)
212 const IndexType row = entry->first.first;
213 const IndexType col = entry->first.second;
214 const int gridRow = row / blockSize;
215 const int gridCol = col / blockSize;
216 grid[gridRow][gridCol]++;
219 for (
int row = 0; row < gridRows; row++)
221 for (
int col = 0; col < gridCols; col++)
223 out << grid[row][col] <<
" ";
235 template <
typename SparseStorageType>
240 blockSize = (std::min)(blockSize, m_sparseStorage->GetRows());
241 std::vector<std::vector<int>> grid(blockSize);
242 for (
int row = 0; row < blockSize; row++)
244 grid[row].resize(blockSize, 0);
247 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
248 for (; entry != m_sparseStorage->end(); entry++)
250 const IndexType row = entry->first.first;
251 const IndexType col = entry->first.second;
253 if (blk_row != row / blockSize)
255 if (blk_col != col / blockSize)
257 grid[row % blockSize][col % blockSize]++;
260 for (
int row = 0; row < blockSize; row++)
262 for (
int col = 0; col < blockSize; col++)
264 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...
boost::call_traits< DataType >::const_reference operator()(const IndexType row, const IndexType column) const
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
The above copyright notice and this permission notice shall be included.
std::shared_ptr< COOMatType > COOMatTypeSharedPtr
std::map< CoordType, NekDouble > COOMatType
scalarT< T > abs(scalarT< T > in)