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
#ifndef HPC_MATVEC_COPY_H
#define HPC_MATVEC_COPY_H 1

#include <cassert>
#include <hpc/ulmblas/gecopy.h>
#include <hpc/matvec/isgematrix.h>
#include <type_traits>

namespace hpc { namespace matvec {

template <typename MA, typename MB>
typename std::enable_if<IsGeMatrix<MA>::value
                     && IsGeMatrix<MB>::value,
         void>::type
copy(const MA &A, MB &&B)
{
    assert(A.numRows==B.numRows);
    assert(A.numCols==B.numCols);

    typedef typename std::common_type<typename MA::Index,
        typename std::remove_reference<MB>::type::Index>::type  Index;

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

    ulmblas::gecopy(m, n,
                    A.data, A.incRow, A.incCol,
                    B.data, B.incRow, B.incCol);
}

} } // namespace matvec, hpc

#endif // HPC_MATVEC_COPY_H