1#ifndef DUNE_FEM_BASEFUNCTIONSET_FUNCTOR_HH
2#define DUNE_FEM_BASEFUNCTIONSET_FUNCTOR_HH
7#include <dune/fem/misc/functor.hh>
8#include <dune/fem/common/explicitfieldvector.hh>
20 inline void axpy (
const T &a,
const T &x, T &y );
22 template<
class K,
int SIZE >
23 inline void axpy (
const typename FieldTraits< K >::field_type &a,
24 const FieldVector< K, SIZE > &x,
25 FieldVector< K, SIZE > &y );
27 template<
class K,
int ROWS,
int COLS >
28 inline void axpy (
const typename FieldTraits< K >::field_type &a,
29 const FieldMatrix< K, ROWS, COLS > &x,
30 FieldMatrix< K, ROWS, COLS > &y );
38 inline void axpy (
const T &a,
const T &x, T &y )
43 template<
class K,
int SIZE >
44 inline void axpy (
const typename FieldTraits< K >::field_type &a,
45 const FieldVector< K, SIZE > &x,
46 FieldVector< K, SIZE > &y )
48 for(
int i = 0; i < SIZE; ++i )
49 axpy( a, x[ i ], y[ i ] );
52 template<
class K,
int ROWS,
int COLS >
53 inline void axpy (
const typename FieldTraits< K >::field_type &a,
54 const FieldMatrix< K, ROWS, COLS > &x,
55 FieldMatrix< K, ROWS, COLS > &y )
65 inline double scalarProduct (
const double &a,
const double &b ) {
return a * b; }
68 inline typename T::field_type scalarProduct (
const T &a,
const T &b )
73 template<
class K,
int ROWS,
int COLS >
74 inline K scalarProduct (
const FieldMatrix< K, ROWS, COLS > &a,
const FieldMatrix< K, ROWS, COLS > &b )
77 for(
int r = 0; r < ROWS; ++r )
82 template<
class K,
int ROWS,
int COLS,
int R >
83 inline K scalarProduct (
const FieldVector< FieldMatrix< K, ROWS, COLS >, R> &a,
const FieldVector< FieldMatrix< K, ROWS, COLS >, R> &b )
86 for (
int i=0; i<R; ++i)
87 for(
int r = 0; r < ROWS; ++r )
88 s += a[ i ][ r ] * b[ i ][ r ];
92 template<
class K,
int ROWS,
int COLS,
int R >
93 inline K scalarProduct (
const ExplicitFieldVector< FieldMatrix< K, ROWS, COLS >, R> &a,
const ExplicitFieldVector< FieldMatrix< K, ROWS, COLS >, R> &b )
96 for (
int i=0; i<R; ++i)
97 for(
int r = 0; r < ROWS; ++r )
98 s += a[ i ][ r ] * b[ i ][ r ];
106 template<
class Vector,
class Value >
109 AxpyFunctor (
const Vector &vector, Value &value )
115 void operator() (
const std::size_t i,
const V &v )
117 axpy( vector_[ i ], v, value_ );
121 const Vector &vector_;
130 template<
class Value,
class Vector >
131 struct FunctionalAxpyFunctor
133 FunctionalAxpyFunctor (
const Value &value, Vector &vector )
139 void operator() (
const std::size_t i,
const V &v )
141 vector_[ i ] += scalarProduct( v, value_ );
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