line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
| Copyright (c) 2013-2017, Nucleic Development Team. |
3
|
|
|
|
|
|
|
| |
4
|
|
|
|
|
|
|
| Distributed under the terms of the Modified BSD License. |
5
|
|
|
|
|
|
|
| |
6
|
|
|
|
|
|
|
| The full license is in the file LICENSE, distributed with this software. |
7
|
|
|
|
|
|
|
|----------------------------------------------------------------------------*/ |
8
|
|
|
|
|
|
|
#pragma once |
9
|
|
|
|
|
|
|
#include <utility> |
10
|
|
|
|
|
|
|
#include "variable.h" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
namespace kiwi |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
class Term |
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
public: |
20
|
|
|
|
|
|
|
|
21
|
8294
|
|
|
|
|
|
Term( Variable variable, double coefficient = 1.0 ) : |
22
|
8294
|
|
|
|
|
|
m_variable( std::move(variable) ), m_coefficient( coefficient ) {} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
// to facilitate efficient map -> vector copies |
25
|
6132
|
|
|
|
|
|
Term( const std::pair<const Variable, double>& pair ) : |
26
|
6132
|
|
|
|
|
|
m_variable( pair.first ), m_coefficient( pair.second ) {} |
27
|
|
|
|
|
|
|
|
28
|
31500
|
|
|
|
|
|
Term(const Term&) = default; |
29
|
|
|
|
|
|
|
|
30
|
4318
|
|
|
|
|
|
Term(Term&&) noexcept = default; |
31
|
|
|
|
|
|
|
|
32
|
49246
|
|
|
|
|
|
~Term() = default; |
33
|
|
|
|
|
|
|
|
34
|
14379
|
|
|
|
|
|
const Variable& variable() const |
35
|
|
|
|
|
|
|
{ |
36
|
14379
|
|
|
|
|
|
return m_variable; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
20500
|
|
|
|
|
|
double coefficient() const |
40
|
|
|
|
|
|
|
{ |
41
|
20500
|
|
|
|
|
|
return m_coefficient; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
8
|
|
|
|
|
|
double value() const |
45
|
|
|
|
|
|
|
{ |
46
|
8
|
|
|
|
|
|
return m_coefficient * m_variable.value(); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Term& operator=(const Term&) = default; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Term& operator=(Term&&) noexcept = default; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
private: |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Variable m_variable; |
56
|
|
|
|
|
|
|
double m_coefficient; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} // namespace kiwi |