dune-istl 2.12-git
Loading...
Searching...
No Matches
matrixview.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5
6#ifndef DUNE_ISTL_EXPERIMENTAL_MATRIXVIEW_HH
7#define DUNE_ISTL_EXPERIMENTAL_MATRIXVIEW_HH
8
9#include <dune-istl-config.hh> // DUNE_ISTL_WITH_CHECKING_NOEXCEPT
10
11#include "vectorview.hh"
12
17
18#include <cfenv>
19#include <limits>
20#include <memory>
21#include <ranges>
22#include <span>
23
24namespace Dune::Experimental
25{
26
52 template <std::random_access_iterator B, class P>
54 {
55 public:
57 using block_iter_type = B;
59#if __cpp_lib_ranges_as_const <= 202311L
61#else
62 using block_const_iter_type = std::basic_const_iterator<B>;
63#endif
64
66 using pattern_type = P;
68 using row_index_range_type = std::ranges::range_value_t<pattern_type>;
74 using size_type = std::ranges::range_size_t<pattern_type>;
82 class Iterator;
84 class ConstIterator;
97
104 MatrixView(block_iter_type block_iter, pattern_type const* pattern_ptr) noexcept
105 : block_iter_(block_iter), pattern_ptr_(pattern_ptr)
106 {}
107
109 row_type operator[](size_type i) { return begin()[i]; }
110
112 const_row_type operator[](size_type i) const { return begin()[i]; }
113
115 Iterator begin() { return {block_iter_, pattern_ptr_, 0}; }
116
118 Iterator end() { return {block_iter_, pattern_ptr_, pattern_ptr_->size()}; }
119
121 ConstIterator begin() const { return cbegin(); }
122
124 ConstIterator end() const { return cend(); }
125
127 ConstIterator cbegin() const { return {{block_iter_, pattern_ptr_, 0}}; }
128
130 ConstIterator cend() const { return {{block_iter_, pattern_ptr_, pattern_ptr_->size()}}; }
131
133 template <class OtherB, class OtherI>
135
137 template <class X, class Y>
138 void mv(const X &x, Y &y) const;
139
141 template <class X, class Y>
142 void umv(const X &x, Y &y) const;
143
145 template <class X, class Y>
146 void mmv(const X &x, Y &y) const;
147
149 template <class X, class Y>
150 void usmv(const field_type &alpha, const X &x, Y &y) const;
151
153 template <class X, class Y>
154 void mtv(const X &x, Y &y) const;
155
157 template <class X, class Y>
158 void umtv(const X &x, Y &y) const;
159
161 template <class X, class Y>
162 void mmtv(const X &x, Y &y) const;
163
165 template <class X, class Y>
166 void usmtv(const field_type &alpha, const X &x, Y &y) const;
167
169 template <class X, class Y>
170 void umhv(const X &x, Y &y) const;
171
173 template <class X, class Y>
174 void mmhv(const X &x, Y &y) const;
175
177 template <class X, class Y>
178 void usmhv(const field_type &alpha, const X &x, Y &y) const;
179
182
185
188
191
198 [[nodiscard]] bool exists (size_type i, size_type j) const DUNE_ISTL_WITH_CHECKING_NOEXCEPT
199 {
200#ifdef DUNE_ISTL_WITH_CHECKING
201 if (i<0 || i>=N()) DUNE_THROW(BCRSMatrixError,"row index out of range");
202 if (j<0 || j>=M()) DUNE_THROW(BCRSMatrixError,"column index out of range");
203#endif
204 return this->operator[](i).contains(j);
205 }
206
208 size_type N() const { return pattern_ptr_ ? pattern().size() : 0; }
209
211 size_type M() const { return pattern_ptr_ ? pattern().range().size() : 0; }
212
219 size_type nonzeroes() const { return pattern_ptr_ ? pattern().count() : 0; }
220
221 //===== vector space arithmetic
222
225
228
234 template <class OtherB, class OtherI>
236
242 template <class OtherB, class OtherI>
244
247
248 const pattern_type& pattern() const {
249 assert(pattern_ptr_);
250 return *pattern_ptr_;
251 }
252
253 private:
254 template <class X, class Y, class F, bool ClearRow = false>
255 void umvImpl(const X &x, Y &y, F &&op, std::bool_constant<ClearRow> = {}) const;
256
257 template <class X, class Y, class F>
258 void mtvImpl(const X &x, Y &y, F &&op) const;
259
260 protected:
261
263 void resetView(block_iter_type block_iter, pattern_type const* pattern_ptr)
264 {
265 block_iter_ = block_iter;
266 pattern_ptr_ = pattern_ptr;
267 }
268
271 return block_iter_;
272 }
273
276 return block_const_iter_type{block_iter_};
277 }
278
280 pattern_type const* patternPtr() const {
281 return pattern_ptr_;
282 }
283
284 private:
285 // View to underlying data
286 block_iter_type block_iter_ = {};
287 // View to underlying sparsity pattern.
288 pattern_type const* pattern_ptr_ = nullptr;
289 };
290} // namespace Dune::Experimental
291
292
293namespace Dune {
294
295 template <std::random_access_iterator B, class I>
296 struct FieldTraits<Experimental::MatrixView<B, I>>
297 : public FieldTraits<typename Experimental::MatrixView<B, I>::block_type>
298 {
299 };
300
301} // namespace Dune
302
303namespace Dune::Experimental {
304
305#if __cpp_lib_ranges_as_const <= 202311L
306
307 namespace Impl {
308 template<std::random_access_iterator B>
310 }
311
318 template <std::random_access_iterator B, class I>
320 : public Dune::IteratorFacade<block_const_iter_type,
321 std::random_access_iterator_tag,
322 std::remove_reference_t<Impl::iter_const_reference_t<B>>,
323 Impl::iter_const_reference_t<B>>
324 {
325 using Facade =
330
331 public:
333 using reference = typename Facade::reference;
336
338 constexpr block_const_iter_type() noexcept = default;
339
341 constexpr block_const_iter_type(const B& it) noexcept(std::is_nothrow_copy_constructible_v<B>)
342 : it_(it)
343 {}
344
346 constexpr block_const_iter_type& operator=(const B& it) noexcept(std::is_nothrow_copy_assignable_v<B>)
347 {
348 it_ = it;
349 return *this;
350 }
351
353 constexpr reference operator*() const { return *it_; }
354
356 constexpr friend auto operator<=>(const block_const_iter_type& it1,
357 const B& it2) noexcept
358 {
359 return it1.baseIterator() <=> it2;
360 }
361
363 constexpr friend auto operator<=>(const B& it1,
364 const block_const_iter_type& it2) noexcept
365 {
366 return it1 <=> it2.baseIterator();
367 }
368
369 private:
371
372 constexpr const B& baseIterator() const noexcept { return it_; }
373 constexpr B& baseIterator() noexcept { return it_; }
374
376 block_iter_type it_;
377 };
378#endif
379
386 template <std::random_access_iterator B, class I>
387 class MatrixView<B, I>::Iterator
388 : public Dune::IteratorFacade<Iterator, std::random_access_iterator_tag, row_type, row_type, Dune::ProxyArrowResult<row_type>>
389 {
391
392 constexpr Iterator(block_iter_type block_iter, pattern_type const* pattern_ptr, size_type row)
393 : block_iter_(block_iter), pattern_ptr_(pattern_ptr), row_(row)
394 {}
395
396 public:
397 using reference = typename Facade::reference;
398
400 constexpr reference operator*() const {
401 auto offset = pattern_ptr_->offset(row_);
402 return {block_iter_ + offset, pattern_ptr_->operator[](row_)};
403 }
404
406 constexpr size_type index() const { return row_; }
407
408 private:
410 friend MatrixView;
411
412 constexpr const size_type &baseIterator() const noexcept { return row_; }
413 constexpr size_type &baseIterator() noexcept { return row_; }
414
415 // View to underlying data
416 block_iter_type block_iter_ = {};
417 // View to underlying sparsity pattern.
418 pattern_type const* pattern_ptr_ = nullptr;
419 // The current logical row index of the iterator.
420 size_type row_ = 0;
421 };
422
429 template <std::random_access_iterator B, class I>
431 : public Dune::IteratorFacade<ConstIterator, std::random_access_iterator_tag, const_row_type, const_row_type, Dune::ProxyArrowResult<const_row_type>>
432 {
434
435 public:
436
438 ConstIterator() noexcept = default;
439
441 constexpr ConstIterator(const Iterator& it) noexcept(std::is_nothrow_copy_constructible_v<Iterator>)
442 : it_{it}
443 {}
444
446 constexpr ConstIterator &operator=(const Iterator &other) noexcept(std::is_nothrow_copy_assignable_v<Iterator>)
447 {
448 it_ = other;
449 return *this;
450 }
451
452 using reference = typename Facade::reference;
453
455 constexpr reference operator*() const {
456 auto offset = it_.pattern_ptr_->offset(index());
457 return {it_.block_iter_ + offset, it_.pattern_ptr_->operator[](index())};
458 }
459
461 constexpr size_type index() const { return it_.index(); }
462
463 private:
465 friend Iterator;
466 friend MatrixView;
467
468 constexpr const size_type &baseIterator() const noexcept { return it_.baseIterator(); }
469 constexpr size_type &baseIterator() noexcept { return it_.baseIterator(); }
470
472 Iterator it_ = {};
473 };
474
475 // MatrixView implementation
476
477 template <std::random_access_iterator B, class I>
479 {
480 // element-wise scaling of blocks
481 for (size_type i = 0; i != pattern().count(); ++i)
482 blockIter()[i] *= k;
483 return *this;
484 }
485
486 template <std::random_access_iterator B, class I>
488 {
489 // element-wise scaling of blocks
490 for (size_type i = 0; i != pattern().count(); ++i)
491 blockIter()[i] /= k;
492 return *this;
493 }
494
495 template <std::random_access_iterator B, class I>
496 template <class OtherB, class OtherI>
498 {
499 if (pattern_ptr_ == b.pattern_ptr_)
500 {
501 // element-wise addition of blocks
502 for (size_type i = 0; i != pattern().count(); ++i)
503 blockIter()[i] += b.blockIter()[i];
504 }
505 else if (pattern().size() == b.pattern().size() && pattern().range().size() == b.pattern().range().size())
506 {
507 // row-wise addition of blocks
508 for (size_type i = 0; i != pattern().size(); ++i)
509 this->operator[](i) += b.operator[](i);
510 }
511 else
512 {
513 DUNE_THROW(RangeError, "Matrix sizes do not match!");
514 }
515 return *this;
516 }
517
518 template <std::random_access_iterator B, class I>
519 template <class OtherB, class OtherI>
521 {
522 if (pattern_ptr_ == b.pattern_ptr_)
523 {
524 // element-wise subtraction of blocks
525 for (size_type i = 0; i != pattern().count(); ++i)
526 blockIter()[i] -= b.blockIter()[i];
527 }
528 else if (pattern().size() == b.pattern().size() && pattern().range().size() == b.pattern().range().size())
529 {
530 // row-wise subtraction of blocks
531 for (size_type i = 0; i != pattern().size(); ++i)
532 this->operator[](i) -= b.operator[](i);
533 }
534 else
535 {
536 DUNE_THROW(RangeError, "Matrix sizes do not match!");
537 }
538 return *this;
539 }
540
541 template <std::random_access_iterator B, class I>
543 {
544 for (size_type i = 0; i != pattern().count(); ++i)
545 blockIter()[i] = f;
546 return *this;
547 }
548
549 template <std::random_access_iterator B, class I>
550 template <class OtherB, class OtherI>
552 {
553 if (pattern_ptr_ == b.pattern_ptr_)
554 {
555 // element-wise axpy addition of blocks
556 for (size_type i = 0; i != pattern().count(); ++i)
557 Dune::Impl::asMatrix(blockIter()[i]).axpy(alpha, Dune::Impl::asMatrix(b.blockIter()[i]));
558 }
559 else if (pattern().size() == b.pattern().size() && pattern().range().size() == b.pattern().range().size())
560 {
561 // row-wise axpy addition of blocks
562 for (size_type i = 0; i != pattern().size(); ++i)
563 this->operator[](i).axpy(alpha, b.operator[](i));
564 }
565 else
566 {
567 DUNE_THROW(RangeError, "Matrix sizes do not match!");
568 }
569 return *this;
570 }
571
572 template <std::random_access_iterator B, class I>
573 template <class X, class Y, class F, bool ClearRow>
574 void MatrixView<B, I>::umvImpl(const X &x, Y &y, F &&op, std::bool_constant<ClearRow>) const
575 {
576#ifdef DUNE_ISTL_WITH_CHECKING
577 if (x.N() != M())
579 "Size mismatch: M: " << N() << "x" << M() << " x: " << x.N());
580 if (y.N() != N())
582 "Size mismatch: M: " << N() << "x" << M() << " y: " << y.N());
583#endif
584 for (size_type i = 0; i != N(); ++i) {
585 if constexpr (ClearRow)
586 y[i] = 0;
587 size_type nnz = pattern().offset(i);
588
589 for (size_type j : pattern()[i]) {
590 auto &&xj = Dune::Impl::asVector(x[j]);
591 auto &&yi = Dune::Impl::asVector(y[i]);
592 op(Dune::Impl::asMatrix(blockIter()[nnz]), xj, yi);
593 ++nnz;
594 }
595 }
596 }
597
598 template <std::random_access_iterator B, class I>
599 template <class X, class Y, class F>
600 void MatrixView<B, I>::mtvImpl(const X &x, Y &y, F &&op) const
601 {
602#ifdef DUNE_ISTL_WITH_CHECKING
603 if (y.N() != M())
604 DUNE_THROW(RangeError,
605 "Size mismatch: M: " << N() << "x" << M() << " y: " << y.N());
606 if (x.N() != N())
607 DUNE_THROW(RangeError,
608 "Size mismatch: M: " << N() << "x" << M() << " x: " << x.N());
609#endif
610 for (size_type i = 0; i != N(); ++i) {
611 size_type nnz = pattern().offset(i);
612 for (size_type j : pattern()[i]) {
613 auto &&xi = Dune::Impl::asVector(x[i]);
614 auto &&yj = Dune::Impl::asVector(y[j]);
615 op(Dune::Impl::asMatrix(blockIter()[nnz]), xi, yj);
616 ++nnz;
617 }
618 }
619 }
620
621 template <std::random_access_iterator B, class I>
622 template <class X, class Y>
623 void MatrixView<B, I>::mv(const X &x, Y &y) const
624 {
625 umvImpl(x, y, [](const auto &aij, const auto &xj, auto &yi){
626 aij.umv(xj, yi);
627 }, /* clear_row = */ std::bool_constant<true>{});
628 }
629
630 template <std::random_access_iterator B, class I>
631 template <class X, class Y>
632 void MatrixView<B, I>::umv(const X &x, Y &y) const
633 {
634 umvImpl(x, y, [](const auto &aij, const auto &xj, auto &yi){
635 aij.umv(xj, yi);
636 });
637 }
638
639 template <std::random_access_iterator B, class I>
640 template <class X, class Y>
641 void MatrixView<B, I>::mmv(const X &x, Y &y) const
642 {
643 umvImpl(x, y, [](const auto &aij, const auto &xj, auto &yi){
644 aij.mmv(xj, yi);
645 });
646 }
647
648 template <std::random_access_iterator B, class I>
649 template <class X, class Y>
650 void MatrixView<B, I>::usmv(const field_type &alpha, const X &x, Y &y) const
651 {
652 umvImpl(x, y, [&alpha](const auto &aij, const auto &xj, auto &yi){
653 aij.usmv(alpha, xj, yi);
654 });
655 }
656
657 template <std::random_access_iterator B, class I>
658 template <class X, class Y>
659 void MatrixView<B, I>::mtv(const X &x, Y &y) const
660 {
661 using ft = typename FieldTraits<Y>::field_type;
662 y = ft(0);
663 umtv(x, y);
664 }
665
666 template <std::random_access_iterator B, class I>
667 template <class X, class Y>
668 void MatrixView<B, I>::umtv(const X &x, Y &y) const
669 {
670 mtvImpl(x, y, [](const auto &aij, const auto &xi, auto &yj){
671 aij.umtv(xi, yj);
672 });
673 }
674
675 template <std::random_access_iterator B, class I>
676 template <class X, class Y>
677 void MatrixView<B, I>::mmtv(const X &x, Y &y) const
678 {
679 mtvImpl(x, y, [](const auto &aij, const auto &xi, auto &yj){
680 aij.mmtv(xi, yj);
681 });
682 }
683
684 template <std::random_access_iterator B, class I>
685 template <class X, class Y>
686 void MatrixView<B, I>::usmtv(const field_type &alpha, const X &x, Y &y) const
687 {
688 mtvImpl(x, y, [alpha](const auto &aij, const auto &xi, auto &yj){
689 aij.usmtv(alpha, xi, yj);
690 });
691 }
692
693 template <std::random_access_iterator B, class I>
694 template <class X, class Y>
695 void MatrixView<B, I>::umhv(const X &x, Y &y) const
696 {
697 mtvImpl(x, y, [](const auto &aij, const auto &xi, auto &yj){
698 aij.umhv(xi, yj);
699 });
700 }
701
702 template <std::random_access_iterator B, class I>
703 template <class X, class Y>
704 void MatrixView<B, I>::mmhv(const X &x, Y &y) const
705 {
706 mtvImpl(x, y, [](const auto &aij, const auto &xi, auto &yj){
707 aij.mmhv(xi, yj);
708 });
709 }
710
711 template <std::random_access_iterator B, class I>
712 template <class X, class Y>
713 void MatrixView<B, I>::usmhv(const field_type &alpha, const X &x, Y &y) const
714 {
715 mtvImpl(x, y, [alpha](const auto &aij, const auto &xi, auto &yj){
716 aij.usmhv(alpha, xi, yj);
717 });
718 }
719
720 template <std::random_access_iterator B, class I>
721 auto MatrixView<B, I>::frobenius_norm() const -> typename FieldTraits<field_type>::real_type
722 {
723 using std::sqrt;
724 return sqrt(frobenius_norm2());
725 }
726
727 template <std::random_access_iterator B, class I>
728 auto MatrixView<B, I>::frobenius_norm2() const -> typename FieldTraits<field_type>::real_type
729 {
730 using real_type = typename FieldTraits<field_type>::real_type;
731 real_type sum = 0;
732 for (auto const &a_i : *this)
733 for (auto const &a_ij : a_i)
734 sum += Dune::Impl::asMatrix(a_ij).frobenius_norm2();
735 return sum;
736 }
737
738 template <std::random_access_iterator B, class I>
739 auto MatrixView<B, I>::infinity_norm() const -> typename FieldTraits<field_type>::real_type
740 {
741 using real_type = typename FieldTraits<field_type>::real_type;
743
744 real_type norm = 0;
745 real_type markNaN = 1;
746 using std::max;
747
748 for (auto const &a_i : *this)
749 {
750 real_type const a = a_i.infinity_norm();
751 norm = max(a, norm);
752 if constexpr (hasNaN)
753 markNaN += a;
754 }
755 if constexpr (hasNaN)
756 {
757 // maintain NaN exception flags that raised the original NaN values.
758 std::fenv_t env;
759 int fpe = std::fegetenv(&env);
760 markNaN = markNaN / markNaN;
761 if (fpe != 0)
762 std::fesetenv(&env);
763 }
764
765 return (markNaN != markNaN) ? markNaN : norm;
766 }
767
769 template <std::random_access_iterator B, class I>
771 {
772 using real_type = typename FieldTraits<field_type>::real_type;
774
775 real_type norm = 0;
776 real_type markNaN = 1;
777 using std::max;
778
779 for (auto const &a_i : *this)
780 {
781 real_type const a = a_i.infinity_norm_real();
782 norm = max(a, norm);
783 if constexpr (hasNaN)
784 markNaN += a;
785 }
786 if constexpr (hasNaN)
787 {
788 // maintain NaN exception flags that raised the original NaN values.
789 std::fenv_t env;
790 int fpe = std::fegetenv(&env);
791 markNaN = markNaN / markNaN;
792 if (fpe != 0)
793 std::fesetenv(&env);
794 }
795
796 return (markNaN != markNaN) ? markNaN : norm;
797 }
798
799} // namespace Dune::Experimental
800
801#endif // DUNE_ISTL_EXPERIMENTAL_MATRIXVIEW_HH
Indexed vector view over random-access data with explicit indices.
STL namespace.
Definition experimental/bcrsmatrix.hh:21
@ pattern
Definition matrixmarket.hh:379
static constexpr size_type M()
static constexpr size_type N()
void umtv(const X &x, Y &y) const
double frobenius_norm2() const
std::ptrdiff_t index() const
#define DUNE_THROW(E,...)
ConstIterator const_iterator
Iterator type with const access to the underlying data.
Definition indexedarrayview.hh:204
Iterator iterator
Iterator type with mutable access to the underlying data.
Definition indexedarrayview.hh:202
bool contains(index_type i) const
Definition indexedarrayview.hh:229
Non-owning matrix view over external block storage and pattern.
Definition matrixview.hh:54
FieldTraits< field_type >::real_type infinity_norm() const
Return the block-aware infinity norm.
Definition matrixview.hh:739
void umtv(const X &x, Y &y) const
Compute .
Definition matrixview.hh:668
MatrixView & operator/=(const field_type &k)
Divide all stored blocks by k.
Definition matrixview.hh:487
void mv(const X &x, Y &y) const
Compute .
Definition matrixview.hh:623
MatrixView(block_iter_type block_iter, pattern_type const *pattern_ptr) noexcept
Construct a view from data iterator and sparsity pattern.
Definition matrixview.hh:104
Iterator begin()
Return iterator to the first row.
Definition matrixview.hh:115
std::iter_value_t< block_iter_type > block_type
The type of blocks in the matrix.
Definition matrixview.hh:70
size_type nonzeroes() const
Number of stored block entries.
Definition matrixview.hh:219
P pattern_type
The type used for the sparsity pattern.
Definition matrixview.hh:66
void usmhv(const field_type &alpha, const X &x, Y &y) const
Compute (Hermitian transpose).
Definition matrixview.hh:713
MatrixView & axpy(field_type alpha, const MatrixView< OtherB, OtherI > &b)
Compute .
B block_iter_type
The iterator type used to access the blocks of the matrix.
Definition matrixview.hh:57
ConstIterator cend() const
Return const iterator one past the last row.
Definition matrixview.hh:130
ConstIterator end() const
Return const iterator one past the last row.
Definition matrixview.hh:124
MatrixView & operator*=(const field_type &k)
Scale all stored blocks by k.
Definition matrixview.hh:478
block_const_iter_type blockIter() const
Return the underlying block iterator as a const iterator.
Definition matrixview.hh:275
FieldTraits< field_type >::real_type infinity_norm_real() const
Return simplified infinity norm (Manhattan norm for complex values).
Definition matrixview.hh:770
void usmtv(const field_type &alpha, const X &x, Y &y) const
Compute .
Definition matrixview.hh:686
size_type M() const
Number of block columns.
Definition matrixview.hh:211
void mmv(const X &x, Y &y) const
Compute .
Definition matrixview.hh:641
FieldTraits< field_type >::real_type frobenius_norm() const
Return the Frobenius norm .
Definition matrixview.hh:721
const_row_type operator[](size_type i) const
Return a const view of row i.
Definition matrixview.hh:112
std::ranges::range_value_t< pattern_type > row_index_range_type
The type used for the index set of rows.
Definition matrixview.hh:68
const pattern_type & pattern() const
Definition matrixview.hh:248
size_type N() const
Number of block rows.
Definition matrixview.hh:208
typename const_row_type::const_iterator ConstColIterator
The type of const row iterators over the column blocks.
Definition matrixview.hh:96
void mtv(const X &x, Y &y) const
Compute .
Definition matrixview.hh:659
void resetView(block_iter_type block_iter, pattern_type const *pattern_ptr)
Reset the view to point to block_iter and pattern_ptr.
Definition matrixview.hh:263
MatrixView & operator+=(const MatrixView< OtherB, OtherI > &b)
Add another matrix view to this one.
ConstIterator begin() const
Return const iterator to the first row.
Definition matrixview.hh:121
void umhv(const X &x, Y &y) const
Compute (Hermitian transpose).
Definition matrixview.hh:695
typename FieldTraits< block_type >::field_type field_type
The type of the field.
Definition matrixview.hh:76
FieldTraits< field_type >::real_type frobenius_norm2() const
Return (sum of squared block Frobenius norms).
Definition matrixview.hh:728
pattern_type const * patternPtr() const
Return the underlying pattern pointer.
Definition matrixview.hh:280
void usmv(const field_type &alpha, const X &x, Y &y) const
Compute .
Definition matrixview.hh:650
void umv(const X &x, Y &y) const
Compute .
Definition matrixview.hh:632
block_iter_type blockIter()
Return the underlying block iterator.
Definition matrixview.hh:270
row_type operator[](size_type i)
Return a mutable view of row i.
Definition matrixview.hh:109
bool exists(size_type i, size_type j) const DUNE_ISTL_WITH_CHECKING_NOEXCEPT
Test whether position is present in the sparsity pattern.
Definition matrixview.hh:198
MatrixView & operator=(const field_type &k)
Assign all stored blocks to scalar k.
Definition matrixview.hh:542
std::ranges::range_size_t< pattern_type > size_type
The type used to count elements in the row and column index sets.
Definition matrixview.hh:74
void mmhv(const X &x, Y &y) const
Compute (Hermitian transpose).
Definition matrixview.hh:704
MatrixView & operator-=(const MatrixView< OtherB, OtherI > &b)
Subtract another matrix view from this one.
typename row_type::iterator ColIterator
The type of mutable row iterators over the column blocks.
Definition matrixview.hh:94
void mmtv(const X &x, Y &y) const
Compute .
Definition matrixview.hh:677
Iterator end()
Return iterator one past the last row.
Definition matrixview.hh:118
ConstIterator cbegin() const
Return const iterator to the first row.
Definition matrixview.hh:127
Const block iterator adapter.
Definition matrixview.hh:324
constexpr block_const_iter_type() noexcept=default
Default constructor.
constexpr friend auto operator<=>(const block_const_iter_type &it1, const B &it2) noexcept
Compare const iterators for equality and ordering.
Definition matrixview.hh:356
constexpr friend auto operator<=>(const B &it1, const block_const_iter_type &it2) noexcept
Compare const iterators for equality and ordering.
Definition matrixview.hh:363
typename Facade::reference reference
The type used for references to the components.
Definition matrixview.hh:333
constexpr reference operator*() const
Reference to the component at the current iterator position.
Definition matrixview.hh:353
constexpr block_const_iter_type & operator=(const B &it) noexcept(std::is_nothrow_copy_assignable_v< B >)
Copy assignment operator from a mutable iterator.
Definition matrixview.hh:346
typename Facade::difference_type difference_type
The type used for differences between iterators.
Definition matrixview.hh:335
Mutable random-access iterator over matrix rows.
Definition matrixview.hh:389
constexpr reference operator*() const
Dereference to the row view at the current row index.
Definition matrixview.hh:400
constexpr size_type index() const
Return the current logical row index.
Definition matrixview.hh:406
typename Facade::reference reference
Definition matrixview.hh:397
Const random-access iterator over matrix rows.
Definition matrixview.hh:432
constexpr reference operator*() const
Dereference to the const row view at the current row index.
Definition matrixview.hh:455
constexpr ConstIterator & operator=(const Iterator &other) noexcept(std::is_nothrow_copy_assignable_v< Iterator >)
Assign from mutable iterator.
Definition matrixview.hh:446
ConstIterator() noexcept=default
Default constructor creating a singular iterator.
constexpr size_type index() const
Return the current logical row index.
Definition matrixview.hh:461
typename Facade::reference reference
Definition matrixview.hh:452
Non-owning block vector view with explicit indices.
Definition vectorview.hh:59
Error specific to BCRSMatrix.
Definition istlexception.hh:24
T fegetenv(T... args)
T max(T... args)
T sqrt(T... args)