11 #ifndef BOGUS_BLOCK_MKL_BINDINGS_HPP
12 #define BOGUS_BLOCK_MKL_BINDINGS_HPP
14 #include "SparseBlockMatrix.hpp"
15 #include "CompressedSparseBlockIndex.hpp"
18 #include <mkl_spblas.h>
33 template<
typename Scalar >
39 typedef double Scalar ;
40 static void bsrmv (
char *transa, MKL_INT *m, MKL_INT *k, MKL_INT *lb, Scalar *alpha,
char *matdescra, Scalar *val, MKL_INT *indx, MKL_INT *pntrb, MKL_INT *pntre, Scalar *x, Scalar *beta, Scalar *y)
42 mkl_dbsrmv( transa, m, k, lb, alpha,
43 matdescra, val, indx, pntrb, pntre,
62 template<
typename Scalar >
64 bool Symmetric,
bool Transpose, MKL_INT Dimension,
65 MKL_INT m, MKL_INT k,
const std::size_t offset,
66 const MKL_INT *rowIndex,
const MKL_INT *columns,
const Scalar *data,
67 const Scalar *rhs,
int rhsCols, Scalar *res, Scalar alpha, Scalar beta )
70 char matdescra[4] = { Symmetric ?
'S' :
'G',
'L',
'N',
'C'} ;
72 char transa = Transpose ?
'T' :
'N' ;
73 MKL_INT lb = Dimension ;
74 Scalar *x =
const_cast< Scalar*
> ( rhs ) ;
77 MKL_INT* pntrb =
const_cast< MKL_INT*
>( rowIndex+offset ) ;
78 MKL_INT* pntre =
const_cast< MKL_INT*
>( rowIndex+offset+1 ) ;
79 MKL_INT* indx =
const_cast< MKL_INT*
>( columns ) ;
81 Scalar *a =
const_cast< Scalar*
> ( data ) + pntrb[0] * lb * lb ;
83 for(
int i = 0 ; i < rhsCols ; ++i )
85 bindings< Scalar >::bsrmv( &transa, &m, &k, &lb, &alpha,
86 matdescra, a, indx, pntrb, pntre,
87 x + i*Dimension*k, &beta, y + i*Dimension*k ) ;
92 template <
typename BlockPtr,
typename BlockType >
93 static void rowmv(
const SparseBlockIndex< true, MKL_INT, BlockPtr >& index,
94 const BlockType* data, MKL_INT row,
95 const typename BlockTraits< BlockType >::Scalar *rhs,
int rhsCols,
96 typename BlockTraits< BlockType >::Scalar *res )
98 const MKL_INT *rowIndexOrig = index.rowIndex() ;
99 const MKL_INT offset = rowIndexOrig[ row ] ;
100 const MKL_INT rowIndex[2] = {0, rowIndexOrig[ row+1 ] - offset} ;
101 const MKL_INT *columns = index.columns() + offset ;
103 mkl::bsrmv< typename BlockTraits< BlockType >::Scalar >
104 (
false,
false, BlockTraits< BlockType >::RowsAtCompileTime,
105 1, index.innerSize(), 0,
107 data_pointer( data[offset + index.base] ),
108 rhs, rhsCols, res, 1, 1 ) ;
114 struct SparseBlockMatrixOpProxy< true, true, double, MKL_INT >
116 typedef double Scalar ;
118 template <
bool Transpose,
typename Derived,
typename RhsT,
typename ResT >
120 Scalar alpha, Scalar beta )
125 ( Traits::is_symmetric, Transpose, Derived::RowsPerBlock,
126 matrix.rowsOfBlocks(), matrix.colsOfBlocks(), 0,
127 matrix.majorIndex().rowIndex(), matrix.majorIndex().columns(),
128 data_pointer( matrix.
data()[0] ),
129 rhs.data(), rhs.cols(), res.data(), alpha, beta ) ;
132 template <
typename Derived,
typename RhsT,
typename ResT >
137 if( Traits::is_symmetric && !matrix.transposeIndex().valid )
139 SparseBlockSplitRowMultiplier< Traits::is_symmetric, !Traits::is_col_major >
140 ::splitRowMultiply( matrix, row, rhs, res ) ;
145 mkl::rowmv( matrix.majorIndex(), matrix.
data(), row,
146 rhs.data(), rhs.cols(), res.data() ) ;
148 if( Traits::is_symmetric )
150 mkl::rowmv( matrix.transposeIndex(), matrix.
data(), row,
151 rhs.data(), rhs.cols(), res.data() ) ;
161 res -= matrix.block( diagPtr ) * segmenter[row] ;
Definition: Traits.hpp:19
Wrapper over scalar-specific mkl calls.
Definition: MklBindings.hpp:34
Base class for Transpose views of a BlockObjectBase.
Definition: Expressions.hpp:22
static const BlockPtr InvalidBlockPtr
Return value of blockPtr( Index, Index ) for non-existing block.
Definition: BlockMatrixBase.hpp:38
Access to segment of a vector corresponding to a given block-row.
Definition: Access.hpp:133
BlockPtr diagonalBlockPtr(Index row) const
Return a BlockPtr to the block a (row, row) or InvalidBlockPtr if it does not exist.
const Index * colOffsets() const
Returns an array containing the first index of each column.
Definition: SparseBlockMatrixBase.hpp:484
const BlockType * data() const
Access to blocks data as a raw pointer.
Definition: BlockMatrixBase.hpp:91
Base class for SparseBlockMatrix.
Definition: SparseBlockMatrixBase.hpp:36