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

#include <cassert>
#include <hpc/ulmblas/swap.h>

namespace hpc { namespace ulmlapack {

template <typename Index, typename TA, typename TP>
void
swap(Index m, Index n,
     TA *A, Index incRowA, Index incColA,
     Index k0, Index k1,
     TP *p, Index incP)
{
    assert(0<=k0);
    assert(k0<=k1);
    assert(k1<=m);

    for (Index k=k0; k<k1; ++k) {
        Index i = p[k*incP];
        if (i!=k) {
            hpc::ulmblas::swap(n,
                               &A[k*incRowA], incColA,
                               &A[i*incRowA], incColA);
        }
    }
}

} } // namespace ulmblas, hpc

#endif // HPC_ULMLAPACK_SWAP_H