1#ifndef DUNE_FEM_FIELDMATRIXHELPER_HH
2#define DUNE_FEM_FIELDMATRIXHELPER_HH
14 namespace FieldMatrixHelper
17 template<
class Field1,
class Field2,
class Field3,
int m,
int n >
18 inline void multiply (
const FieldMatrix< Field1, m, n > &A,
19 const FieldVector< Field2, n > &x,
20 FieldVector< Field3, m > &y )
22 for(
int i = 0; i < m; ++i )
24 Field3 &value = y[ i ];
27 for(
int j = 0; j < n; ++j )
28 value += A[ i ][ j ] * x[ j ];
34 template<
class Field1,
class Field2,
class Field3,
int m,
int n,
int p >
35 inline void multiply (
const FieldMatrix< Field1, m, n > &A,
36 const FieldMatrix< Field2, n, p > &B,
37 FieldMatrix< Field3, m, p > &C )
39 for(
int i = 0; i < m; ++i )
41 for(
int j = 0; j < p; ++j )
43 Field3 &value = C[ i ][ j ];
46 for(
int k = 0; k < n; ++k )
47 value += A[ i ][ k ] * B[ k ][ j ];
52 template<
class Field1,
class Field2,
class Field3 >
53 inline void multiply (
const DynamicMatrix< Field1 >& A,
54 const DynamicMatrix< Field2 >& B,
55 DynamicMatrix< Field3 >& C )
57 const int m = A.rows();
58 const int n = A.cols();
59 const int p = B.cols();
63 assert( A.cols() == B.rows() );
64 assert( A.rows() == C.rows() );
65 assert( B.cols() == C.cols() );
67 for(
int i = 0; i < m; ++i )
69 for(
int j = 0; j < p; ++j )
71 Field3 &value = C[ i ][ j ];
74 for(
int k = 0; k < n; ++k )
75 value += A[ i ][ k ] * B[ k ][ j ];
80 template<
class Field1,
class Field2,
class Field3,
int m,
int n,
int p >
81 inline void multiply (
const FieldMatrix< Field1, m, n > &A,
82 const FieldMatrix< Field2, n, p > &B,
85 for(
int i = 0, ip = 0; i < m; ++i )
87 for(
int j = 0; j < p; ++j , ++ ip )
89 Field3 &value = C[ ip ];
91 for(
int k = 0; k < n; ++k )
92 value += A[ i ][ k ] * B[ k ][ j ];
This file implements a dense matrix with dynamic numbers of rows and columns.
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:13