Discontinuous Galerkin Library
#include "dg/algorithm.h"
transpose.h
Go to the documentation of this file.
1#pragma once
2#include <cusp/transpose.h>
3#include "blas2_cusp.h"
4#include "tensor_traits.h"
5#ifdef MPI_VERSION
6#include "blas2_dispatch_mpi.h"
7#endif //MPI_VERSION
8
9namespace dg
10{
11
13namespace detail
14{
15template <class Matrix>
16Matrix doTranspose( const Matrix& src, CuspMatrixTag)
17{
18 Matrix out;
19 cusp::transpose( src, out);
20 return out;
21}
22#ifdef MPI_VERSION
23template <class LocalMatrix, class Collective>
24MPIDistMat<LocalMatrix, Collective> doTranspose( const MPIDistMat<LocalMatrix, Collective>& src, MPIMatrixTag)
25{
26 LocalMatrix tr = doTranspose( src.matrix(), get_tensor_category<LocalMatrix>());
27 MPIDistMat<LocalMatrix, Collective> out( tr, src.collective());
28 if( src.get_dist() == dg::row_dist) out.set_dist( dg::col_dist);
29 if( src.get_dist() == dg::col_dist) out.set_dist( dg::row_dist);
30 return out;
31}
32#endif// MPI_VERSION
33}//namespace detail
35
47template<class Matrix>
48Matrix transpose( const Matrix& src)
49{
50 //%Transposed matrices work only for csr_matrix due to bad matrix form for ell_matrix!!!
51 return detail::doTranspose( src, get_tensor_category<Matrix>());
52}
53
54} //namespace dg
Matrix transpose(const Matrix &src)
Generic matrix transpose method.
Definition: transpose.h:48
void transpose(unsigned nx, unsigned ny, const ContainerType &in, ContainerType &out)
Transpose vector.
Definition: average_dispatch.h:26
@ col_dist
Column distributed.
Definition: mpi_matrix.h:200
@ row_dist
Row distributed.
Definition: mpi_matrix.h:199
typename TensorTraits< std::decay_t< Vector > >::tensor_category get_tensor_category
Definition: tensor_traits.h:40
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...