Dune Core Modules (2.8.0)

transpose.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_COMMON_TRANSPOSE_HH
4#define DUNE_COMMON_TRANSPOSE_HH
5
6#include <cstddef>
7
10
11namespace Dune {
12
13namespace Impl {
14
15 // Wrapper representing the transposed of a matrix.
16 // Creating the wrapper does not compute anything
17 // but only serves for tagging the wrapped matrix
18 // for transposition.
19 template<class M>
20 class TransposedMatrixWrapper
21 {
22 public:
23
24 enum {
26 rows = M::cols,
28 cols = M::rows
29 };
30
31 TransposedMatrixWrapper(const M& matrix) : matrix_(matrix) {}
32 TransposedMatrixWrapper(const TransposedMatrixWrapper&) = delete;
33 TransposedMatrixWrapper(TransposedMatrixWrapper&&) = delete;
34
35 template<class OtherField, int otherRows>
36 friend auto operator* (const FieldMatrix<OtherField, otherRows, rows>& matrixA,
37 const TransposedMatrixWrapper& matrixB)
38 {
39 using ThisField = typename FieldTraits<M>::field_type;
40 using Field = typename PromotionTraits<ThisField, OtherField>::PromotedType;
41 FieldMatrix<Field, otherRows, cols> result;
42 for (std::size_t j=0; j<otherRows; ++j)
43 matrixB.matrix_.mv(matrixA[j], result[j]);
44 return result;
45 }
46
47 private:
48
49 const M& matrix_;
50 };
51
52} // namespace Impl
53
69template<class Matrix>
70auto transpose(const Matrix& matrix) {
71 return Impl::TransposedMatrixWrapper<Matrix>(matrix);
72}
73
74
75} // namespace Dune
76
77#endif // DUNE_COMMON_TRANSPOSE_HH
A generic dynamic dense matrix.
Definition: matrix.hh:559
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Dune namespace.
Definition: alignedallocator.hh:11
auto transpose(const Matrix &matrix)
Create a wrapper modelling the transposed matrix.
Definition: transpose.hh:70
Compute type of the result of an arithmetic operation involving two different number types.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)