Content

Lösungsvorschlag

swap

#ifndef HPC_MATVEC_SWAP_H
#define HPC_MATVEC_SWAP_H 1

#include <cassert>
#include <type_traits>
#include <hpc/ulmblas/swap.h>
#include <hpc/matvec/isdensevector.h>

namespace hpc { namespace matvec {

template <typename VX, typename VY>
typename std::enable_if<IsDenseVector<VX>::value && IsDenseVector<VY>::value,
         void>::type
swap(VX &&x, VY &&y)
{
    assert(x.length==y.length);

    return ulmblas::swap(x.length, x.data, x.inc, y.data, y.inc);
}

} } // namespace matvec, hpc

#endif // HPC_MATVEC_SWAP_H

iamax

#ifndef HPC_MATVEC_IAMAX_H
#define HPC_MATVEC_IAMAX_H 1

#include <cassert>
#include <type_traits>
#include <hpc/ulmblas/iamax.h>
#include <hpc/matvec/isdensevector.h>

namespace hpc { namespace matvec {

template <typename VX>
typename std::enable_if<IsDenseVector<VX>::value,
         typename VX::Index>::type
iamax(const VX &x)
{
    return ulmblas::iamax(x.length, x.data, x.inc);
}

} } // namespace matvec, hpc

#endif // HPC_MATVEC_IAMAX_H

Rang-1 Update: r

#ifndef HPC_MATVEC_R_H
#define HPC_MATVEC_R_H 1

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

namespace hpc { namespace matvec {

template <typename Alpha, typename VX, typename VY, typename MA>
    /*
typename std::enable_if<IsDenseVector<VX>::value
                     && IsDenseVector<VY>::value
                     && IsGeMatrix<MA>::value,
         void>::type
         */
void
r(const Alpha &alpha, const VX &x, const VY &y, MA &&A)
{
    assert(x.length==A.numRows);
    assert(y.length==A.numCols);

    return ulmblas::ger(A.numRows, A.numCols,
                        alpha,
                        x.data, x.inc,
                        y.data, y.inc,
                        A.data, A.incRow, A.incCol);
}

} } // namespace matvec, hpc

#endif // HPC_MATVEC_R_H