dune-common 2.12-git
Loading...
Searching...
No Matches
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
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 {
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 {
89
90 // each row is implemented by a field vector
92
95
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 {
106 };
107
108
119 template<class M, int ROWS, int COLS>
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
148
149 public:
150
153
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
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 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
251 friend constexpr auto operator+ (const FieldMatrix& a, const S& b) noexcept
252 requires(ROWS*COLS == 1)
253 {
254 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
255 return FieldMatrix<ResultValueType,1,1>{ResultValueType(a[0][0] + b)};
256 }
257
259 template <Concept::Number S>
260 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
261 friend constexpr auto operator+ (const S& a, const FieldMatrix& b) noexcept
262 requires(ROWS*COLS == 1)
263 {
264 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
265 return FieldMatrix<ResultValueType,1,1>{ResultValueType(a + b[0][0])};
266 }
267
269 template <Concept::Number S>
270 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
271 constexpr FieldMatrix& operator+= (const S& scalar)
272 requires(ROWS*COLS == 1)
273 {
274 _data[0][0] += scalar;
275 return *this;
276 }
277
278 using Base::operator+=;
279
281 template <class OtherK>
282 friend constexpr auto operator- (const FieldMatrix& matrixA,
283 const FieldMatrix<OtherK,ROWS,COLS>& matrixB)
284 {
286 for (size_type i = 0; i < ROWS; ++i)
287 for (size_type j = 0; j < COLS; ++j)
288 result[i][j] = matrixA[i][j] - matrixB[i][j];
289 return result;
290 }
291
293 template<Concept::Number S>
294 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
295 friend constexpr auto operator- (const FieldMatrix& a, const S& b) noexcept
296 requires(ROWS*COLS == 1)
297 {
298 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
299 return FieldMatrix<ResultValueType,1,1>{ResultValueType(a[0][0] - b)};
300 }
301
303 template<Concept::Number S>
304 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
305 friend constexpr auto operator- (const S& a, const FieldMatrix& b) noexcept
306 requires(ROWS*COLS == 1)
307 {
308 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
309 return FieldMatrix<ResultValueType,1,1>{ResultValueType(a - b[0][0])};
310 }
311
313 template <Concept::Number S>
314 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
315 constexpr FieldMatrix& operator-= (const S& scalar)
316 requires(ROWS*COLS == 1)
317 {
318 _data[0][0] -= scalar;
319 return *this;
320 }
321
322 using Base::operator-=;
323
325 template <Concept::Number S>
326 friend constexpr auto operator* (const FieldMatrix& matrix, const S& scalar)
327 {
329 for (size_type i = 0; i < ROWS; ++i)
330 for (size_type j = 0; j < COLS; ++j)
331 result[i][j] = matrix[i][j] * scalar;
332 return result;
333 }
334
336 template <Concept::Number S>
337 friend constexpr auto operator* (const S& scalar, const FieldMatrix& matrix)
338 {
340 for (size_type i = 0; i < ROWS; ++i)
341 for (size_type j = 0; j < COLS; ++j)
342 result[i][j] = scalar * matrix[i][j];
343 return result;
344 }
345
354 template <Concept::Number S>
355 constexpr FieldMatrix& operator*= (const S& scalar)
356 requires(ROWS*COLS == 1)
357 {
358 _data[0][0] *= scalar;
359 return *this;
360 }
361
362 using Base::operator*=;
363
365 template <Concept::Number S>
366 friend constexpr auto operator/ (const FieldMatrix& matrix, const S& scalar)
367 {
369 for (size_type i = 0; i < ROWS; ++i)
370 for (size_type j = 0; j < COLS; ++j)
371 result[i][j] = matrix[i][j] / scalar;
372 return result;
373 }
374
376 template<Concept::Number S>
377 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
378 friend constexpr auto operator/ (const S& a, const FieldMatrix& b) noexcept
379 requires(ROWS*COLS == 1)
380 {
381 using ResultValueType = typename PromotionTraits<K,S>::PromotedType;
382 return FieldMatrix<ResultValueType,1,1>{ResultValueType(a / b[0][0])};
383 }
384
393 template <Concept::Number S>
394 constexpr FieldMatrix& operator/= (const S& scalar)
395 requires(ROWS*COLS == 1)
396 {
397 _data[0][0] /= scalar;
398 return *this;
399 }
400
401 using Base::operator/=;
402
404
405
408
410 template <class OtherK, int otherCols>
411 friend constexpr auto operator* (const FieldMatrix& matrixA,
413 {
415
416 for (size_type i = 0; i < matrixA.mat_rows(); ++i)
417 for (size_type j = 0; j < matrixB.mat_cols(); ++j)
418 {
419 result[i][j] = 0;
420 for (size_type k = 0; k < matrixA.mat_cols(); ++k)
421 result[i][j] += matrixA[i][k] * matrixB[k][j];
422 }
423
424 return result;
425 }
426
433 template <class OtherMatrix>
434 requires (Impl::IsStaticSizeMatrix_v<OtherMatrix> and not Impl::IsFieldMatrix_v<OtherMatrix>)
435 friend constexpr auto operator* (const FieldMatrix& matrixA,
436 const OtherMatrix& matrixB)
437 {
440 for (size_type j = 0; j < rows; ++j)
441 matrixB.mtv(matrixA[j], result[j]);
442 return result;
443 }
444
451 template <class OtherMatrix>
452 requires (Impl::IsStaticSizeMatrix_v<OtherMatrix> and not Impl::IsFieldMatrix_v<OtherMatrix>)
453 friend constexpr auto operator* (const OtherMatrix& matrixA,
454 const FieldMatrix& matrixB)
455 {
458 for (size_type j = 0; j < cols; ++j)
459 {
460 auto B_j = Impl::ColumnVectorView(matrixB, j);
461 auto result_j = Impl::ColumnVectorView(result, j);
462 matrixA.mv(B_j, result_j);
463 }
464 return result;
465 }
466
468 template<int l>
470 {
471 return M * (*this);
472 }
473
475
477 template <int r, int c>
479 {
480 static_assert(r == c, "Cannot rightmultiply with non-square matrix");
481 static_assert(r == cols, "Size mismatch");
483
484 for (size_type i=0; i<rows; i++)
485 for (size_type j=0; j<cols; j++) {
486 (*this)[i][j] = 0;
487 for (size_type k=0; k<cols; k++)
488 (*this)[i][j] += C[i][k]*M[k][j];
489 }
490 return *this;
491 }
492
494 template<int l>
496 {
497 return (*this) * M;
498 }
499
501
502
505
506 // internal: return the number of rows
507 static constexpr size_type mat_rows() { return ROWS; }
508
509 // internal: return the number of columns
510 static constexpr size_type mat_cols() { return COLS; }
511
513
514
517
518 // internal: return a reference to the ith row
520 {
521 DUNE_ASSERT_BOUNDS(i < ROWS);
522 return _data[i];
523 }
524
525 // internal: return a const reference to the ith row
527 {
528 DUNE_ASSERT_BOUNDS(i < ROWS);
529 return _data[i];
530 }
531
533 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
534 constexpr operator const_reference () const noexcept
535 requires(ROWS*COLS == 1)
536 {
537 return _data[0][0];
538 }
539
541 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
542 constexpr operator reference () noexcept
543 requires(ROWS*COLS == 1)
544 {
545 return _data[0][0];
546 }
547
549
550
553
555 template<Concept::Number S>
556 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
557 friend constexpr bool operator== (const FieldMatrix& a, const S& b) noexcept
558 requires(ROWS*COLS == 1)
559 {
560 return a._data[0] == b;
561 }
562
564 template<Concept::Number S>
565 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
566 friend constexpr bool operator== (const S& a, const FieldMatrix& b) noexcept
567 requires(ROWS*COLS == 1)
568 {
569 return a == b._data[0];
570 }
571
573 template<class OtherK>
575 friend constexpr auto operator<=> (const FieldMatrix& a, const FieldMatrix<OtherK,ROWS,COLS>& b) noexcept
576 {
577#if __cpp_lib_three_way_comparison
578 return a._data <=> b._data;
579#else
580 return Std::lexicographical_compare_three_way(a.begin(), a.end(), b.begin(), b.end());
581#endif
582 }
583
585 template<Concept::Number S>
586 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
587 friend constexpr auto operator<=> (const FieldMatrix& a, const S& b) noexcept
588 requires(ROWS*COLS == 1)
589 {
590 return a._data[0] <=> b;
591 }
592
594 template<Concept::Number S>
595 [[deprecated("Please use 1x1 FieldMatrix objects like matrices, not like scalars!")]]
596 friend constexpr auto operator<=> (const S& a, const FieldMatrix& b) noexcept
597 requires(ROWS*COLS == 1)
598 {
599 return a <=> b._data[0];
600 }
601
603 };
604
612 template<typename K>
614 {
615 s << a[0][0];
616 return s;
617 }
618
619 namespace FMatrixHelp {
620
622 template <typename K>
623 static constexpr K invertMatrix (const FieldMatrix<K,1,1> &matrix, FieldMatrix<K,1,1> &inverse)
624 {
625 using real_type = typename FieldTraits<K>::real_type;
626 inverse[0][0] = real_type(1.0)/matrix[0][0];
627 return matrix[0][0];
628 }
629
631 template <typename K>
632 static constexpr K invertMatrix_retTransposed (const FieldMatrix<K,1,1> &matrix, FieldMatrix<K,1,1> &inverse)
633 {
634 return invertMatrix(matrix,inverse);
635 }
636
637
639 template <typename K>
640 static constexpr K invertMatrix (const FieldMatrix<K,2,2> &matrix, FieldMatrix<K,2,2> &inverse)
641 {
642 using real_type = typename FieldTraits<K>::real_type;
643 // code generated by maple
644 K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]);
645 K det_1 = real_type(1.0)/det;
646 inverse[0][0] = matrix[1][1] * det_1;
647 inverse[0][1] = - matrix[0][1] * det_1;
648 inverse[1][0] = - matrix[1][0] * det_1;
649 inverse[1][1] = matrix[0][0] * det_1;
650 return det;
651 }
652
655 template <typename K>
656 static constexpr K invertMatrix_retTransposed (const FieldMatrix<K,2,2> &matrix, FieldMatrix<K,2,2> &inverse)
657 {
658 using real_type = typename FieldTraits<K>::real_type;
659 // code generated by maple
660 K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]);
661 K det_1 = real_type(1.0)/det;
662 inverse[0][0] = matrix[1][1] * det_1;
663 inverse[1][0] = - matrix[0][1] * det_1;
664 inverse[0][1] = - matrix[1][0] * det_1;
665 inverse[1][1] = matrix[0][0] * det_1;
666 return det;
667 }
668
670 template <typename K>
671 static constexpr K invertMatrix (const FieldMatrix<K,3,3> &matrix, FieldMatrix<K,3,3> &inverse)
672 {
673 using real_type = typename FieldTraits<K>::real_type;
674 // code generated by maple
675 K t4 = matrix[0][0] * matrix[1][1];
676 K t6 = matrix[0][0] * matrix[1][2];
677 K t8 = matrix[0][1] * matrix[1][0];
678 K t10 = matrix[0][2] * matrix[1][0];
679 K t12 = matrix[0][1] * matrix[2][0];
680 K t14 = matrix[0][2] * matrix[2][0];
681
682 K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+
683 t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]);
684 K t17 = real_type(1.0)/det;
685
686 inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17;
687 inverse[0][1] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17;
688 inverse[0][2] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17;
689 inverse[1][0] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17;
690 inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17;
691 inverse[1][2] = -(t6-t10) * t17;
692 inverse[2][0] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17;
693 inverse[2][1] = -(matrix[0][0] * matrix[2][1] - t12) * t17;
694 inverse[2][2] = (t4-t8) * t17;
695
696 return det;
697 }
698
700 template <typename K>
701 static constexpr K invertMatrix_retTransposed (const FieldMatrix<K,3,3> &matrix, FieldMatrix<K,3,3> &inverse)
702 {
703 using real_type = typename FieldTraits<K>::real_type;
704 // code generated by maple
705 K t4 = matrix[0][0] * matrix[1][1];
706 K t6 = matrix[0][0] * matrix[1][2];
707 K t8 = matrix[0][1] * matrix[1][0];
708 K t10 = matrix[0][2] * matrix[1][0];
709 K t12 = matrix[0][1] * matrix[2][0];
710 K t14 = matrix[0][2] * matrix[2][0];
711
712 K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+
713 t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]);
714 K t17 = real_type(1.0)/det;
715
716 inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17;
717 inverse[1][0] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17;
718 inverse[2][0] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17;
719 inverse[0][1] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17;
720 inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17;
721 inverse[2][1] = -(t6-t10) * t17;
722 inverse[0][2] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17;
723 inverse[1][2] = -(matrix[0][0] * matrix[2][1] - t12) * t17;
724 inverse[2][2] = (t4-t8) * t17;
725
726 return det;
727 }
728
730 template< class K, int m, int n, int p >
731 static constexpr void multMatrix ( const FieldMatrix< K, m, n > &A,
732 const FieldMatrix< K, n, p > &B,
734 {
735 typedef typename FieldMatrix< K, m, p > :: size_type size_type;
736
737 for( size_type i = 0; i < m; ++i )
738 {
739 for( size_type j = 0; j < p; ++j )
740 {
741 ret[ i ][ j ] = K( 0 );
742 for( size_type k = 0; k < n; ++k )
743 ret[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ];
744 }
745 }
746 }
747
749 template <typename K, int rows, int cols>
751 {
752 typedef typename FieldMatrix<K,rows,cols>::size_type size_type;
753
754 for(size_type i=0; i<cols; i++)
755 for(size_type j=0; j<cols; j++)
756 {
757 ret[i][j]=0.0;
758 for(size_type k=0; k<rows; k++)
759 ret[i][j]+=matrix[k][i]*matrix[k][j];
760 }
761 }
762
764
766 template <typename K, int rows, int cols>
767 static constexpr void multAssignTransposed( const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,rows> & x, FieldVector<K,cols> & ret)
768 {
769 typedef typename FieldMatrix<K,rows,cols>::size_type size_type;
770
771 for(size_type i=0; i<cols; ++i)
772 {
773 ret[i] = 0.0;
774 for(size_type j=0; j<rows; ++j)
775 ret[i] += matrix[j][i]*x[j];
776 }
777 }
778
780 template <typename K, int rows, int cols>
781 static constexpr FieldVector<K,rows> mult(const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,cols> & x)
782 {
784 multAssign(matrix,x,ret);
785 return ret;
786 }
787
789 template <typename K, int rows, int cols>
791 {
793 multAssignTransposed( matrix, x, ret );
794 return ret;
795 }
796
797 } // end namespace FMatrixHelp
798
801} // end namespace
802
803#include "fmatrixev.hh"
804#endif
Various precision settings for calculations with FieldMatrix and FieldVector.
Macro for wrapping boundary checks.
A few common exception classes.
Compute type of the result of an arithmetic operation involving two different number types.
Eigenvalue computations for the FieldMatrix class.
Traits for type conversions and type information.
Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
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 bigunsignedint< k > &x)
Definition bigunsignedint.hh:301
STL namespace.
Dune namespace
Definition alignedallocator.hh:13
static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret)
calculates ret = matrix * x
Definition densematrix.hh:1174
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:767
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:790
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:632
static constexpr void multTransposedMatrix(const FieldMatrix< K, rows, cols > &matrix, FieldMatrix< K, cols, cols > &ret)
calculates ret= A_t*A
Definition fmatrix.hh:750
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:731
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:623
static constexpr FieldVector< K, rows > mult(const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, cols > &x)
calculates ret = matrix * x
Definition fmatrix.hh:781
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
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 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
static constexpr size_type mat_cols()
Definition fmatrix.hh:510
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:394
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:495
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:478
constexpr FieldMatrix & operator+=(const S &scalar)
add scalar
Definition fmatrix.hh:271
constexpr const_row_reference mat_access(size_type i) const
Definition fmatrix.hh:526
constexpr FieldMatrix & operator-=(const S &scalar)
subtract scalar
Definition fmatrix.hh:315
friend constexpr auto operator*(const FieldMatrix &matrix, const S &scalar)
vector space multiplication with scalar
Definition fmatrix.hh:326
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:575
friend constexpr auto operator-(const FieldMatrix &matrixA, const FieldMatrix< OtherK, ROWS, COLS > &matrixB)
vector space subtraction
Definition fmatrix.hh:282
typename Base::row_type row_type
The type the rows of the matrix are represented by.
Definition fmatrix.hh:170
static constexpr size_type mat_rows()
Definition fmatrix.hh:507
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:355
friend constexpr bool operator==(const FieldMatrix &a, const S &b) noexcept
comparing FieldMatrix<1,1> with scalar for equality
Definition fmatrix.hh:557
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:366
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:469
constexpr row_reference mat_access(size_type i)
Definition fmatrix.hh:519
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
you have to specialize this structure for any type that should be assignable to a DenseMatrix
Definition densematrix.hh:61
std::array< row_type, ROWS > container_type
Definition fmatrix.hh:96
FieldMatrix< K, ROWS, COLS > derived_type
Definition fmatrix.hh:88
const row_type & const_row_reference
Definition fmatrix.hh:94
FieldVector< K, COLS > row_type
Definition fmatrix.hh:91
container_type::size_type size_type
Definition fmatrix.hh:98
row_type & row_reference
Definition fmatrix.hh:93
FieldTraits< K >::field_type field_type
Definition fmatrix.hh:104
FieldTraits< K >::real_type real_type
Definition fmatrix.hh:105
TMP to check the shape of a DenseMatrix statically, if possible.
Definition fmatrix.hh:121
Definition ftraits.hh:26
T field_type
export the type representing the field
Definition ftraits.hh:28
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
Definition matvectraits.hh:31
decltype(std::declval< T1 >()+std::declval< T2 >()) PromotedType
Definition promotiontraits.hh:28
The concept std::three_way_comparable_with specifies that the three way comparison operator <=> on (p...
Definition compare.hh:100
T data(T... args)