1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
#ifndef HPC_MATVEC_SCAL_H
#define HPC_MATVEC_SCAL_H 1

#include <cassert>
#include <type_traits>
#include <hpc/ulmblas/gescal.h>
#include <hpc/ulmblas/scal.h>
#include <hpc/matvec/isdensevector.h>
#include <hpc/matvec/isgematrix.h>

namespace hpc { namespace matvec {

template <typename Alpha, typename MA>
typename std::enable_if<IsGeMatrix<MA>::value,
         void>::type
scal(const Alpha &alpha, MA &A)
{
    typedef typename MA::Index  Index;

    const Index m = A.numRows;
    const Index n = A.numCols;

    ulmblas::gescal(m, n, alpha,
                    A.data, A.incRow, A.incCol);
}

template <typename Alpha, typename VX>
typename std::enable_if<IsDenseVector<VX>::value,
         void>::type
scal(const Alpha &alpha, VX &x)
{
    ulmblas::scal(x.length, alpha, x.data, x.inc);
}

} } // namespace matvec, hpc

#endif // HPC_MATVEC_SCAL_H