dune-assembler 2.11
Loading...
Searching...
No Matches
flatvector.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef DUNE_ASSEMBLER_BACKENDS_FLATVECTOR_HH
5#define DUNE_ASSEMBLER_BACKENDS_FLATVECTOR_HH
6
7#include <vector>
8
11
12namespace Dune::Assembler {
13
14template <class T>
16 : public Std::mdarray<T, Std::dextents<std::size_t,1>, Std::layout_right, std::vector<T>>
17{
19 using index_type = typename Base::index_type;
20 using value_type = typename Base::value_type;
21 using extents_type = typename Base::extents_type;
22 using mapping_type = typename Base::mapping_type;
23
24public:
25 using Base::Base;
26
27 constexpr FlatVector& operator= (const value_type& value)
28 {
29 for (index_type i = 0; i < size(); ++i)
30 (*this)[i] = value;
31 return *this;
32 }
33
34 constexpr index_type size () const noexcept { return Base::extent(0); }
35
38
40 void resize (index_type size, const value_type& value)
41 {
42 if (size != this->size())
43 {
44 auto container = std::move(*this).extract_container();
45 auto m = mapping_type{extents_type{size}};
46 container.resize(m.required_span_size(), value);
47 static_cast<Base&>(*this) = Base{m, std::move(container)};
48 }
49 }
50
52 void resize (index_type size)
53 {
54 if (size != this->size())
55 {
56 auto container = std::move(*this).extract_container();
57 auto m = mapping_type{extents_type{size}};
58 container.resize(m.required_span_size());
59 static_cast<Base&>(*this) = Base{m, std::move(container)};
60 }
61 }
62
64};
65
66} // end namespace Dune::Assembler
67
68#endif // DUNE_ASSEMBLER_BACKENDS_FLATVECTOR_HH
Definition localboundaryintersectionmatrixassembler.hh:9
Definition flatvector.hh:17
void resize(index_type size, const value_type &value)
Change the shape of the matrix and resize the underlying container with given default value.
Definition flatvector.hh:40
void resize(index_type size)
Change the shape of the matrix and resize the underlying container.
Definition flatvector.hh:52
constexpr FlatVector & operator=(const value_type &value)
Definition flatvector.hh:27
constexpr index_type size() const noexcept
Definition flatvector.hh:34