dune-assembler 2.12
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
20public:
21 using index_type = typename Base::index_type;
22 using value_type = typename Base::value_type;
25
26 using Base::Base;
27
28 constexpr FlatVector& operator= (const value_type& value)
29 {
30 for (index_type i = 0; i < size(); ++i)
31 (*this)[i] = value;
32 return *this;
33 }
34
35 constexpr index_type size () const noexcept { return Base::extent(0); }
36
39
41 void resize (index_type size, const value_type& value)
42 {
43 if (size != this->size())
44 {
45 auto container = std::move(*this).extract_container();
47 container.resize(m.required_span_size(), value);
48 static_cast<Base&>(*this) = Base{m, std::move(container)};
49 }
50 }
51
54 {
55 if (size != this->size())
56 {
57 auto container = std::move(*this).extract_container();
59 container.resize(m.required_span_size());
60 static_cast<Base&>(*this) = Base{m, std::move(container)};
61 }
62 }
63
65};
66
67} // end namespace Dune::Assembler
68
69#endif // DUNE_ASSEMBLER_BACKENDS_FLATVECTOR_HH
Definition localboundaryintersectionmatrixassembler.hh:9
Definition flatvector.hh:17
typename Base::mapping_type mapping_type
Definition flatvector.hh:24
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:41
void resize(index_type size)
Change the shape of the matrix and resize the underlying container.
Definition flatvector.hh:53
constexpr FlatVector & operator=(const value_type &value)
Definition flatvector.hh:28
typename Base::extents_type extents_type
Definition flatvector.hh:23
constexpr index_type size() const noexcept
Definition flatvector.hh:35
typename Base::index_type index_type
Definition flatvector.hh:21
typename Base::value_type value_type
Definition flatvector.hh:22