Nektar++
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::StorageSmvBsr< T > Class Template Reference

#include <SparseMatrixFwd.hpp>

Classes

class  const_iterator
 

Public Types

typedef T DataType
 
typedef Array< OneD, DataTypeDataVectorType
 
typedef Array< OneD, const DataTypeConstDataVectorType
 
typedef Array< OneD, IndexTypeIndexVectorType
 
typedef void(* MultiplyKernel) (const double *, const double *, double *)
 

Public Member Functions

 StorageSmvBsr (const IndexType blkRows, const IndexType blkCols, const IndexType blkDim, const BCOMatType &bcoMat, const MatrixStorage matType=eFULL)
 
 StorageSmvBsr (const StorageSmvBsr &src)
 
 ~StorageSmvBsr ()
 
IndexType GetRows () const
 
IndexType GetColumns () const
 
IndexType GetNumNonZeroEntries () const
 
IndexType GetNumStoredDoubles () const
 
IndexType GetBlkSize () const
 
DataType GetFillInRatio () const
 
size_t GetMemoryUsage () const
 
const_iterator begin () const
 
const_iterator end () const
 
const DataTypeGetValue (IndexType row, IndexType column) const
 
void Multiply (const DataType *in, DataType *out)
 
void Multiply (const DataVectorType &in, DataVectorType &out)
 
void MultiplyLight (const DataVectorType &in, DataVectorType &out)
 

Protected Member Functions

void processBcoInput (const IndexType blkRows, const IndexType blkDim, const BCOMatType &bcoMat)
 
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.9b routine CSR_VecMult_CAB_double() More...
 
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 from NIST Sparse Blas 0.9b routine BSR_VecMult_BAB_double() More...
 
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. More...
 
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. More...
 
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. More...
 

Protected Attributes

MultiplyKernel m_mvKernel
 
MatrixStorage m_matType
 
IndexType m_blkRows
 
IndexType m_blkCols
 
IndexType m_blkDim
 
IndexType m_bnnz
 
IndexType m_nnz
 
DataVectorType m_val
 
IndexVectorType m_indx
 
IndexVectorType m_pntr
 

Detailed Description

template<typename T>
class Nektar::StorageSmvBsr< T >

Definition at line 70 of file SparseMatrixFwd.hpp.

Member Typedef Documentation

◆ ConstDataVectorType

template<typename T >
typedef Array<OneD, const DataType> Nektar::StorageSmvBsr< T >::ConstDataVectorType

Definition at line 69 of file StorageSmvBsr.hpp.

◆ DataType

template<typename T >
typedef T Nektar::StorageSmvBsr< T >::DataType

Definition at line 67 of file StorageSmvBsr.hpp.

◆ DataVectorType

template<typename T >
typedef Array<OneD, DataType> Nektar::StorageSmvBsr< T >::DataVectorType

Definition at line 68 of file StorageSmvBsr.hpp.

◆ IndexVectorType

template<typename T >
typedef Array<OneD, IndexType> Nektar::StorageSmvBsr< T >::IndexVectorType

Definition at line 70 of file StorageSmvBsr.hpp.

◆ MultiplyKernel

template<typename T >
typedef void(* Nektar::StorageSmvBsr< T >::MultiplyKernel) (const double *, const double *, double *)

Definition at line 72 of file StorageSmvBsr.hpp.

Constructor & Destructor Documentation

◆ StorageSmvBsr() [1/2]

template<typename DataType >
Nektar::StorageSmvBsr< DataType >::StorageSmvBsr ( const IndexType  blkRows,
const IndexType  blkCols,
const IndexType  blkDim,
const BCOMatType bcoMat,
const MatrixStorage  matType = eFULL 
)
Todo:
: - iterators over strictly lower-triangular part
  • number off-diagonal elements calculation
  • clear distinction between stored and factual nonzeros (row density)

Definition at line 214 of file StorageSmvBsr.cpp.

References Nektar::eFULL, and Nektar::StorageSmvBsr< T >::processBcoInput().

219  :
220  m_matType (matType),
221  m_blkRows (blkRows),
222  m_blkCols (blkCols),
223  m_blkDim (blkDim),
224  m_bnnz (bcoMat.size()),
225  m_nnz (0),
226  m_val (m_bnnz * blkDim*blkDim),
227  m_indx (m_bnnz+1),
228  m_pntr (blkRows+1)
229  {
230  if (matType != Nektar::eFULL)
231  {
232  /// \todo: - iterators over strictly lower-triangular part
233  /// - number off-diagonal elements calculation
234  /// - clear distinction between stored and factual nonzeros
235  /// (row density)
236  std::cout << "matrix type not implemented" << std::endl;
237  throw 1;
238  }
239 
240  processBcoInput(blkRows,blkDim,bcoMat);
241  }
IndexVectorType m_pntr
void processBcoInput(const IndexType blkRows, const IndexType blkDim, const BCOMatType &bcoMat)
IndexVectorType m_indx

◆ StorageSmvBsr() [2/2]

template<typename DataType >
Nektar::StorageSmvBsr< DataType >::StorageSmvBsr ( const StorageSmvBsr< T > &  src)

Definition at line 245 of file StorageSmvBsr.cpp.

245  :
246  m_matType(src.m_matType),
247  m_blkRows (src.m_blkRows),
248  m_blkCols (src.m_blkCols),
249  m_blkDim(src.m_blkDim),
250  m_bnnz(src.m_bnnz),
251  m_nnz(src.m_nnz),
252  m_val(src.m_val),
253  m_indx(src.m_indx),
254  m_pntr(src.m_pntr)
255  {
256  }
IndexVectorType m_pntr
IndexVectorType m_indx

◆ ~StorageSmvBsr()

template<typename DataType >
Nektar::StorageSmvBsr< DataType >::~StorageSmvBsr ( )

Definition at line 259 of file StorageSmvBsr.cpp.

260  {
261  }

Member Function Documentation

◆ begin()

template<typename DataType >
StorageSmvBsr< DataType >::const_iterator Nektar::StorageSmvBsr< DataType >::begin ( ) const

◆ end()

template<typename DataType >
StorageSmvBsr< DataType >::const_iterator Nektar::StorageSmvBsr< DataType >::end ( ) const

◆ GetBlkSize()

template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetBlkSize ( ) const

Definition at line 283 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_blkDim.

284  {
285  return m_blkDim;
286  }

◆ GetColumns()

template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetColumns ( ) const

Definition at line 271 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_blkCols, and Nektar::StorageSmvBsr< T >::m_blkDim.

272  {
273  return m_blkCols*m_blkDim;
274  }

◆ GetFillInRatio()

template<typename DataType >
DataType Nektar::StorageSmvBsr< DataType >::GetFillInRatio ( ) const

◆ GetMemoryUsage()

template<typename DataType >
size_t Nektar::StorageSmvBsr< DataType >::GetMemoryUsage ( ) const

Definition at line 303 of file StorageSmvBsr.cpp.

References Nektar::Array< OneD, const DataType >::capacity(), Nektar::StorageSmvBsr< T >::m_indx, Nektar::StorageSmvBsr< T >::m_pntr, and Nektar::StorageSmvBsr< T >::m_val.

304  {
305  return sizeof(DataType) *m_val.capacity() +
306  sizeof(IndexType)*m_indx.capacity() +
307  sizeof(IndexType)*m_pntr.capacity() +
308  sizeof(IndexType)*5 + //< blkRows + blkCols + blkDim + nnz + bnnz
309  sizeof(MatrixStorage);
310  }
IndexVectorType m_pntr
unsigned int IndexType
IndexVectorType m_indx

◆ GetNumNonZeroEntries()

template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetNumNonZeroEntries ( ) const

Definition at line 277 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_nnz.

278  {
279  return m_nnz;
280  }

◆ GetNumStoredDoubles()

template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetNumStoredDoubles ( ) const

◆ GetRows()

template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetRows ( ) const

Definition at line 265 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_blkDim, and Nektar::StorageSmvBsr< T >::m_blkRows.

266  {
267  return m_blkRows*m_blkDim;
268  }

◆ GetValue()

template<typename DataType >
const DataType & Nektar::StorageSmvBsr< DataType >::GetValue ( IndexType  row,
IndexType  column 
) const

Definition at line 314 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_blkDim, Nektar::StorageSmvBsr< T >::m_indx, Nektar::StorageSmvBsr< T >::m_pntr, and Nektar::StorageSmvBsr< T >::m_val.

315  {
316  IndexType brow = grow / m_blkDim;
317  IndexType bcol = gcolumn / m_blkDim;
318  IndexType lrow = grow % m_blkDim;
319  IndexType lcol = gcolumn % m_blkDim;
320 
321  // rewind to the first entry of the first
322  // block in the current block row
323  IndexType offset = m_pntr[brow]*m_blkDim*m_blkDim;
324 
325  IndexType i;
326  static DataType defaultReturnValue;
327  for( i = m_pntr[brow]; i < m_pntr[brow+1]; i++)
328  {
329  if(bcol == m_indx[i])
330  {
331  return m_val[offset+lrow + lcol*m_blkDim];
332  }
333  offset += m_blkDim*m_blkDim;
334  }
335 
336  return defaultReturnValue;
337  }
IndexVectorType m_pntr
unsigned int IndexType
IndexVectorType m_indx

◆ Multiply() [1/2]

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply ( const DataType in,
DataType out 
)

Definition at line 383 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_blkDim, Nektar::StorageSmvBsr< T >::m_blkRows, Nektar::StorageSmvBsr< T >::m_indx, Nektar::StorageSmvBsr< T >::m_pntr, Nektar::StorageSmvBsr< T >::m_val, Nektar::StorageSmvBsr< T >::Multiply_1x1(), Nektar::StorageSmvBsr< T >::Multiply_2x2(), and Nektar::StorageSmvBsr< T >::Multiply_generic().

386  {
387  const double* b = &in[0];
388  double* c = &out[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;
393  const int mb = m_blkRows;
394 
395  switch(m_blkDim)
396  {
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;
399  default:
400  {
401  Multiply_generic(mb,val,bindx,bpntrb,bpntre,b,c); return;
402  }
403  }
404  }
IndexVectorType m_pntr
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...
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...
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.
IndexVectorType m_indx

◆ Multiply() [2/2]

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply ( const DataVectorType in,
DataVectorType out 
)

Definition at line 358 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_blkDim, Nektar::StorageSmvBsr< T >::m_blkRows, Nektar::StorageSmvBsr< T >::m_indx, Nektar::StorageSmvBsr< T >::m_pntr, Nektar::StorageSmvBsr< T >::m_val, Nektar::StorageSmvBsr< T >::Multiply_1x1(), Nektar::StorageSmvBsr< T >::Multiply_2x2(), and Nektar::StorageSmvBsr< T >::Multiply_generic().

361  {
362  const double* b = &in[0];
363  double* c = &out[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;
368  const int mb = m_blkRows;
369 
370  switch(m_blkDim)
371  {
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;
374  default:
375  {
376  Multiply_generic(mb,val,bindx,bpntrb,bpntre,b,c); return;
377  }
378  }
379  }
IndexVectorType m_pntr
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...
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...
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.
IndexVectorType m_indx

◆ Multiply_1x1()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_1x1 ( const int  mb,
const double *  val,
const int *  bindx,
const int *  bpntrb,
const int *  bpntre,
const double *  b,
double *  c 
)
protected

Zero-based CSR multiply. Essentially this is slightly modified copy-paste from NIST Sparse Blas 0.9b routine CSR_VecMult_CAB_double()

Definition at line 437 of file StorageSmvBsr.cpp.

Referenced by Nektar::StorageSmvBsr< T >::Multiply(), and Nektar::StorageSmvBsr< T >::MultiplyLight().

445  {
446  for (int i=0;i!=mb;i++)
447  {
448  double t = 0;
449  int jb = bpntrb[i];
450  int je = bpntre[i];
451  for (int j=jb;j!=je;j++)
452  {
453  t += b[bindx[j]] * (*val++);
454  }
455  c[i] = t;
456  }
457  }

◆ Multiply_2x2()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_2x2 ( const int  mb,
const double *  val,
const int *  bindx,
const int *  bpntrb,
const int *  bpntre,
const double *  b,
double *  c 
)
protected

Zero-based BSR multiply unrolled for 2x2 blocks. Essentially this is slightly optimised copy-paste from NIST Sparse Blas 0.9b routine BSR_VecMult_BAB_double()

Definition at line 463 of file StorageSmvBsr.cpp.

Referenced by Nektar::StorageSmvBsr< T >::Multiply(), and Nektar::StorageSmvBsr< T >::MultiplyLight().

471  {
472  const int lb = 2;
473 
474  const double *pval = val;
475  double *pc=c;
476 
477  for (int i=0;i!=mb;i++)
478  {
479  int jb = bpntrb[i];
480  int je = bpntre[i];
481  pc[0] = 0;
482  pc[1] = 0;
483  for (int j=jb;j!=je;j++)
484  {
485  int bs=bindx[j]*lb;
486  const double *pb = &b[bs];
487 
488  pc[0] += pb[0] * pval[0] + pb[1] * pval[2];
489  pc[1] += pb[0] * pval[1] + pb[1] * pval[3];
490  pval += 4;
491  }
492  pc += 2;
493  }
494  }

◆ Multiply_3x3()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_3x3 ( const int  mb,
const double *  val,
const int *  bindx,
const int *  bpntrb,
const int *  bpntre,
const double *  b,
double *  c 
)
protected

Zero-based BSR multiply unrolled for 3x3 blocks.

Definition at line 498 of file StorageSmvBsr.cpp.

506  {
507  const int lb = 3;
508 
509  const double *pval = val;
510  double *pc=c;
511 
512  for (int i=0;i!=mb;i++)
513  {
514  int jb = bpntrb[i];
515  int je = bpntre[i];
516  pc[0] = 0;
517  pc[1] = 0;
518  pc[2] = 0;
519  for (int j=jb;j!=je;j++)
520  {
521  int bs=bindx[j]*lb;
522  const double *pb = &b[bs];
523 
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];
527  pval += 9;
528  }
529  pc += 3;
530  }
531  }

◆ Multiply_4x4()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_4x4 ( const int  mb,
const double *  val,
const int *  bindx,
const int *  bpntrb,
const int *  bpntre,
const double *  b,
double *  c 
)
protected

Zero-based BSR multiply unrolled for 4x4 blocks.

Definition at line 535 of file StorageSmvBsr.cpp.

543  {
544  const int lb = 4;
545 
546  const double *pval = val;
547  double *pc=c;
548 
549  for (int i=0;i!=mb;i++)
550  {
551  int jb = bpntrb[i];
552  int je = bpntre[i];
553  pc[0] = 0;
554  pc[1] = 0;
555  pc[2] = 0;
556  pc[3] = 0;
557  for (int j=jb;j!=je;j++)
558  {
559  int bs=bindx[j]*lb;
560  const double *pb = &b[bs];
561 
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];
566  pval += 16;
567  }
568  pc += 4;
569  }
570  }

◆ Multiply_generic()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_generic ( const int  mb,
const double *  val,
const int *  bindx,
const int *  bpntrb,
const int *  bpntre,
const double *  b,
double *  c 
)
protected

Generic zero-based BSR multiply for higher matrix ranks.

Definition at line 574 of file StorageSmvBsr.cpp.

References Blas::Dgemv(), and Nektar::StorageSmvBsr< T >::m_blkDim.

Referenced by Nektar::StorageSmvBsr< T >::Multiply(), and Nektar::StorageSmvBsr< T >::MultiplyLight().

582  {
583  const int lb = m_blkDim;
584  const double *pval = val;
585  const int mm=lb*lb;
586  double *pc=c;
587  for (int i=0;i!=mb*lb;i++) *pc++ = 0;
588 
589  pc=c;
590  for (int i=0;i!=mb;i++)
591  {
592  int jb = bpntrb[i];
593  int je = bpntre[i];
594  for (int j=jb;j!=je;j++)
595  {
596  Blas::Dgemv('N',lb,lb,1.0,pval,lb,&b[bindx[j]*lb],1,1.0,pc,1);
597  pval+=mm;
598  }
599  pc += lb;
600  }
601  }
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].
Definition: Blas.hpp:168

◆ MultiplyLight()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::MultiplyLight ( const DataVectorType in,
DataVectorType out 
)

Definition at line 410 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::m_blkDim, Nektar::StorageSmvBsr< T >::m_blkRows, Nektar::StorageSmvBsr< T >::m_indx, Nektar::StorageSmvBsr< T >::m_pntr, Nektar::StorageSmvBsr< T >::m_val, Nektar::StorageSmvBsr< T >::Multiply_1x1(), Nektar::StorageSmvBsr< T >::Multiply_2x2(), and Nektar::StorageSmvBsr< T >::Multiply_generic().

413  {
414  const double* b = &in[0];
415  double* c = &out[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;
420  const int mb = m_blkRows;
421 
422  switch(m_blkDim)
423  {
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;
426  default:
427  {
428  Multiply_generic(mb,val,bindx,bpntrb,bpntre,b,c); return;
429  }
430  }
431  }
IndexVectorType m_pntr
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...
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...
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.
IndexVectorType m_indx

◆ processBcoInput()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::processBcoInput ( const IndexType  blkRows,
const IndexType  blkDim,
const BCOMatType bcoMat 
)
protected

Definition at line 608 of file StorageSmvBsr.cpp.

References CellMLToNektar.pycml::copy(), Nektar::NekConstants::kNekSparseNonZeroTol, Nektar::StorageSmvBsr< T >::m_indx, Nektar::StorageSmvBsr< T >::m_nnz, Nektar::StorageSmvBsr< T >::m_pntr, and Nektar::StorageSmvBsr< T >::m_val.

Referenced by Nektar::StorageSmvBsr< T >::StorageSmvBsr().

612  {
613  IndexType i;
614  BCOMatTypeConstIt entry;
615  IndexType rowcoord;
616  IndexType colcoord;
617  BCOEntryType value;
618 
619  std::vector<IndexType> tmp(blkRows+1,0);
620 
621  // calculate the number of entries on each row
622  // and store the result in tmp
623  for(entry = bcoMat.begin(); entry != bcoMat.end(); entry++)
624  {
625  rowcoord = (entry->first).first;
626  tmp[rowcoord]++;
627  }
628  // Based upon this information, fill the array m_pntr
629  // which basically contains the offset of each row's
630  // first entry in the other arrays m_val and m_indx
631  m_pntr[0] = 0;
632  for(i = 0; i < blkRows; i++)
633  {
634  m_pntr[i+1] = m_pntr[i] + tmp[i];
635  }
636 
637  // Copy the values of m_pntr into tmp as this will be needed
638  // in the following step
639  std::copy(&m_pntr[0],&m_pntr[0]+blkRows+1,&tmp[0]);
640 
641  // Now, fill in index and value entries.
642  for(entry = bcoMat.begin(); entry != bcoMat.end(); entry++)
643  {
644  rowcoord = (entry->first).first;
645  colcoord = (entry->first).second;
646  value = entry->second;
647  int blkSize = blkDim*blkDim;
648 
649  for (i = 0; i < blkSize; i++)
650  {
651  m_val [ blkSize*(tmp[rowcoord]) + i ] = value[i];
652  if (std::abs(value[i]) > NekConstants::kNekSparseNonZeroTol) m_nnz++;
653  }
654 
655  m_indx[ tmp[rowcoord] ] = colcoord;
656  tmp[rowcoord]++;
657  }
658  }
IndexVectorType m_pntr
def copy(self)
Definition: pycml.py:2663
BCOMatType::const_iterator BCOMatTypeConstIt
Array< OneD, NekDouble > BCOEntryType
unsigned int IndexType
static const NekDouble kNekSparseNonZeroTol
IndexVectorType m_indx

Member Data Documentation

◆ m_blkCols

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::m_blkCols
protected

Definition at line 195 of file StorageSmvBsr.hpp.

Referenced by Nektar::StorageSmvBsr< T >::GetColumns().

◆ m_blkDim

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::m_blkDim
protected

◆ m_blkRows

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::m_blkRows
protected

◆ m_bnnz

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::m_bnnz
protected

◆ m_indx

template<typename T >
IndexVectorType Nektar::StorageSmvBsr< T >::m_indx
protected

◆ m_matType

template<typename T >
MatrixStorage Nektar::StorageSmvBsr< T >::m_matType
protected

◆ m_mvKernel

template<typename T >
MultiplyKernel Nektar::StorageSmvBsr< T >::m_mvKernel
protected

Definition at line 190 of file StorageSmvBsr.hpp.

◆ m_nnz

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::m_nnz
protected

◆ m_pntr

template<typename T >
IndexVectorType Nektar::StorageSmvBsr< T >::m_pntr
protected

◆ m_val

template<typename T >
DataVectorType Nektar::StorageSmvBsr< T >::m_val
protected