54 template<
typename SparseStorageType>
57 m_sparseStorage(sparseStoragePtr)
61 template<
typename SparseStorageType>
63 m_mulCallsCounter(src.m_mulCallsCounter),
64 m_sparseStorage(src.m_sparseStorage)
68 template<
typename SparseStorageType>
74 template<
typename SparseStorageType>
77 return m_sparseStorage->GetRows();
80 template<
typename SparseStorageType>
83 return m_sparseStorage->GetColumns();
86 template<
typename SparseStorageType>
89 return m_sparseStorage->GetNumNonZeroEntries();
93 template<
typename SparseStorageType>
96 return m_sparseStorage->GetFillInRatio();
101 template<
typename SparseStorageType>
104 return m_sparseStorage->GetValue(row, column);
107 template<
typename SparseStorageType>
110 return m_sparseStorage->begin();
113 template<
typename SparseStorageType>
116 return m_sparseStorage->end();
120 template<
typename SparseStorageType>
124 m_sparseStorage->Multiply(in,out);
128 template<
typename SparseStorageType>
132 m_sparseStorage->Multiply(in,out);
136 template<
typename SparseStorageType>
139 return m_sparseStorage->GetMemoryUsage() +
141 sizeof(
unsigned long);
144 template<
typename SparseStorageType>
147 return m_mulCallsCounter;
150 template<
typename SparseStorageType>
153 return (
DataType) m_sparseStorage->GetNumNonZeroEntries() /
154 (
DataType) m_sparseStorage->GetRows();
157 template<
typename SparseStorageType>
162 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
164 for (; entry != m_sparseStorage->end(); ++entry)
166 bandwidth = (std::max)(bandwidth, 2*
std::abs((
int)(entry->first.first - entry->first.second+1)));
171 template<
typename SparseStorageType>
176 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
177 for (; entry != m_sparseStorage->end(); entry++)
179 (*coo)[std::make_pair(entry->first.first, entry->first.second) ] = entry->second;
191 template<
typename SparseStorageType>
194 const int matRows = m_sparseStorage->GetRows();
195 const int gridRows = matRows / blockSize + (matRows % blockSize > 0);
196 const int gridCols = gridRows;
198 std::vector< std::vector<int> > grid (gridRows);
199 for (
int row = 0; row < gridRows; row++)
201 grid[row].resize(gridCols,0);
204 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
205 for (; entry != m_sparseStorage->end(); entry++)
207 const IndexType row = entry->first.first;
208 const IndexType col = entry->first.second;
209 const int gridRow = row / blockSize;
210 const int gridCol = col / blockSize;
211 grid[gridRow][gridCol]++;
214 for (
int row = 0; row < gridRows; row++)
216 for (
int col = 0; col < gridCols; col++)
218 out << grid[row][col] <<
" ";
230 template<
typename SparseStorageType>
234 blockSize = (std::min)(blockSize, m_sparseStorage->GetRows());
235 std::vector< std::vector<int> > grid (blockSize);
236 for (
int row = 0; row < blockSize; row++)
238 grid[row].resize(blockSize,0);
241 typename SparseStorageType::const_iterator entry = m_sparseStorage->begin();
242 for (; entry != m_sparseStorage->end(); entry++)
244 const IndexType row = entry->first.first;
245 const IndexType col = entry->first.second;
247 if (blk_row != row / blockSize )
continue;
248 if (blk_col != col / blockSize )
continue;
249 grid[row % blockSize][col % blockSize]++;
252 for (
int row = 0; row < blockSize; row++)
254 for (
int col = 0; col < blockSize; col++)
256 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
const DataType GetAvgRowDensity() 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)