ug4
matrix_use_operators.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012: G-CSC, Goethe University Frankfurt
3  * Author: Martin Rupp
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 
34 // MATRIX_USE_OPERATORS: elementary types like double, float, or template operatored classes: use operators
36 
37 namespace ug{
38 
39 template<typename vector_t, typename matrix_t>
40 struct mat_operations_class<vector_t, matrix_t, MATRIX_USE_OPERATORS>
41 {
43  static inline bool MatMult(vector_t &dest, const number &beta1, const matrix_t &A1, const vector_t &w1)
44  {
45  dest = beta1 * A1 * w1;
46  return true;
47  }
48 
50  static inline bool MatMultAdd(vector_t &dest,
51  const number &alpha1, const vector_t &v1,
52  const number &beta1, const matrix_t &A1, const vector_t &w1)
53  {
54  dest = alpha1*v1 + beta1 * A1 * w1;
55  return true;
56  }
57  static inline bool MatMultAdd(vector_t &dest,
58  const number &alpha1, const vector_t &v1,
59  const number &alpha2, const vector_t &v2,
60  const number &beta1, const matrix_t &A1, const vector_t &w1)
61  {
62  dest = alpha1*v1 + alpha2*v2 + beta1 * A1 * w1;
63  return true;
64  }
65  static inline bool MatMultAdd(vector_t &dest,
66  const number &beta1, const matrix_t &A1, const vector_t &w1,
67  const number &beta2, const matrix_t &A2, const vector_t &w2)
68  {
69  dest = beta1 * A1 * w1 + beta2 * A2 * w2;
70  return true;
71  }
72  static inline bool MatMultAdd(vector_t &dest,
73  const number &alpha1, const vector_t &v1,
74  const number &beta1, const matrix_t &A1, const vector_t &w1,
75  const number &beta2, const matrix_t &A2, const vector_t &w2)
76  {
77  dest = alpha1*v1 + beta1 * A1 * w1 + beta2 * A2 * w2;
78  return true;
79  }
80 
82  static inline bool MatMultTransposed(vector_t &dest,
83  const number &beta1, const matrix_t &A1, const vector_t &w1)
84  {
85  dest = beta1 * A1 * w1;
86  return true;
87  }
88 
90  static inline bool MatMultTransposedAdd(vector_t &dest,
91  const number &alpha1, const vector_t &v1,
92  const number &beta1, const matrix_t &A1, const vector_t &w1)
93  {
94  dest = alpha1*v1 + beta1 * A1 * w1;
95  return true;
96  }
97 };
98 
99 }
double number
Definition: types.h:124
the ug namespace
@ MATRIX_USE_OPERATORS
Definition: matrix_algebra_types.h:70
static bool MatMultAdd(vector_t &dest, const number &alpha1, const vector_t &v1, const number &alpha2, const vector_t &v2, const number &beta1, const matrix_t &A1, const vector_t &w1)
Definition: matrix_use_operators.h:57
static bool MatMultTransposedAdd(vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = alpha1*v1 + beta1 * A1^T *w1;
Definition: matrix_use_operators.h:90
static bool MatMultAdd(vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const matrix_t &A1, const vector_t &w1, const number &beta2, const matrix_t &A2, const vector_t &w2)
Definition: matrix_use_operators.h:72
static bool MatMultAdd(vector_t &dest, const number &beta1, const matrix_t &A1, const vector_t &w1, const number &beta2, const matrix_t &A2, const vector_t &w2)
Definition: matrix_use_operators.h:65
static bool MatMult(vector_t &dest, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = beta1 * A1 *w1;
Definition: matrix_use_operators.h:43
static bool MatMultTransposed(vector_t &dest, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = beta1 * A1^T *w1;
Definition: matrix_use_operators.h:82
static bool MatMultAdd(vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = alpha1*v1 + beta1 * A1 *w1;
Definition: matrix_use_operators.h:50
Definition: matrix_algebra_types.h:75