50 template<
typename DataType>
91 std::cout <<
"const_iterator: 'begin' out stored values bounds" << std::endl;
103 template<
typename DataType>
109 const IndexType block = storageIndex / elms;
110 const IndexType loc_offset = storageIndex % elms;
118 while(block >=
m_pntr[block_row+1])
126 coord.first = block_row*m_blkDim + loc_row;
127 coord.second = block_col*m_blkDim + loc_col;
132 template<
typename DataType>
144 template<
typename DataType>
149 template<
typename DataType>
157 template<
typename DataType>
164 template<
typename DataType>
170 template<
typename DataType>
176 template<
typename DataType>
182 template<
typename DataType>
188 template<
typename DataType>
213 template<
typename DataType>
236 std::cout <<
"matrix type not implemented" << std::endl;
244 template<
typename DataType>
258 template<
typename DataType>
264 template<
typename DataType>
270 template<
typename DataType>
276 template<
typename DataType>
282 template<
typename DataType>
289 template<
typename DataType>
295 template<
typename DataType>
302 template<
typename DataType>
313 template<
typename DataType>
336 return defaultReturnValue;
340 template<
typename DataType>
346 template<
typename DataType>
357 template<
typename DataType>
362 const double* b = &in[0];
364 const double* val = &
m_val[0];
365 const int* bindx = (
int*)&
m_indx[0];
366 const int* bpntrb = (
int*)&
m_pntr[0];
367 const int* bpntre = (
int*)&
m_pntr[0]+1;
372 case 1:
Multiply_1x1(mb,val,bindx,bpntrb,bpntre,b,c);
return;
373 case 2:
Multiply_2x2(mb,val,bindx,bpntrb,bpntre,b,c);
return;
382 template<
typename DataType>
387 const double* b = &in[0];
389 const double* val = &
m_val[0];
390 const int* bindx = (
int*)&
m_indx[0];
391 const int* bpntrb = (
int*)&
m_pntr[0];
392 const int* bpntre = (
int*)&
m_pntr[0]+1;
397 case 1:
Multiply_1x1(mb,val,bindx,bpntrb,bpntre,b,c);
return;
398 case 2:
Multiply_2x2(mb,val,bindx,bpntrb,bpntre,b,c);
return;
409 template<
typename DataType>
414 const double* b = &in[0];
416 const double* val = &
m_val[0];
417 const int* bindx = (
int*)&
m_indx[0];
418 const int* bpntrb = (
int*)&
m_pntr[0];
419 const int* bpntre = (
int*)&
m_pntr[0]+1;
424 case 1:
Multiply_1x1(mb,val,bindx,bpntrb,bpntre,b,c);
return;
425 case 2:
Multiply_2x2(mb,val,bindx,bpntrb,bpntre,b,c);
return;
436 template<
typename DataType>
446 for (
int i=0;i!=mb;i++)
451 for (
int j=jb;j!=je;j++)
453 t += b[bindx[j]] * (*val++);
462 template<
typename DataType>
474 const double *pval = val;
477 for (
int i=0;i!=mb;i++)
483 for (
int j=jb;j!=je;j++)
486 const double *pb = &b[bs];
488 pc[0] += pb[0] * pval[0] + pb[1] * pval[2];
489 pc[1] += pb[0] * pval[1] + pb[1] * pval[3];
497 template<
typename DataType>
509 const double *pval = val;
512 for (
int i=0;i!=mb;i++)
519 for (
int j=jb;j!=je;j++)
522 const double *pb = &b[bs];
524 pc[0] += pb[0] * pval[0] + pb[1] * pval[3] + pb[2] * pval[6];
525 pc[1] += pb[0] * pval[1] + pb[1] * pval[4] + pb[2] * pval[7];
526 pc[2] += pb[0] * pval[2] + pb[1] * pval[5] + pb[2] * pval[8];
534 template<
typename DataType>
546 const double *pval = val;
549 for (
int i=0;i!=mb;i++)
557 for (
int j=jb;j!=je;j++)
560 const double *pb = &b[bs];
562 pc[0] += pb[0] * pval[0] + pb[1] * pval[4] + pb[2] * pval[ 8] + pb[3] * pval[12];
563 pc[1] += pb[0] * pval[1] + pb[1] * pval[5] + pb[2] * pval[ 9] + pb[3] * pval[13];
564 pc[2] += pb[0] * pval[2] + pb[1] * pval[6] + pb[2] * pval[10] + pb[3] * pval[14];
565 pc[3] += pb[0] * pval[3] + pb[1] * pval[7] + pb[2] * pval[11] + pb[3] * pval[15];
573 template<
typename DataType>
584 const double *pval = val;
587 for (
int i=0;i!=mb*lb;i++) *pc++ = 0;
590 for (
int i=0;i!=mb;i++)
594 for (
int j=jb;j!=je;j++)
596 Blas::Dgemv(
'N',lb,lb,1.0,pval,lb,&b[bindx[j]*lb],1,1.0,pc,1);
607 template<
typename DataType>
619 std::vector<IndexType> tmp(blkRows+1,0);
623 for(entry = bcoMat.begin(); entry != bcoMat.end(); entry++)
625 rowcoord = (entry->first).first;
632 for(i = 0; i < blkRows; i++)
642 for(entry = bcoMat.begin(); entry != bcoMat.end(); entry++)
644 rowcoord = (entry->first).first;
645 colcoord = (entry->first).second;
646 value = entry->second;
647 int blkSize = blkDim*blkDim;
649 for (i = 0; i < blkSize; i++)
651 m_val [ blkSize*(tmp[rowcoord]) + i ] = value[i];
655 m_indx[ tmp[rowcoord] ] = colcoord;
void Multiply_1x1(const int mb, const double *val, const int *bindx, const int *bpntrb, const int *bpntre, const double *b, double *c)
Zero-based CSR multiply. Essentially this is slightly modified copy-paste from NIST Sparse Blas 0...
const IterType & operator*()
const DataVectorType & m_val
IndexType GetBlkSize() const
void MultiplyLight(const DataVectorType &in, DataVectorType &out)
const DataType & GetValue(IndexType row, IndexType column) const
DataType GetFillInRatio() const
const IndexVectorType & m_pntr
bool operator==(const const_iterator &rhs)
const_iterator & operator++()
BCOMatType::const_iterator BCOMatTypeConstIt
void Multiply_2x2(const int mb, const double *val, const int *bindx, const int *bpntrb, const int *bpntre, const double *b, double *c)
Zero-based BSR multiply unrolled for 2x2 blocks. Essentially this is slightly optimised copy-paste fr...
IndexType GetColumns() const
const_iterator begin() const
void Multiply_3x3(const int mb, const double *val, const int *bindx, const int *bpntrb, const int *bpntre, const double *b, double *c)
Zero-based BSR multiply unrolled for 3x3 blocks.
void processBcoInput(const IndexType blkRows, const IndexType blkDim, const BCOMatType &bcoMat)
const IterType * operator->()
std::map< CoordType, BCOEntryType > BCOMatType
IndexType GetRows() const
void Multiply_generic(const int mb, const double *val, const int *bindx, const int *bpntrb, const int *bpntre, const double *b, double *c)
Generic zero-based BSR multiply for higher matrix ranks.
static void Dgemv(const char &trans, const int &m, const int &n, const double &alpha, const double *a, const int &lda, const double *x, const int &incx, const double &beta, double *y, const int &incy)
BLAS level 2: Matrix vector multiply y = A x where A[m x n].
void Multiply_4x4(const int mb, const double *val, const int *bindx, const int *bpntrb, const int *bpntre, const double *b, double *c)
Zero-based BSR multiply unrolled for 4x4 blocks.
IndexType GetNumNonZeroEntries() const
const IndexVectorType & m_indx
CoordType storageIndexToFullCoord(IndexType storageIndex)
const_iterator(MatrixStorage matType, IndexType begin, IndexType end, IndexType blkDim, const DataVectorType &val, const IndexVectorType &indx, const IndexVectorType &pntr)
static const NekDouble kNekSparseNonZeroTol
bool operator!=(const const_iterator &rhs)
void Multiply(const DataType *in, DataType *out)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
size_t GetMemoryUsage() const
size_t num_elements() const
Returns the array's size.
IndexType GetNumStoredDoubles() const
const_iterator end() const
std::pair< IndexType, IndexType > CoordType
StorageSmvBsr(const IndexType blkRows, const IndexType blkCols, const IndexType blkDim, const BCOMatType &bcoMat, const MatrixStorage matType=eFULL)