DOLFIN
DOLFIN C++ interface
FunctionAXPY.h
1 // Copyright (C) 2013 Johan Hake
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // First added: 2013-02-11
19 // Last changed: 2013-02-14
20 
21 #ifndef __FUNCTION_AXPY_H
22 #define __FUNCTION_AXPY_H
23 
24 #include <utility>
25 #include <vector>
26 
27 namespace dolfin
28 {
29 
30  class Function;
31 
36  {
37 
38  public:
39 
41  enum class Direction : int {ADD_ADD=0, SUB_ADD=1, ADD_SUB=2, SUB_SUB=3};
42 
44  FunctionAXPY(std::shared_ptr<const Function> func, double scalar);
45 
47  FunctionAXPY(const FunctionAXPY& axpy, double scalar);
48 
50  FunctionAXPY(std::shared_ptr<const Function> func0,
51  std::shared_ptr<const Function> func1,
52  Direction direction);
53 
55  FunctionAXPY(const FunctionAXPY& axpy,
56  std::shared_ptr<const Function> func,
57  Direction direction);
58 
60  FunctionAXPY(const FunctionAXPY& axpy0,
61  const FunctionAXPY& axpy1,
62  Direction direction);
63 
66  std::vector<std::pair<double, std::shared_ptr<const Function>>> pairs);
67 
69  FunctionAXPY(const FunctionAXPY& axpy);
70 
72  ~FunctionAXPY();
73 
75  FunctionAXPY operator+(std::shared_ptr<const Function> func) const;
76 
78  FunctionAXPY operator+(const FunctionAXPY& axpy) const;
79 
81  FunctionAXPY operator-(std::shared_ptr<const Function> func) const;
82 
84  FunctionAXPY operator-(const FunctionAXPY& axpy) const;
85 
87  FunctionAXPY operator*(double scale) const;
88 
90  FunctionAXPY operator/(double scale) const;
91 
93  const std::vector<std::pair<double, std::shared_ptr<const Function>>>&
94  pairs() const;
95 
96  private:
97 
99  void _register(const FunctionAXPY& axpy0, double scale);
100 
101  std::vector<std::pair<double, std::shared_ptr<const Function>>> _pairs;
102 
103  };
104 
105 }
106 
107 #endif
FunctionAXPY operator+(std::shared_ptr< const Function > func) const
Addition operator.
Definition: FunctionAXPY.cpp:107
const std::vector< std::pair< double, std::shared_ptr< const Function > > > & pairs() const
Return the scalar and Function pairs.
Definition: FunctionAXPY.cpp:128
Definition: adapt.h:29
Definition: FunctionAXPY.h:35
FunctionAXPY operator/(double scale) const
Scale operator.
Definition: FunctionAXPY.cpp:157
~FunctionAXPY()
Destructor.
Definition: FunctionAXPY.cpp:102
FunctionAXPY operator-(std::shared_ptr< const Function > func) const
Subtraction operator.
Definition: FunctionAXPY.cpp:117
Direction
Enum to decide what way AXPY is constructed.
Definition: FunctionAXPY.h:41
FunctionAXPY(std::shared_ptr< const Function > func, double scalar)
Constructor.
Definition: FunctionAXPY.cpp:29
FunctionAXPY operator*(double scale) const
Scale operator.
Definition: FunctionAXPY.cpp:152