Line | Branch | Exec | Source |
---|---|---|---|
1 | // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
2 | // vi: set et ts=4 sw=4 sts=4: | ||
3 | // | ||
4 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup Core | ||
10 | * \brief A arithmetic block vector type based on DUNE's reserved vector | ||
11 | */ | ||
12 | #ifndef DUMUX_RESERVED_BLOCK_VECTOR_HH | ||
13 | #define DUMUX_RESERVED_BLOCK_VECTOR_HH | ||
14 | |||
15 | #include <algorithm> | ||
16 | #include <dune/common/reservedvector.hh> | ||
17 | |||
18 | namespace Dumux { | ||
19 | |||
20 | /*! | ||
21 | * \ingroup Core | ||
22 | * \brief A arithmetic block vector type based on DUNE's reserved vector | ||
23 | */ | ||
24 | template<class BlockType, int capacity> | ||
25 | class ReservedBlockVector : public Dune::ReservedVector<BlockType, capacity> | ||
26 | { | ||
27 | using Base = Dune::ReservedVector<BlockType, capacity>; | ||
28 | public: | ||
29 | |||
30 | using size_type = typename Base::size_type; | ||
31 | using value_type = BlockType; | ||
32 | |||
33 | 14991374 | using Base::Base; | |
34 | |||
35 | 30793908 | explicit ReservedBlockVector() : Base() {} | |
36 |
31/33✓ Branch 0 taken 10132140 times.
✓ Branch 1 taken 3564717 times.
✓ Branch 2 taken 10132140 times.
✓ Branch 3 taken 3807407 times.
✓ Branch 4 taken 10139096 times.
✓ Branch 5 taken 13600386 times.
✓ Branch 6 taken 20139086 times.
✓ Branch 7 taken 13213632 times.
✓ Branch 8 taken 20139052 times.
✓ Branch 9 taken 3044104 times.
✓ Branch 10 taken 20132115 times.
✓ Branch 11 taken 1843575 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 340894 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 371230 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 373847 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 373847 times.
✓ Branch 20 taken 2 times.
✓ Branch 21 taken 91542 times.
✓ Branch 22 taken 2 times.
✓ Branch 23 taken 91542 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 87680 times.
✓ Branch 26 taken 1 times.
✓ Branch 27 taken 374463 times.
✓ Branch 28 taken 1 times.
✓ Branch 29 taken 374463 times.
✓ Branch 30 taken 1 times.
✓ Branch 31 taken 374463 times.
✗ Branch 32 not taken.
|
2185672454 | explicit ReservedBlockVector(size_type size) : Base() { this->resize(size); } |
37 | |||
38 | ReservedBlockVector(const ReservedBlockVector&) = default; | ||
39 | ReservedBlockVector(ReservedBlockVector&&) = default; | ||
40 | |||
41 | ReservedBlockVector& operator= (const ReservedBlockVector&) = default; | ||
42 | ReservedBlockVector& operator= (ReservedBlockVector&&) = default; | ||
43 | |||
44 | ~ReservedBlockVector() = default; | ||
45 | |||
46 | //! assignment from scalar | ||
47 | ✗ | ReservedBlockVector& operator= (const typename BlockType::field_type& v) | |
48 | { | ||
49 |
15/15✓ Branch 0 taken 31913 times.
✓ Branch 1 taken 92772203 times.
✓ Branch 2 taken 79754677 times.
✓ Branch 3 taken 16715516 times.
✓ Branch 4 taken 6405417 times.
✓ Branch 5 taken 2275636 times.
✓ Branch 6 taken 2341446 times.
✓ Branch 7 taken 406320 times.
✓ Branch 8 taken 3095855 times.
✓ Branch 9 taken 913268 times.
✓ Branch 10 taken 9913902 times.
✓ Branch 11 taken 424924 times.
✓ Branch 12 taken 217463 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 5780 times.
|
1395792810 | std::fill(this->begin(), this->end(), v); |
50 | ✗ | return *this; | |
51 | } | ||
52 | |||
53 | //! vector space addition | ||
54 | ReservedBlockVector& operator+= (const ReservedBlockVector& other) | ||
55 | { | ||
56 |
8/8✓ Branch 0 taken 403918614 times.
✓ Branch 1 taken 167730720 times.
✓ Branch 2 taken 52681089 times.
✓ Branch 3 taken 34583673 times.
✓ Branch 4 taken 1367424 times.
✓ Branch 5 taken 1317424 times.
✓ Branch 6 taken 4820000 times.
✓ Branch 7 taken 2892000 times.
|
669310944 | for (size_type i = 0; i < this->size(); ++i) |
57 | 1851148508 | (*this)[i] += other[i]; | |
58 | return *this; | ||
59 | } | ||
60 | |||
61 | //! vector space subtraction | ||
62 | ReservedBlockVector& operator-= (const ReservedBlockVector& other) | ||
63 | { | ||
64 |
20/36✓ Branch 0 taken 6097920 times.
✓ Branch 1 taken 1538880 times.
✓ Branch 2 taken 550170646 times.
✓ Branch 3 taken 131158467 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 220862904 times.
✓ Branch 7 taken 56062987 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 70006006 times.
✓ Branch 11 taken 17016458 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 91822016 times.
✓ Branch 15 taken 15560817 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 2279774 times.
✓ Branch 19 taken 544082 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 9276480 times.
✓ Branch 23 taken 2995984 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4548 times.
✓ Branch 27 taken 998 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 3168 times.
✓ Branch 31 taken 1056 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 123328 times.
✓ Branch 35 taken 30832 times.
|
1175557351 | for (size_type i = 0; i < this->size(); ++i) |
65 | 3802587160 | (*this)[i] -= other[i]; | |
66 | return *this; | ||
67 | } | ||
68 | |||
69 | //! division by scalar | ||
70 | ReservedBlockVector& operator/= (const typename BlockType::field_type& v) | ||
71 | { | ||
72 |
18/18✓ Branch 0 taken 556268566 times.
✓ Branch 1 taken 132697347 times.
✓ Branch 2 taken 220862904 times.
✓ Branch 3 taken 56062987 times.
✓ Branch 4 taken 70006006 times.
✓ Branch 5 taken 17016458 times.
✓ Branch 6 taken 91822016 times.
✓ Branch 7 taken 15560817 times.
✓ Branch 8 taken 2279774 times.
✓ Branch 9 taken 544082 times.
✓ Branch 10 taken 9276480 times.
✓ Branch 11 taken 2995984 times.
✓ Branch 12 taken 4548 times.
✓ Branch 13 taken 998 times.
✓ Branch 14 taken 3168 times.
✓ Branch 15 taken 1056 times.
✓ Branch 16 taken 123328 times.
✓ Branch 17 taken 30832 times.
|
1175557351 | for (size_type i = 0; i < this->size(); ++i) |
73 | 2851940370 | (*this)[i] /= v; | |
74 | return *this; | ||
75 | } | ||
76 | |||
77 | //! multiplication by scalar | ||
78 | ReservedBlockVector& operator*= (const typename BlockType::field_type& v) | ||
79 | { | ||
80 | for (size_type i = 0; i < this->size(); ++i) | ||
81 | (*this)[i] *= v; | ||
82 | return *this; | ||
83 | } | ||
84 | }; | ||
85 | |||
86 | } // end namespace Dumux | ||
87 | |||
88 | #endif | ||
89 |