Reference documentation for deal.II version 8.5.1
matrix_lib.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2002 - 2014 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/lac/matrix_lib.templates.h>
17 #include <deal.II/lac/sparse_matrix.h>
18 
19 DEAL_II_NAMESPACE_OPEN
20 
22  :
23  component(component)
24 {}
25 
26 
27 template<typename number, typename vnumber>
29  const MatrixType &mat1,
30  const MatrixType &mat2,
32  :
33  m1(&mat1, typeid(*this).name()),
34  m2(&mat2, typeid(*this).name()),
35  mem(&mem, typeid(*this).name())
36 {
37  Assert(mat1.n() == mat2.m(), ExcDimensionMismatch(mat1.n(),mat2.m()));
38 }
39 
40 
41 template<typename number, typename vnumber>
43  :
44  m1(0, typeid(*this).name()),
45  m2(0, typeid(*this).name()),
46  mem(0, typeid(*this).name())
47 {}
48 
49 
50 template<typename number, typename vnumber>
51 void
53  const MatrixType &mat1,
54  const MatrixType &mat2,
56 {
57  Assert(mat1.n() == mat2.m(), ExcDimensionMismatch(mat1.n(),mat2.m()));
58  mem = &memory;
59  m1 = &mat1;
60  m2 = &mat2;
61 }
62 
63 
64 template<typename number, typename vnumber>
65 void
67 {
68  m1 = 0;
69  m2 = 0;
70 }
71 
72 
73 template<typename number, typename vnumber>
74 void
76 {
77  Assert(mem != 0, ExcNotInitialized());
78  Assert(m1 != 0, ExcNotInitialized());
79  Assert(m2 != 0, ExcNotInitialized());
80 
81  VectorType *v = mem->alloc();
82  v->reinit(m1->n());
83  m2->vmult (*v, src);
84  m1->vmult (dst, *v);
85  mem->free(v);
86 }
87 
88 
89 template<typename number, typename vnumber>
90 void
92 {
93  Assert(mem != 0, ExcNotInitialized());
94  Assert(m1 != 0, ExcNotInitialized());
95  Assert(m2 != 0, ExcNotInitialized());
96 
97  VectorType *v = mem->alloc();
98  v->reinit(m1->n());
99  m2->vmult (*v, src);
100  m1->vmult_add (dst, *v);
101  mem->free(v);
102 }
103 
104 
105 template<typename number, typename vnumber>
106 void
108 {
109  Assert(mem != 0, ExcNotInitialized());
110  Assert(m1 != 0, ExcNotInitialized());
111  Assert(m2 != 0, ExcNotInitialized());
112 
113  VectorType *v = mem->alloc();
114  v->reinit(m1->n());
115  m1->Tvmult (*v, src);
116  m2->Tvmult (dst, *v);
117  mem->free(v);
118 }
119 
120 
121 template<typename number, typename vnumber>
122 void
124 {
125  Assert(mem != 0, ExcNotInitialized());
126  Assert(m1 != 0, ExcNotInitialized());
127  Assert(m2 != 0, ExcNotInitialized());
128 
129  VectorType *v = mem->alloc();
130  v->reinit(m1->n());
131  m1->Tvmult (*v, src);
132  m2->Tvmult_add (dst, *v);
133  mem->free(v);
134 }
135 
136 
140 template class ProductSparseMatrix<float, float>;
141 
142 template void MeanValueFilter::filter(Vector<float> &) const;
143 template void MeanValueFilter::filter(Vector<double> &) const;
144 template void MeanValueFilter::filter(BlockVector<float> &) const;
145 template void MeanValueFilter::filter(BlockVector<double> &) const;
146 template void MeanValueFilter::vmult(Vector<float> &,
147  const Vector<float> &) const;
148 template void MeanValueFilter::vmult(Vector<double> &,
149  const Vector<double> &) const;
151  const BlockVector<float> &) const;
153  const BlockVector<double> &) const;
154 
156  const Vector<float> &) const;
158  const Vector<double> &) const;
160  const BlockVector<float> &) const;
162  const BlockVector<double> &) const;
163 
168 
169 DEAL_II_NAMESPACE_CLOSE
MeanValueFilter(const size_type component=numbers::invalid_size_type)
Definition: matrix_lib.cc:21
virtual void vmult(VectorType &w, const VectorType &v) const
Definition: matrix_lib.cc:75
void vmult(Vector< number > &dst, const Vector< number > &src) const
static ::ExceptionBase & ExcNotInitialized()
virtual void Tvmult(VectorType &w, const VectorType &v) const
Definition: matrix_lib.cc:107
void vmult_add(Vector< number > &dst, const Vector< number > &src) const
virtual void vmult_add(VectorType &w, const VectorType &v) const
Definition: matrix_lib.cc:91
size_type n() const
#define Assert(cond, exc)
Definition: exceptions.h:313
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void filter(Vector< number > &v) const
types::global_dof_index size_type
Definition: matrix_lib.h:333
virtual void Tvmult_add(VectorType &w, const VectorType &v) const
Definition: matrix_lib.cc:123
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
size_type m() const