Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
densematrix_operations.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2015: 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#ifndef __H__UG__COMMON__DENSEMATRIX_OPERATIONS_H__
34#define __H__UG__COMMON__DENSEMATRIX_OPERATIONS_H__
35
36#include "densematrix.h"
37#include "densevector.h"
38
39#include "../../common/operations.h"
40
41namespace ug{
42
45
46template<typename T>
47struct matrix_algebra_type_traits;
48
49template<typename T>
54
56template<typename vector_t, typename matrix_t>
58 const number &beta1, const DenseMatrix<matrix_t> &A1, const DenseVector<vector_t> &w1)
59{
60 for(size_t r = 0; r < dest.size(); ++r)
61 {
62 MatMult(dest[r], beta1, A1(r,0), w1[0]);
63 for(size_t c = 1; c < w1.size(); ++c)
64 MatMultAdd(dest[r], 1.0, dest[r], beta1, A1(r,c), w1[c]);
65 }
66}
67
69template<typename vector_t, typename matrix_t>
71 const number &alpha1, const DenseVector<vector_t> &v1,
72 const number &beta1, const DenseMatrix<matrix_t> &A1, const DenseVector<vector_t> &w1)
73{
74 for(size_t r = 0; r < dest.size(); ++r)
75 {
76 VecScaleAssign(dest[r], alpha1, v1[r]);
77 for(size_t c = 0; c < w1.size(); ++c)
78 MatMultAdd(dest[r], 1.0, dest[r], beta1, A1(r,c), w1[c]);
79 }
80}
81
83template<typename vector_t, typename matrix_t>
85 const number &alpha1, const DenseVector<vector_t> &v1,
86 const number &beta1, const DenseMatrix<matrix_t> &A1, const DenseVector<vector_t> &w1)
87{
88 for(size_t r = 0; r < dest.size(); ++r)
89 {
90 VecScaleAssign(dest[r], alpha1, v1[r]);
91 for(size_t c = 0; c < w1.size(); ++c)
92 MatMultTransposedAdd(dest[r], 1.0, dest[r], beta1, A1(c,r), w1[c]);
93 }
94}
95
96// end group small_algebra
98
99}
100
101#endif // __H__UG__COMMON__DENSEMATRIX_OPERATIONS_H__
Definition densematrix.h:57
Definition densevector.h:101
double number
Definition types.h:124
the ug namespace
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 *w1;
Definition operations_mat.h:121
@ MATRIX_USE_GLOBAL_FUNCTIONS
Definition matrix_algebra_types.h:69
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 operations_mat.h:68
bool MatMult(vector_t &dest, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = beta1 * A1;
Definition operations_mat.h:59
void VecScaleAssign(double &dest, double alpha1, const double &v1)
calculates dest = alpha1*v1. for doubles
Definition operations_vec.h:49
Definition matrix_algebra_types.h:79
static const int type
Definition matrix_algebra_types.h:80