Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::StorageSmvBsr< T > Class Template Reference

#include <SparseMatrixFwd.hpp>

Collaboration diagram for Nektar::StorageSmvBsr< T >:
Collaboration graph
[legend]

Classes

class  const_iterator
 

Public Types

typedef T DataType
 
typedef Array< OneD, DataTypeDataVectorType
 
typedef Array< OneD, const
DataType
ConstDataVectorType
 
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 (IndexType nnz, IndexType nRows) const
 
const_iterator begin () const
 
const_iterator end () const
 
const boost::call_traits
< DataType >::const_reference 
GetValue (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 blkColumns, const IndexType blkDim, const BCOMatType &bcoMat)
 
void Multiply_1x1 (const int mb, const int kb, 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 int kb, 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 int kb, 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 int kb, 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 int kb, 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 71 of file SparseMatrixFwd.hpp.

Member Typedef Documentation

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

Definition at line 76 of file StorageSmvBsr.hpp.

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

Definition at line 74 of file StorageSmvBsr.hpp.

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

Definition at line 75 of file StorageSmvBsr.hpp.

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

Definition at line 77 of file StorageSmvBsr.hpp.

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

Definition at line 79 of file StorageSmvBsr.hpp.

Constructor & Destructor Documentation

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 220 of file StorageSmvBsr.cpp.

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

225  :
226  m_matType (matType),
227  m_blkRows (blkRows),
228  m_blkCols (blkCols),
229  m_blkDim (blkDim),
230  m_bnnz (bcoMat.size()),
231  m_nnz (0),
232  m_val (m_bnnz * blkDim*blkDim),
233  m_indx (m_bnnz+1),
234  m_pntr (blkRows+1)
235  {
236  if (matType != Nektar::eFULL)
237  {
238  /// \todo: - iterators over strictly lower-triangular part
239  /// - number off-diagonal elements calculation
240  /// - clear distinction between stored and factual nonzeros
241  /// (row density)
242  std::cout << "matrix type not implemented" << std::endl;
243  throw 1;
244  }
245 
246 #ifdef NEKTAR_USING_SMV
247  // Set pointer to rank-specific matrix-vector multiply kernel.
248  // Number of ranks is defined by LibSMV library
249  switch (blkDim)
250  {
251  #define BOOST_PP_LOCAL_MACRO(n) case n: m_mvKernel = Smv::F77NAME(smv_##n); break;
252  #define BOOST_PP_LOCAL_LIMITS (1, LIBSMV_MAX_RANK)
253  #include BOOST_PP_LOCAL_ITERATE()
254  }
255 #endif
256 
257  processBcoInput(blkRows,blkCols,blkDim,bcoMat);
258  }
IndexVectorType m_indx
void processBcoInput(const IndexType blkRows, const IndexType blkColumns, const IndexType blkDim, const BCOMatType &bcoMat)
IndexVectorType m_pntr
template<typename DataType >
Nektar::StorageSmvBsr< DataType >::StorageSmvBsr ( const StorageSmvBsr< T > &  src)

Definition at line 262 of file StorageSmvBsr.cpp.

262  :
263  m_matType(src.m_matType),
264  m_blkRows (src.m_blkRows),
265  m_blkCols (src.m_blkCols),
266  m_blkDim(src.m_blkDim),
267  m_bnnz(src.m_bnnz),
268  m_nnz(src.m_nnz),
269  m_val(src.m_val),
270  m_indx(src.m_indx),
271  m_pntr(src.m_pntr)
272  {
273  }
IndexVectorType m_indx
IndexVectorType m_pntr
template<typename DataType >
Nektar::StorageSmvBsr< DataType >::~StorageSmvBsr ( )

Definition at line 276 of file StorageSmvBsr.cpp.

277  {
278  }

Member Function Documentation

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

Definition at line 358 of file StorageSmvBsr.cpp.

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

359  {
360  return const_iterator(m_matType, 0, m_nnz, m_blkDim, m_val, m_indx, m_pntr);
361  }
IndexVectorType m_indx
IndexVectorType m_pntr
template<typename DataType >
StorageSmvBsr< DataType >::const_iterator Nektar::StorageSmvBsr< DataType >::end ( ) const

Definition at line 364 of file StorageSmvBsr.cpp.

365  {
366  return const_iterator(m_matType, m_nnz, m_nnz, m_blkDim, m_val, m_indx, m_pntr);
367  }
IndexVectorType m_indx
IndexVectorType m_pntr
template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetBlkSize ( ) const

Definition at line 300 of file StorageSmvBsr.cpp.

301  {
302  return m_blkDim;
303  }
template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetColumns ( ) const

Definition at line 288 of file StorageSmvBsr.cpp.

289  {
290  return m_blkCols*m_blkDim;
291  }
template<typename DataType >
DataType Nektar::StorageSmvBsr< DataType >::GetFillInRatio ( ) const

Definition at line 313 of file StorageSmvBsr.cpp.

template<typename DataType >
size_t Nektar::StorageSmvBsr< DataType >::GetMemoryUsage ( IndexType  nnz,
IndexType  nRows 
) const

Definition at line 320 of file StorageSmvBsr.cpp.

321  {
322  return sizeof(DataType) *m_val.capacity() +
323  sizeof(IndexType)*m_indx.capacity() +
324  sizeof(IndexType)*m_pntr.capacity() +
325  sizeof(IndexType)*5 + //< blkRows + blkCols + blkDim + nnz + bnnz
326  sizeof(MatrixStorage);
327  }
IndexVectorType m_indx
unsigned int IndexType
IndexVectorType m_pntr
template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetNumNonZeroEntries ( ) const

Definition at line 294 of file StorageSmvBsr.cpp.

295  {
296  return m_nnz;
297  }
template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetNumStoredDoubles ( ) const

Definition at line 307 of file StorageSmvBsr.cpp.

308  {
309  return m_bnnz*m_blkDim*m_blkDim;
310  }
template<typename DataType >
IndexType Nektar::StorageSmvBsr< DataType >::GetRows ( ) const

Definition at line 282 of file StorageSmvBsr.cpp.

283  {
284  return m_blkRows*m_blkDim;
285  }
template<typename DataType >
const boost::call_traits< DataType >::const_reference Nektar::StorageSmvBsr< DataType >::GetValue ( IndexType  row,
IndexType  column 
) const

Definition at line 331 of file StorageSmvBsr.cpp.

332  {
333  IndexType brow = grow / m_blkDim;
334  IndexType bcol = gcolumn / m_blkDim;
335  IndexType lrow = grow % m_blkDim;
336  IndexType lcol = gcolumn % m_blkDim;
337 
338  // rewind to the first entry of the first
339  // block in the current block row
340  IndexType offset = m_pntr[brow]*m_blkDim*m_blkDim;
341 
342  IndexType i;
343  static DataType defaultReturnValue;
344  for( i = m_pntr[brow]; i < m_pntr[brow+1]; i++)
345  {
346  if(bcol == m_indx[i])
347  {
348  return m_val[offset+lrow + lcol*m_blkDim];
349  }
350  offset += m_blkDim*m_blkDim;
351  }
352 
353  return defaultReturnValue;
354  }
IndexVectorType m_indx
unsigned int IndexType
IndexVectorType m_pntr
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply ( const DataType in,
DataType out 
)

Definition at line 412 of file StorageSmvBsr.cpp.

415  {
416  const double* b = &in[0];
417  double* c = &out[0];
418  const double* val = &m_val[0];
419  const int* bindx = (int*)&m_indx[0];
420  const int* bpntrb = (int*)&m_pntr[0];
421  const int* bpntre = (int*)&m_pntr[0]+1;
422  const int mb = m_blkRows;
423  const int kb = m_blkCols;
424 
425  switch(m_blkDim)
426  {
427  case 1: Multiply_1x1(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
428  case 2: Multiply_2x2(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
429 #ifndef NEKTAR_USING_SMV
430  case 3: Multiply_3x3(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
431  case 4: Multiply_4x4(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
432 #endif
433  default:
434 #ifdef NEKTAR_USING_SMV
435  if (m_blkDim <= LIBSMV_MAX_RANK)
436  {
437  Multiply_libsmv(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
438  }
439  else
440 #endif
441  {
442  Multiply_generic(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
443  }
444  }
445  }
IndexVectorType m_indx
void Multiply_1x1(const int mb, const int kb, 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_4x4(const int mb, const int kb, 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.
void Multiply_2x2(const int mb, const int kb, 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...
IndexVectorType m_pntr
void Multiply_generic(const int mb, const int kb, 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.
void Multiply_3x3(const int mb, const int kb, 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.
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply ( const DataVectorType in,
DataVectorType out 
)

Definition at line 375 of file StorageSmvBsr.cpp.

378  {
379  const double* b = &in[0];
380  double* c = &out[0];
381  const double* val = &m_val[0];
382  const int* bindx = (int*)&m_indx[0];
383  const int* bpntrb = (int*)&m_pntr[0];
384  const int* bpntre = (int*)&m_pntr[0]+1;
385  const int mb = m_blkRows;
386  const int kb = m_blkCols;
387 
388  switch(m_blkDim)
389  {
390  case 1: Multiply_1x1(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
391  case 2: Multiply_2x2(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
392 #ifndef NEKTAR_USING_SMV
393  case 3: Multiply_3x3(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
394  case 4: Multiply_4x4(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
395 #endif
396  default:
397 #ifdef NEKTAR_USING_SMV
398  if (m_blkDim <= LIBSMV_MAX_RANK)
399  {
400  Multiply_libsmv(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
401  }
402  else
403 #endif
404  {
405  Multiply_generic(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
406  }
407  }
408  }
IndexVectorType m_indx
void Multiply_1x1(const int mb, const int kb, 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_4x4(const int mb, const int kb, 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.
void Multiply_2x2(const int mb, const int kb, 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...
IndexVectorType m_pntr
void Multiply_generic(const int mb, const int kb, 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.
void Multiply_3x3(const int mb, const int kb, 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.
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_1x1 ( const int  mb,
const int  kb,
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 490 of file StorageSmvBsr.cpp.

499  {
500  for (int i=0;i!=mb;i++)
501  {
502  double t = 0;
503  int jb = bpntrb[i];
504  int je = bpntre[i];
505  for (int j=jb;j!=je;j++)
506  {
507  t += b[bindx[j]] * (*val++);
508  }
509  c[i] = t;
510  }
511  }
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_2x2 ( const int  mb,
const int  kb,
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 517 of file StorageSmvBsr.cpp.

526  {
527  const int lb = 2;
528 
529  const double *pval = val;
530  double *pc=c;
531 
532  for (int i=0;i!=mb;i++)
533  {
534  int jb = bpntrb[i];
535  int je = bpntre[i];
536  pc[0] = 0;
537  pc[1] = 0;
538  for (int j=jb;j!=je;j++)
539  {
540  int bs=bindx[j]*lb;
541  const double *pb = &b[bs];
542 
543  pc[0] += pb[0] * pval[0] + pb[1] * pval[2];
544  pc[1] += pb[0] * pval[1] + pb[1] * pval[3];
545  pval += 4;
546  }
547  pc += 2;
548  }
549  }
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_3x3 ( const int  mb,
const int  kb,
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 553 of file StorageSmvBsr.cpp.

562  {
563  const int lb = 3;
564 
565  const double *pval = val;
566  double *pc=c;
567 
568  for (int i=0;i!=mb;i++)
569  {
570  int jb = bpntrb[i];
571  int je = bpntre[i];
572  pc[0] = 0;
573  pc[1] = 0;
574  pc[2] = 0;
575  for (int j=jb;j!=je;j++)
576  {
577  int bs=bindx[j]*lb;
578  const double *pb = &b[bs];
579 
580  pc[0] += pb[0] * pval[0] + pb[1] * pval[3] + pb[2] * pval[6];
581  pc[1] += pb[0] * pval[1] + pb[1] * pval[4] + pb[2] * pval[7];
582  pc[2] += pb[0] * pval[2] + pb[1] * pval[5] + pb[2] * pval[8];
583  pval += 9;
584  }
585  pc += 3;
586  }
587  }
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_4x4 ( const int  mb,
const int  kb,
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 591 of file StorageSmvBsr.cpp.

600  {
601  const int lb = 4;
602 
603  const double *pval = val;
604  double *pc=c;
605 
606  for (int i=0;i!=mb;i++)
607  {
608  int jb = bpntrb[i];
609  int je = bpntre[i];
610  pc[0] = 0;
611  pc[1] = 0;
612  pc[2] = 0;
613  pc[3] = 0;
614  for (int j=jb;j!=je;j++)
615  {
616  int bs=bindx[j]*lb;
617  const double *pb = &b[bs];
618 
619  pc[0] += pb[0] * pval[0] + pb[1] * pval[4] + pb[2] * pval[ 8] + pb[3] * pval[12];
620  pc[1] += pb[0] * pval[1] + pb[1] * pval[5] + pb[2] * pval[ 9] + pb[3] * pval[13];
621  pc[2] += pb[0] * pval[2] + pb[1] * pval[6] + pb[2] * pval[10] + pb[3] * pval[14];
622  pc[3] += pb[0] * pval[3] + pb[1] * pval[7] + pb[2] * pval[11] + pb[3] * pval[15];
623  pval += 16;
624  }
625  pc += 4;
626  }
627  }
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::Multiply_generic ( const int  mb,
const int  kb,
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 667 of file StorageSmvBsr.cpp.

676  {
677  const int lb = m_blkDim;
678  const double *pval = val;
679  const int mm=lb*lb;
680  double *pc=c;
681  for (int i=0;i!=mb*lb;i++) *pc++ = 0;
682 
683  pc=c;
684  for (int i=0;i!=mb;i++)
685  {
686  int jb = bpntrb[i];
687  int je = bpntre[i];
688  for (int j=jb;j!=je;j++)
689  {
690  Blas::Dgemv('N',lb,lb,1.0,pval,lb,&b[bindx[j]*lb],1,1.0,pc,1);
691  pval+=mm;
692  }
693  pc += lb;
694  }
695  }
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::MultiplyLight ( const DataVectorType in,
DataVectorType out 
)

Definition at line 451 of file StorageSmvBsr.cpp.

454  {
455  const double* b = &in[0];
456  double* c = &out[0];
457  const double* val = &m_val[0];
458  const int* bindx = (int*)&m_indx[0];
459  const int* bpntrb = (int*)&m_pntr[0];
460  const int* bpntre = (int*)&m_pntr[0]+1;
461  const int mb = m_blkRows;
462  const int kb = m_blkCols;
463 
464  switch(m_blkDim)
465  {
466  case 1: Multiply_1x1(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
467  case 2: Multiply_2x2(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
468 #ifndef NEKTAR_USING_SMV
469  case 3: Multiply_3x3(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
470  case 4: Multiply_4x4(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
471 #endif
472  default:
473 #ifdef NEKTAR_USING_SMV
474  if (m_blkDim <= LIBSMV_MAX_RANK)
475  {
476  Multiply_libsmv(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
477  }
478  else
479 #endif
480  {
481  Multiply_generic(mb,kb,val,bindx,bpntrb,bpntre,b,c); return;
482  }
483  }
484  }
IndexVectorType m_indx
void Multiply_1x1(const int mb, const int kb, 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_4x4(const int mb, const int kb, 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.
void Multiply_2x2(const int mb, const int kb, 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...
IndexVectorType m_pntr
void Multiply_generic(const int mb, const int kb, 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.
void Multiply_3x3(const int mb, const int kb, 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.
template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::processBcoInput ( const IndexType  blkRows,
const IndexType  blkColumns,
const IndexType  blkDim,
const BCOMatType bcoMat 
)
protected

Definition at line 702 of file StorageSmvBsr.cpp.

References CellMLToNektar.pycml::copy(), and Nektar::NekConstants::kNekSparseNonZeroTol.

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

707  {
708  IndexType i;
709  BCOMatTypeConstIt entry;
710  IndexType rowcoord;
711  IndexType colcoord;
712  BCOEntryType value;
713 
714  std::vector<IndexType> tmp(blkRows+1,0);
715 
716  // calculate the number of entries on each row
717  // and store the result in tmp
718  for(entry = bcoMat.begin(); entry != bcoMat.end(); entry++)
719  {
720  rowcoord = (entry->first).first;
721  tmp[rowcoord]++;
722  }
723  // Based upon this information, fill the array m_pntr
724  // which basically contains the offset of each row's
725  // first entry in the other arrays m_val and m_indx
726  m_pntr[0] = 0;
727  for(i = 0; i < blkRows; i++)
728  {
729  m_pntr[i+1] = m_pntr[i] + tmp[i];
730  }
731 
732  // Copy the values of m_pntr into tmp as this will be needed
733  // in the following step
734  std::copy(&m_pntr[0],&m_pntr[0]+blkRows+1,&tmp[0]);
735 
736  // Now, fill in index and value entries.
737  for(entry = bcoMat.begin(); entry != bcoMat.end(); entry++)
738  {
739  rowcoord = (entry->first).first;
740  colcoord = (entry->first).second;
741  value = entry->second;
742  int blkSize = blkDim*blkDim;
743 
744  for (i = 0; i < blkSize; i++)
745  {
746  m_val [ blkSize*(tmp[rowcoord]) + i ] = value[i];
747  if (std::abs(value[i]) > NekConstants::kNekSparseNonZeroTol) m_nnz++;
748  }
749 
750  m_indx[ tmp[rowcoord] ] = colcoord;
751  tmp[rowcoord]++;
752  }
753  }
IndexVectorType m_indx
BCOMatType::const_iterator BCOMatTypeConstIt
Array< OneD, NekDouble > BCOEntryType
unsigned int IndexType
IndexVectorType m_pntr
static const NekDouble kNekSparseNonZeroTol

Member Data Documentation

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

Definition at line 210 of file StorageSmvBsr.hpp.

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

Definition at line 209 of file StorageSmvBsr.hpp.

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

Definition at line 213 of file StorageSmvBsr.hpp.

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

Definition at line 207 of file StorageSmvBsr.hpp.

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

Definition at line 205 of file StorageSmvBsr.hpp.

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

Definition at line 214 of file StorageSmvBsr.hpp.

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