#include namespace flens { struct Permutation : public GeneralMatrix { typedef int ElementType; typedef int IndexType; explicit Permutation(int n) : vector(n) { } DenseVector > vector; }; namespace blas { template void mv(Transpose trans, const ALPHA &alpha, const Permutation &P, const DenseVector &x, const BETA &beta, DenseVector &y) { if (y.length()==0) { y.resize(x.length(), x.firstIndex()); } if (trans==NoTrans) { int ix0 = x.firstIndex(); int iy0 = y.firstIndex(); for (int i=1, ix=ix0, iy=iy0; i<=x.length(); ++i, ++ix, ++iy) { y(i) = beta*y(i) + alpha*x(P.vector(i)); } } else { int ix0 = x.firstIndex(); int iy0 = y.firstIndex(); for (int i=1, ix=ix0, iy=iy0; i<=x.length(); ++i, ++ix, ++iy) { y(P.vector(i)) = beta*y(i) + alpha*x(i); } } } template void mm(Transpose transP, Transpose transA, const ALPHA &alpha, const Permutation &P, const GeMatrix &A, const BETA &beta, GeMatrix &B) { typedef typename MB::IndexType IndexType; if (B.numRows()==0 || B.numCols()==0) { B.resize(A.numRows(), A.numCols(), A.firstRow(), A.firstCol()); } const Underscore _; if (transA==NoTrans) { for (IndexType j=1; j<=A.numCols(); ++j) { const auto x = A(_,j); auto y = B(_,j); mv(transP, alpha, P, x, beta, y); } } else { for (IndexType i=1; i<=A.numRows(); ++i) { const auto x = A(i,_); auto y = B(_,i); mv(transP, alpha, P, x, beta, y); } } } } // namespace blas } // namespace flens