DUNE-FEM (unstable)

fmatrix.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_FMATRIX_HH
6#define DUNE_FMATRIX_HH
7
8#include <cmath>
9#include <cstddef>
10#include <iostream>
11#include <algorithm>
12#include <initializer_list>
13#include <type_traits>
14
22#include <dune/common/matrixconcepts.hh>
23
24namespace Dune
25{
26
27 namespace Impl
28 {
29
30 template<class M>
31 class ColumnVectorView
32 {
33 public:
34
35 using value_type = typename M::value_type;
36 using size_type = typename M::size_type;
37
38 constexpr ColumnVectorView(M& matrix, size_type col) :
39 matrix_(matrix),
40 col_(col)
41 {}
42
43 constexpr size_type N () const {
44 return matrix_.N();
45 }
46
47 template<class M_ = M,
48 std::enable_if_t<std::is_same_v<M_,M> and not std::is_const_v<M_>, int> = 0>
49 constexpr value_type& operator[] (size_type row) {
50 return matrix_[row][col_];
51 }
52
53 constexpr const value_type& operator[] (size_type row) const {
54 return matrix_[row][col_];
55 }
56
57 protected:
58 M& matrix_;
59 const size_type col_;
60 };
61
62 }
63
64 template<typename M>
65 struct FieldTraits< Impl::ColumnVectorView<M> >
66 {
67 using field_type = typename FieldTraits<M>::field_type;
68 using real_type = typename FieldTraits<M>::real_type;
69 };
70
82 template< class K, int ROWS, int COLS = ROWS > class FieldMatrix;
83
84
85 template< class K, int ROWS, int COLS >
86 struct DenseMatVecTraits< FieldMatrix<K,ROWS,COLS> >
87 {
88 typedef FieldMatrix<K,ROWS,COLS> derived_type;
89
90 // each row is implemented by a field vector
91 typedef FieldVector<K,COLS> row_type;
92
93 typedef row_type &row_reference;
94 typedef const row_type &const_row_reference;
95
96 typedef std::array<row_type,ROWS> container_type;
97 typedef K value_type;
98 typedef typename container_type::size_type size_type;
99 };
100
101 template< class K, int ROWS, int COLS >
102 struct FieldTraits< FieldMatrix<K,ROWS,COLS> >
103 {
104 typedef typename FieldTraits<K>::field_type field_type;
105 typedef typename FieldTraits<K>::real_type real_type;
106 };
107
108
119 template<class M, int ROWS, int COLS>
121 : std::true_type {};
122
123 template<class K, int ROWS, int COLS>
124 struct IsFieldMatrixShapeCorrect<FieldMatrix<K,ROWS,COLS>,ROWS,COLS>
125 : std::true_type {};
126
127 template<class K, int ROWS, int COLS, int ROWS1, int COLS1>
128 struct IsFieldMatrixShapeCorrect<FieldMatrix<K,ROWS1,COLS1>,ROWS,COLS>
129 : std::false_type {};
130
131
140 template<class K, int ROWS, int COLS>
141 class FieldMatrix : public DenseMatrix< FieldMatrix<K,ROWS,COLS> >
142 {
143 template<class,int,int> friend class FieldMatrix;
145
147 std::array< FieldVector<K,COLS>, ROWS > _data;
148
149 public:
150
152 static constexpr std::integral_constant<int, ROWS> rows = {};
153
155 static constexpr std::integral_constant<int, COLS> cols = {};
156
158 using size_type = typename Base::size_type;
159
161 using value_type = typename Base::value_type;
162
165
168
170 using row_type = typename Base::row_type;
171
174
177
178 public:
179
182
184 constexpr FieldMatrix ()
185 noexcept(std::is_nothrow_default_constructible_v<K>)
186 : _data{}
187 {}
188
190 constexpr FieldMatrix (std::initializer_list<Dune::FieldVector<K, cols> > const &l)
191 : _data{}
192 {
193 DUNE_ASSERT_BOUNDS(l.size() == rows);
194 for (size_type i = 0; i < rows; ++i)
195 _data[i] = std::data(l)[i];
196 }
197
199 template <class OtherK, int otherRows, int otherCols>
200 requires (otherRows != ROWS || otherCols != COLS)
202
204 template <class OtherMatrix>
205 requires (HasDenseMatrixAssigner<FieldMatrix, OtherMatrix>::value)
206 constexpr FieldMatrix (const OtherMatrix& rhs)
207 : _data{}
208 {
210 }
211
213
215 template <class OtherK, int otherRows, int otherCols>
216 requires (otherRows != ROWS || otherCols != COLS)
217 constexpr FieldMatrix& operator= (const FieldMatrix<OtherK, otherRows, otherCols>&) = delete;
218
220 using Base::operator=;
221
224 {
226 for( int i = 0; i < ROWS; ++i )
227 for( int j = 0; j < COLS; ++j )
228 AT[j][i] = (*this)[i][j];
229 return AT;
230 }
231
232
235
237 template <class OtherK>
238 friend constexpr auto operator+ (const FieldMatrix& matrixA,
239 const FieldMatrix<OtherK,ROWS,COLS>& matrixB)
240 {
242 for (size_type i = 0; i < ROWS; ++i)
243 for (size_type j = 0; j < COLS; ++j)
244 result[i][j] = matrixA[i][j] + matrixB[i][j];
245 return result;
246 }
247
249 template <Concept::Number S>
250 friend constexpr auto operator+ (const FieldMatrix& a, const S& b) noexcept
251 requires(ROWS*COLS == 1)
252 {
253 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
254 return FieldMatrix<ResultValueType,1,1>{a[0][0] + b};
255 }
256
258 template <Concept::Number S>
259 friend constexpr auto operator+ (const S& a, const FieldMatrix& b) noexcept
260 requires(ROWS*COLS == 1)
261 {
262 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
263 return FieldMatrix<ResultValueType,1,1>{a + b[0][0]};
264 }
265
267 template <Concept::Number S>
268 constexpr FieldMatrix& operator+= (const S& scalar)
269 requires(ROWS*COLS == 1)
270 {
271 _data[0][0] += scalar;
272 return *this;
273 }
274
275 using Base::operator+=;
276
278 template <class OtherK>
279 friend constexpr auto operator- (const FieldMatrix& matrixA,
280 const FieldMatrix<OtherK,ROWS,COLS>& matrixB)
281 {
283 for (size_type i = 0; i < ROWS; ++i)
284 for (size_type j = 0; j < COLS; ++j)
285 result[i][j] = matrixA[i][j] - matrixB[i][j];
286 return result;
287 }
288
290 template<Concept::Number S>
291 friend constexpr auto operator- (const FieldMatrix& a, const S& b) noexcept
292 requires(ROWS*COLS == 1)
293 {
294 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
295 return FieldMatrix<ResultValueType,1,1>{a[0][0] - b};
296 }
297
299 template<Concept::Number S>
300 friend constexpr auto operator- (const S& a, const FieldMatrix& b) noexcept
301 requires(ROWS*COLS == 1)
302 {
303 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
304 return FieldMatrix<ResultValueType,1,1>{a - b[0][0]};
305 }
306
308 template <Concept::Number S>
309 constexpr FieldMatrix& operator-= (const S& scalar)
310 requires(ROWS*COLS == 1)
311 {
312 _data[0][0] -= scalar;
313 return *this;
314 }
315
316 using Base::operator-=;
317
319 template <Concept::Number S>
320 friend constexpr auto operator* (const FieldMatrix& matrix, const S& scalar)
321 {
323 for (size_type i = 0; i < ROWS; ++i)
324 for (size_type j = 0; j < COLS; ++j)
325 result[i][j] = matrix[i][j] * scalar;
326 return result;
327 }
328
330 template <Concept::Number S>
331 friend constexpr auto operator* (const S& scalar, const FieldMatrix& matrix)
332 {
334 for (size_type i = 0; i < ROWS; ++i)
335 for (size_type j = 0; j < COLS; ++j)
336 result[i][j] = scalar * matrix[i][j];
337 return result;
338 }
339
341 template <Concept::Number S>
342 constexpr FieldMatrix& operator*= (const S& scalar)
343 requires(ROWS*COLS == 1)
344 {
345 _data[0][0] *= scalar;
346 return *this;
347 }
348
349 using Base::operator*=;
350
352 template <Concept::Number S>
353 friend constexpr auto operator/ (const FieldMatrix& matrix, const S& scalar)
354 {
356 for (size_type i = 0; i < ROWS; ++i)
357 for (size_type j = 0; j < COLS; ++j)
358 result[i][j] = matrix[i][j] / scalar;
359 return result;
360 }
361
363 template<Concept::Number S>
364 friend constexpr FieldMatrix operator/ (const S& a, const FieldMatrix& b) noexcept
365 requires(ROWS*COLS == 1)
366 {
367 return FieldMatrix{a / b[0][0]};
368 }
369
371 template <Concept::Number S>
372 constexpr FieldMatrix& operator/= (const S& scalar)
373 requires(ROWS*COLS == 1)
374 {
375 _data[0][0] /= scalar;
376 return *this;
377 }
378
379 using Base::operator/=;
380
382
383
386
388 template <class OtherK, int otherCols>
389 friend constexpr auto operator* (const FieldMatrix& matrixA,
391 {
393
394 for (size_type i = 0; i < matrixA.mat_rows(); ++i)
395 for (size_type j = 0; j < matrixB.mat_cols(); ++j)
396 {
397 result[i][j] = 0;
398 for (size_type k = 0; k < matrixA.mat_cols(); ++k)
399 result[i][j] += matrixA[i][k] * matrixB[k][j];
400 }
401
402 return result;
403 }
404
411 template <class OtherMatrix>
412 requires (Impl::IsStaticSizeMatrix_v<OtherMatrix> and not Impl::IsFieldMatrix_v<OtherMatrix>)
413 friend constexpr auto operator* (const FieldMatrix& matrixA,
414 const OtherMatrix& matrixB)
415 {
416 using Field = typename PromotionTraits<K, typename OtherMatrix::field_type>::PromotedType;
418 for (size_type j = 0; j < rows; ++j)
419 matrixB.mtv(matrixA[j], result[j]);
420 return result;
421 }
422
429 template <class OtherMatrix>
430 requires (Impl::IsStaticSizeMatrix_v<OtherMatrix> and not Impl::IsFieldMatrix_v<OtherMatrix>)
431 friend constexpr auto operator* (const OtherMatrix& matrixA,
432 const FieldMatrix& matrixB)
433 {
434 using Field = typename PromotionTraits<K, typename OtherMatrix::field_type>::PromotedType;
436 for (size_type j = 0; j < cols; ++j)
437 {
438 auto B_j = Impl::ColumnVectorView(matrixB, j);
439 auto result_j = Impl::ColumnVectorView(result, j);
440 matrixA.mv(B_j, result_j);
441 }
442 return result;
443 }
444
446 template<int l>
448 {
449 return M * (*this);
450 }
451
453
455 template <int r, int c>
457 {
458 static_assert(r == c, "Cannot rightmultiply with non-square matrix");
459 static_assert(r == cols, "Size mismatch");
461
462 for (size_type i=0; i<rows; i++)
463 for (size_type j=0; j<cols; j++) {
464 (*this)[i][j] = 0;
465 for (size_type k=0; k<cols; k++)
466 (*this)[i][j] += C[i][k]*M[k][j];
467 }
468 return *this;
469 }
470
472 template<int l>
474 {
475 return (*this) * M;
476 }
477
479
480
483
484 // internal: return the number of rows
485 static constexpr size_type mat_rows() { return ROWS; }
486
487 // internal: return the number of columns
488 static constexpr size_type mat_cols() { return COLS; }
489
491
492
495
496 // internal: return a reference to the ith row
497 constexpr row_reference mat_access (size_type i)
498 {
499 DUNE_ASSERT_BOUNDS(i < ROWS);
500 return _data[i];
501 }
502
503 // internal: return a const reference to the ith row
504 constexpr const_row_reference mat_access (size_type i) const
505 {
506 DUNE_ASSERT_BOUNDS(i < ROWS);
507 return _data[i];
508 }
509
511 constexpr operator const_reference () const noexcept
512 requires(ROWS*COLS == 1)
513 {
514 return _data[0][0];
515 }
516
518 constexpr operator reference () noexcept
519 requires(ROWS*COLS == 1)
520 {
521 return _data[0][0];
522 }
523
525
526
529
531 template<Concept::Number S>
532 friend constexpr bool operator== (const FieldMatrix& a, const S& b) noexcept
533 requires(ROWS*COLS == 1)
534 {
535 return a._data[0] == b;
536 }
537
539 template<Concept::Number S>
540 friend constexpr bool operator== (const S& a, const FieldMatrix& b) noexcept
541 requires(ROWS*COLS == 1)
542 {
543 return a == b._data[0];
544 }
545
547 template<class OtherK>
549 friend constexpr auto operator<=> (const FieldMatrix& a, const FieldMatrix<OtherK,ROWS,COLS>& b) noexcept
550 {
551#if __cpp_lib_three_way_comparison
552 return a._data <=> b._data;
553#else
554 return Std::lexicographical_compare_three_way(a.begin(), a.end(), b.begin(), b.end());
555#endif
556 }
557
559 template<Concept::Number S>
560 friend constexpr auto operator<=> (const FieldMatrix& a, const S& b) noexcept
561 requires(ROWS*COLS == 1)
562 {
563 return a._data[0] <=> b;
564 }
565
567 template<Concept::Number S>
568 friend constexpr auto operator<=> (const S& a, const FieldMatrix& b) noexcept
569 requires(ROWS*COLS == 1)
570 {
571 return a <=> b._data[0];
572 }
573
575 };
576
578 template<typename K>
579 std::ostream& operator<< (std::ostream& s, const FieldMatrix<K,1,1>& a)
580 {
581 s << a[0][0];
582 return s;
583 }
584
585 namespace FMatrixHelp {
586
588 template <typename K>
589 static constexpr K invertMatrix (const FieldMatrix<K,1,1> &matrix, FieldMatrix<K,1,1> &inverse)
590 {
591 using real_type = typename FieldTraits<K>::real_type;
592 inverse[0][0] = real_type(1.0)/matrix[0][0];
593 return matrix[0][0];
594 }
595
597 template <typename K>
598 static constexpr K invertMatrix_retTransposed (const FieldMatrix<K,1,1> &matrix, FieldMatrix<K,1,1> &inverse)
599 {
600 return invertMatrix(matrix,inverse);
601 }
602
603
605 template <typename K>
606 static constexpr K invertMatrix (const FieldMatrix<K,2,2> &matrix, FieldMatrix<K,2,2> &inverse)
607 {
608 using real_type = typename FieldTraits<K>::real_type;
609 // code generated by maple
610 K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]);
611 K det_1 = real_type(1.0)/det;
612 inverse[0][0] = matrix[1][1] * det_1;
613 inverse[0][1] = - matrix[0][1] * det_1;
614 inverse[1][0] = - matrix[1][0] * det_1;
615 inverse[1][1] = matrix[0][0] * det_1;
616 return det;
617 }
618
621 template <typename K>
622 static constexpr K invertMatrix_retTransposed (const FieldMatrix<K,2,2> &matrix, FieldMatrix<K,2,2> &inverse)
623 {
624 using real_type = typename FieldTraits<K>::real_type;
625 // code generated by maple
626 K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]);
627 K det_1 = real_type(1.0)/det;
628 inverse[0][0] = matrix[1][1] * det_1;
629 inverse[1][0] = - matrix[0][1] * det_1;
630 inverse[0][1] = - matrix[1][0] * det_1;
631 inverse[1][1] = matrix[0][0] * det_1;
632 return det;
633 }
634
636 template <typename K>
637 static constexpr K invertMatrix (const FieldMatrix<K,3,3> &matrix, FieldMatrix<K,3,3> &inverse)
638 {
639 using real_type = typename FieldTraits<K>::real_type;
640 // code generated by maple
641 K t4 = matrix[0][0] * matrix[1][1];
642 K t6 = matrix[0][0] * matrix[1][2];
643 K t8 = matrix[0][1] * matrix[1][0];
644 K t10 = matrix[0][2] * matrix[1][0];
645 K t12 = matrix[0][1] * matrix[2][0];
646 K t14 = matrix[0][2] * matrix[2][0];
647
648 K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+
649 t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]);
650 K t17 = real_type(1.0)/det;
651
652 inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17;
653 inverse[0][1] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17;
654 inverse[0][2] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17;
655 inverse[1][0] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17;
656 inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17;
657 inverse[1][2] = -(t6-t10) * t17;
658 inverse[2][0] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17;
659 inverse[2][1] = -(matrix[0][0] * matrix[2][1] - t12) * t17;
660 inverse[2][2] = (t4-t8) * t17;
661
662 return det;
663 }
664
666 template <typename K>
667 static constexpr K invertMatrix_retTransposed (const FieldMatrix<K,3,3> &matrix, FieldMatrix<K,3,3> &inverse)
668 {
669 using real_type = typename FieldTraits<K>::real_type;
670 // code generated by maple
671 K t4 = matrix[0][0] * matrix[1][1];
672 K t6 = matrix[0][0] * matrix[1][2];
673 K t8 = matrix[0][1] * matrix[1][0];
674 K t10 = matrix[0][2] * matrix[1][0];
675 K t12 = matrix[0][1] * matrix[2][0];
676 K t14 = matrix[0][2] * matrix[2][0];
677
678 K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+
679 t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]);
680 K t17 = real_type(1.0)/det;
681
682 inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17;
683 inverse[1][0] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17;
684 inverse[2][0] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17;
685 inverse[0][1] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17;
686 inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17;
687 inverse[2][1] = -(t6-t10) * t17;
688 inverse[0][2] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17;
689 inverse[1][2] = -(matrix[0][0] * matrix[2][1] - t12) * t17;
690 inverse[2][2] = (t4-t8) * t17;
691
692 return det;
693 }
694
696 template< class K, int m, int n, int p >
697 static constexpr void multMatrix ( const FieldMatrix< K, m, n > &A,
698 const FieldMatrix< K, n, p > &B,
700 {
701 typedef typename FieldMatrix< K, m, p > :: size_type size_type;
702
703 for( size_type i = 0; i < m; ++i )
704 {
705 for( size_type j = 0; j < p; ++j )
706 {
707 ret[ i ][ j ] = K( 0 );
708 for( size_type k = 0; k < n; ++k )
709 ret[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ];
710 }
711 }
712 }
713
715 template <typename K, int rows, int cols>
717 {
718 typedef typename FieldMatrix<K,rows,cols>::size_type size_type;
719
720 for(size_type i=0; i<cols; i++)
721 for(size_type j=0; j<cols; j++)
722 {
723 ret[i][j]=0.0;
724 for(size_type k=0; k<rows; k++)
725 ret[i][j]+=matrix[k][i]*matrix[k][j];
726 }
727 }
728
729 using Dune::DenseMatrixHelp::multAssign;
730
732 template <typename K, int rows, int cols>
733 static constexpr void multAssignTransposed( const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,rows> & x, FieldVector<K,cols> & ret)
734 {
735 typedef typename FieldMatrix<K,rows,cols>::size_type size_type;
736
737 for(size_type i=0; i<cols; ++i)
738 {
739 ret[i] = 0.0;
740 for(size_type j=0; j<rows; ++j)
741 ret[i] += matrix[j][i]*x[j];
742 }
743 }
744
746 template <typename K, int rows, int cols>
747 static constexpr FieldVector<K,rows> mult(const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,cols> & x)
748 {
750 multAssign(matrix,x,ret);
751 return ret;
752 }
753
755 template <typename K, int rows, int cols>
757 {
759 multAssignTransposed( matrix, x, ret );
760 return ret;
761 }
762
763 } // end namespace FMatrixHelp
764
767} // end namespace
768
769#include "fmatrixev.hh"
770#endif
Macro for wrapping boundary checks.
A dense n x m matrix.
Definition: densematrix.hh:145
constexpr size_type M() const
number of columns
Definition: densematrix.hh:708
FieldMatrix< K, ROWS, COLS > & rightmultiply(const DenseMatrix< M2 > &M)
Multiplies M from the right to this matrix.
Definition: densematrix.hh:650
Traits::value_type value_type
export the type representing the field
Definition: densematrix.hh:162
constexpr Iterator end()
end iterator
Definition: densematrix.hh:227
constexpr derived_type operator-() const
Matrix negation.
Definition: densematrix.hh:303
constexpr void mtv(const X &x, Y &y) const
y = A^T x
Definition: densematrix.hh:392
Traits::row_type row_type
The type used to represent a row (must fulfill the Dune::DenseVector interface)
Definition: densematrix.hh:174
Traits::size_type size_type
The type used for the index access and size operation.
Definition: densematrix.hh:171
Traits::const_row_reference const_row_reference
The type used to represent a reference to a constant row (usually const row_type &)
Definition: densematrix.hh:180
Traits::row_reference row_reference
The type used to represent a reference to a row (usually row_type &)
Definition: densematrix.hh:177
constexpr Iterator begin()
begin iterator
Definition: densematrix.hh:221
A dense n x m matrix.
Definition: fmatrix.hh:142
typename Base::size_type size_type
The type used for the index access and size operation.
Definition: fmatrix.hh:158
constexpr FieldMatrix & operator/=(const S &scalar)
division by scalar
Definition: fmatrix.hh:372
constexpr FieldMatrix< K, rows, l > rightmultiplyany(const FieldMatrix< K, cols, l > &M) const
Multiplies M from the right to this matrix, this matrix is not modified.
Definition: fmatrix.hh:473
constexpr FieldMatrix() noexcept(std::is_nothrow_default_constructible_v< K >)
Default constructor, making value-initialized matrix with all components set to zero.
Definition: fmatrix.hh:184
static constexpr std::integral_constant< int, ROWS > rows
The number of rows.
Definition: fmatrix.hh:152
static constexpr std::integral_constant< int, COLS > cols
The number of columns.
Definition: fmatrix.hh:155
constexpr FieldMatrix & rightmultiply(const FieldMatrix< K, r, c > &M)
Multiplies M from the right to this matrix.
Definition: fmatrix.hh:456
constexpr FieldMatrix & operator+=(const S &scalar)
add scalar
Definition: fmatrix.hh:268
constexpr FieldMatrix & operator-=(const S &scalar)
subtract scalar
Definition: fmatrix.hh:309
friend constexpr auto operator*(const FieldMatrix &matrix, const S &scalar)
vector space multiplication with scalar
Definition: fmatrix.hh:320
constexpr FieldMatrix(std::initializer_list< Dune::FieldVector< K, cols > > const &l)
Constructor initializing the matrix from a nested list of values.
Definition: fmatrix.hh:190
friend constexpr auto operator<=>(const FieldMatrix &a, const FieldMatrix< OtherK, ROWS, COLS > &b) noexcept
three-way comparison of FieldMatrix
Definition: fmatrix.hh:549
typename Base::row_type row_type
The type the rows of the matrix are represented by.
Definition: fmatrix.hh:170
friend constexpr auto operator+(const FieldMatrix &matrixA, const FieldMatrix< OtherK, ROWS, COLS > &matrixB)
vector space addition
Definition: fmatrix.hh:238
typename Base::const_row_reference const_row_reference
The type used for const references to the rows of the matrix.
Definition: fmatrix.hh:176
constexpr FieldMatrix & operator*=(const S &scalar)
multiplication with scalar
Definition: fmatrix.hh:342
friend constexpr bool operator==(const FieldMatrix &a, const S &b) noexcept
comparing FieldMatrix<1,1> with scalar for equality
Definition: fmatrix.hh:532
typename Base::value_type value_type
The type of the elements stored in the matrix.
Definition: fmatrix.hh:161
const value_type & const_reference
The type used for const references to the matrix entries.
Definition: fmatrix.hh:167
constexpr FieldMatrix< K, COLS, ROWS > transposed() const
Return transposed of the matrix as FieldMatrix.
Definition: fmatrix.hh:223
friend constexpr auto operator/(const FieldMatrix &matrix, const S &scalar)
vector space division by scalar
Definition: fmatrix.hh:353
constexpr FieldMatrix< K, l, cols > leftmultiplyany(const FieldMatrix< K, l, rows > &M) const
Multiplies M from the left to this matrix, this matrix is not modified.
Definition: fmatrix.hh:447
typename Base::row_reference row_reference
The type used for references to the rows of the matrix.
Definition: fmatrix.hh:173
value_type & reference
The type used for references to the matrix entries.
Definition: fmatrix.hh:164
vector space out of a tensor product of fields.
Definition: fvector.hh:97
The concept std::three_way_comparable_with specifies that the three way comparison operator <=> on (p...
Definition: compare.hh:100
Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
A few common exception classes.
static constexpr void multAssignTransposed(const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, rows > &x, FieldVector< K, cols > &ret)
calculates ret = matrix^T * x
Definition: fmatrix.hh:733
static constexpr FieldVector< K, cols > multTransposed(const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, rows > &x)
calculates ret = matrix^T * x
Definition: fmatrix.hh:756
static constexpr K invertMatrix_retTransposed(const FieldMatrix< K, 1, 1 > &matrix, FieldMatrix< K, 1, 1 > &inverse)
invert scalar without changing the original matrix
Definition: fmatrix.hh:598
static constexpr void multTransposedMatrix(const FieldMatrix< K, rows, cols > &matrix, FieldMatrix< K, cols, cols > &ret)
calculates ret= A_t*A
Definition: fmatrix.hh:716
static constexpr void multMatrix(const FieldMatrix< K, m, n > &A, const FieldMatrix< K, n, p > &B, FieldMatrix< K, m, p > &ret)
calculates ret = A * B
Definition: fmatrix.hh:697
static constexpr K invertMatrix(const FieldMatrix< K, 1, 1 > &matrix, FieldMatrix< K, 1, 1 > &inverse)
invert scalar without changing the original matrix
Definition: fmatrix.hh:589
static constexpr FieldVector< K, rows > mult(const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, cols > &x)
calculates ret = matrix * x
Definition: fmatrix.hh:747
Eigenvalue computations for the FieldMatrix class.
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition: boundschecking.hh:30
std::ostream & operator<<(std::ostream &s, const FieldMatrix< K, 1, 1 > &a)
Sends the matrix to an output stream.
Definition: fmatrix.hh:579
constexpr auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2, Cmp comp={}) -> decltype(comp(*f1, *f2))
Lexicographically compares two ranges [first1, last1) and [first2, last2) using three-way comparison ...
Definition: algorithm.hh:37
Dune namespace
Definition: alignedallocator.hh:13
STL namespace.
Various precision settings for calculations with FieldMatrix and FieldVector.
Compute type of the result of an arithmetic operation involving two different number types.
you have to specialize this structure for any type that should be assignable to a DenseMatrix
Definition: densematrix.hh:61
TMP to check the shape of a DenseMatrix statically, if possible.
Definition: fmatrix.hh:121
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Feb 16, 23:40, 2026)