5 #ifndef DUNE_DENSEMATRIX_HH 6 #define DUNE_DENSEMATRIX_HH 12 #include <type_traits> 60 template<
class DenseMatrix,
class RHS >
67 template<
class DenseMatrix,
class RHS >
71 template<
class DenseMatrix,
class RHS >
76 constexpr
static void apply (
DenseMatrix &denseMatrix,
const RHS &rhs )
79 std::fill( denseMatrix.
begin(), denseMatrix.
end(),
static_cast< field_type
>( rhs ) );
83 template<
class DenseMatrix,
class RHS >
85 decltype(std::begin(*std::declval<typename RHS::const_iterator>())),
86 decltype(std::begin(*std::declval<typename DenseMatrix::iterator>()))>
87 class DenseMatrixAssigner<DenseMatrix, RHS>
90 constexpr
static void apply ( DenseMatrix &denseMatrix,
const RHS &rhs )
95 typename RHS::const_iterator sIt = std::begin(rhs);
96 for(; sIt != std::end(rhs); ++tIt, ++sIt)
97 std::copy(std::begin(*sIt), std::end(*sIt), std::begin(*tIt));
105 template<
class DenseMatrix,
class RHS >
106 struct DenseMatrixAssigner
107 :
public Impl::DenseMatrixAssigner< DenseMatrix, RHS >
114 template<
class DenseMatrix,
class RHS >
117 std::false_type hasDenseMatrixAssigner ( ... );
121 template<
class DenseMatrix,
class RHS >
122 struct HasDenseMatrixAssigner
123 :
public decltype( Impl::hasDenseMatrixAssigner( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) )
126 #endif // #ifndef DOXYGEN 143 template<
typename MAT>
149 constexpr MAT & asImp() {
return static_cast<MAT&
>(*this); }
150 constexpr
const MAT & asImp()
const {
return static_cast<const MAT&
>(*this); }
196 return asImp().mat_access(
i);
201 return asImp().mat_access(
i);
218 typedef typename std::remove_reference<row_reference>::type::Iterator
ColIterator;
253 typedef typename std::remove_reference<const_row_reference>::type::ConstIterator
ConstColIterator;
283 template< class RHS, class = std::enable_if_t< HasDenseMatrixAssigner< MAT, RHS >::value > >
293 template <
class Other>
306 using idx_type =
typename decltype(result)::
size_type;
308 for (idx_type
i = 0;
i <
rows(); ++
i)
309 for (idx_type j = 0; j <
cols(); ++j)
310 result[
i][j] = - asImp()[
i][j];
316 template <
class Other>
342 template <
class Other>
347 (*
this)[
i ].axpy( a, x[
i ] );
352 template <
class Other>
357 if ((*
this)[
i]!=x[
i])
362 template <
class Other>
372 template<
class X,
class Y>
373 constexpr
void mv (
const X& x, Y& y)
const 375 auto&& xx = Impl::asVector(x);
376 auto&& yy = Impl::asVector(y);
384 yy[
i] = y_field_type(0);
386 yy[
i] += (*
this)[
i][j] * xx[j];
391 template<
class X,
class Y >
392 constexpr
void mtv (
const X &x, Y &y )
const 394 auto&& xx = Impl::asVector(x);
395 auto&& yy = Impl::asVector(y);
403 yy[
i] = y_field_type(0);
405 yy[
i] += (*
this)[j][
i] * xx[j];
410 template<
class X,
class Y>
411 constexpr
void umv (
const X& x, Y& y)
const 413 auto&& xx = Impl::asVector(x);
414 auto&& yy = Impl::asVector(y);
419 yy[
i] += (*
this)[
i][j] * xx[j];
423 template<
class X,
class Y>
424 constexpr
void umtv (
const X& x, Y& y)
const 426 auto&& xx = Impl::asVector(x);
427 auto&& yy = Impl::asVector(y);
432 yy[j] += (*
this)[
i][j]*xx[
i];
436 template<
class X,
class Y>
437 constexpr
void umhv (
const X& x, Y& y)
const 439 auto&& xx = Impl::asVector(x);
440 auto&& yy = Impl::asVector(y);
449 template<
class X,
class Y>
450 constexpr
void mmv (
const X& x, Y& y)
const 452 auto&& xx = Impl::asVector(x);
453 auto&& yy = Impl::asVector(y);
458 yy[
i] -= (*
this)[
i][j] * xx[j];
462 template<
class X,
class Y>
463 constexpr
void mmtv (
const X& x, Y& y)
const 465 auto&& xx = Impl::asVector(x);
466 auto&& yy = Impl::asVector(y);
471 yy[j] -= (*
this)[
i][j]*xx[
i];
475 template<
class X,
class Y>
476 constexpr
void mmhv (
const X& x, Y& y)
const 478 auto&& xx = Impl::asVector(x);
479 auto&& yy = Impl::asVector(y);
488 template<
class X,
class Y>
490 const X& x, Y& y)
const 492 auto&& xx = Impl::asVector(x);
493 auto&& yy = Impl::asVector(y);
498 yy[
i] += alpha * (*
this)[
i][j] * xx[j];
502 template<
class X,
class Y>
504 const X& x, Y& y)
const 506 auto&& xx = Impl::asVector(x);
507 auto&& yy = Impl::asVector(y);
512 yy[j] += alpha*(*
this)[
i][j]*xx[
i];
516 template<
class X,
class Y>
518 const X& x, Y& y)
const 520 auto&& xx = Impl::asVector(x);
521 auto&& yy = Impl::asVector(y);
550 typename std::enable_if<!HasNaN<vt>::value,
int>::type = 0>
556 for (
auto const &x : *
this) {
557 real_type
const a = x.one_norm();
565 typename std::enable_if<!HasNaN<vt>::value,
int>::type = 0>
571 for (
auto const &x : *
this) {
572 real_type
const a = x.one_norm_real();
580 typename std::enable_if<HasNaN<vt>::value,
int>::type = 0>
586 real_type is_nan = 1;
587 for (
auto const &x : *
this) {
588 real_type
const a = x.one_norm();
592 return norm * (is_nan / is_nan);
597 typename std::enable_if<HasNaN<vt>::value,
int>::type = 0>
603 real_type is_nan = 1;
604 for (
auto const &x : *
this) {
605 real_type
const a = x.one_norm_real();
609 return norm * (is_nan / is_nan);
618 template <
class V1,
class V2>
619 void solve (V1& x,
const V2& b,
bool doPivoting =
true)
const;
625 void invert(
bool doPivoting =
true);
631 template<
typename M2>
642 (*
this)[
i][j] +=
M[
i][k]*C[k][j];
649 template<
typename M2>
660 (*
this)[
i][j] += C[
i][k]*
M[k][j];
676 C[
i][j] +=
M[
i][k]*(*
this)[k][j];
684 FieldMatrix<K,rows,l> rightmultiplyany (
const FieldMatrix<K,cols,l>&
M)
const 686 FieldMatrix<K,rows,l> C;
692 C[
i][j] += (*
this)[
i][k]*
M[k][j];
716 return asImp().mat_rows();
722 return asImp().mat_cols();
740 ElimPivot(std::vector<simd_index_type> & pivot);
742 void swap(std::size_t
i, simd_index_type j);
745 void operator()(
const T&,
int,
int)
748 std::vector<simd_index_type> & pivot_;
756 void swap(std::size_t
i, simd_index_type j);
758 void operator()(
const typename V::field_type& factor,
int k,
int i);
768 void swap(std::size_t
i, simd_index_type j)
820 template<
class Func,
class Mask>
822 Mask &nonsingularLanes,
bool throwEarly,
bool doPivoting);
826 template<
typename MAT>
827 DenseMatrix<MAT>::ElimPivot::ElimPivot(std::vector<simd_index_type> & pivot)
830 for(
typename std::vector<size_type>::size_type
i=0;
i < pivot_.size(); ++
i)
834 template<
typename MAT>
838 Simd::cond(Simd::Scalar<simd_index_type>(
i) == j, pivot_[
i], j);
841 template<
typename MAT>
843 DenseMatrix<MAT>::Elim<V>::Elim(V& rhs)
847 template<
typename MAT>
859 template<
typename MAT>
861 void DenseMatrix<MAT>::
862 Elim<V>::operator()(
const typename V::field_type& factor,
int k,
int i)
864 (*rhs_)[k] -= factor*(*rhs_)[
i];
867 template<
typename MAT>
868 template<
typename Func,
class Mask>
869 inline void DenseMatrix<MAT>::
870 luDecomposition(DenseMatrix<MAT>& A, Func func,
Mask &nonsingularLanes,
871 bool throwEarly,
bool doPivoting)
876 typedef typename FieldTraits<value_type>::real_type real_type;
879 for (size_type
i=0;
i<A.rows();
i++)
881 real_type pivmax = fvmeta::absreal(A[
i][
i]);
886 simd_index_type imax=
i;
887 for (size_type k=
i+1; k<A.rows(); k++)
889 auto abs = fvmeta::absreal(A[k][
i]);
895 for (size_type j=0; j<A.rows(); j++)
913 nonsingularLanes = nonsingularLanes && (pivmax != real_type(0));
916 DUNE_THROW(FMatrixError,
"matrix is singular");
924 for (size_type k=
i+1; k<A.rows(); k++)
928 field_type factor = A[k][
i]/A[
i][
i];
930 for (size_type j=
i+1; j<A.rows(); j++)
931 A[k][j] -= factor*A[
i][j];
937 template<
typename MAT>
938 template <
class V1,
class V2>
939 inline void DenseMatrix<MAT>::solve(V1& x,
const V2& b,
bool doPivoting)
const 941 using real_type =
typename FieldTraits<value_type>::real_type;
944 DUNE_THROW(FMatrixError,
"Can't solve for a " << rows() <<
"x" << cols() <<
" matrix!");
948 #ifdef DUNE_FMatrix_WITH_CHECKING 950 < FMatrixPrecision<>::absolute_limit()))
951 DUNE_THROW(FMatrixError,
"matrix is singular");
953 x[0] = b[0]/(*this)[0][0];
956 else if (rows()==2) {
958 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
959 #ifdef DUNE_FMatrix_WITH_CHECKING 961 < FMatrixPrecision<>::absolute_limit()))
962 DUNE_THROW(FMatrixError,
"matrix is singular");
964 detinv = real_type(1.0)/detinv;
966 x[0] = detinv*((*this)[1][1]*b[0]-(*this)[0][1]*b[1]);
967 x[1] = detinv*((*this)[0][0]*b[1]-(*this)[1][0]*b[0]);
970 else if (rows()==3) {
972 field_type d = determinant(doPivoting);
973 #ifdef DUNE_FMatrix_WITH_CHECKING 975 < FMatrixPrecision<>::absolute_limit()))
976 DUNE_THROW(FMatrixError,
"matrix is singular");
979 x[0] = (b[0]*(*this)[1][1]*(*this)[2][2] - b[0]*(*this)[2][1]*(*this)[1][2]
980 - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2]
981 + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / d;
983 x[1] = ((*this)[0][0]*b[1]*(*this)[2][2] - (*this)[0][0]*b[2]*(*this)[1][2]
984 - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2]
985 + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / d;
987 x[2] = ((*this)[0][0]*(*this)[1][1]*b[2] - (*this)[0][0]*(*this)[2][1]*b[1]
988 - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0]
989 + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / d;
997 AutonomousValue<MAT> A(asImp());
998 Simd::Mask<typename FieldTraits<value_type>::real_type>
999 nonsingularLanes(
true);
1001 AutonomousValue<MAT>::luDecomposition(A, elim, nonsingularLanes,
true, doPivoting);
1004 for(
int i=rows()-1;
i>=0;
i--) {
1005 for (size_type j=
i+1; j<rows(); j++)
1006 rhs[
i] -= A[
i][j]*x[j];
1007 x[
i] = rhs[
i]/A[
i][
i];
1012 template<
typename MAT>
1013 inline void DenseMatrix<MAT>::invert(
bool doPivoting)
1015 using real_type =
typename FieldTraits<MAT>::real_type;
1020 DUNE_THROW(FMatrixError,
"Can't invert a " << rows() <<
"x" << cols() <<
" matrix!");
1024 #ifdef DUNE_FMatrix_WITH_CHECKING 1026 < FMatrixPrecision<>::absolute_limit()))
1027 DUNE_THROW(FMatrixError,
"matrix is singular");
1029 (*this)[0][0] = real_type( 1 ) / (*this)[0][0];
1032 else if (rows()==2) {
1034 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
1035 #ifdef DUNE_FMatrix_WITH_CHECKING 1037 < FMatrixPrecision<>::absolute_limit()))
1038 DUNE_THROW(FMatrixError,
"matrix is singular");
1040 detinv = real_type( 1 ) / detinv;
1042 field_type temp=(*this)[0][0];
1043 (*this)[0][0] = (*this)[1][1]*detinv;
1044 (*this)[0][1] = -(*this)[0][1]*detinv;
1045 (*this)[1][0] = -(*this)[1][0]*detinv;
1046 (*this)[1][1] = temp*detinv;
1051 using K = field_type;
1053 K t4 = (*this)[0][0] * (*this)[1][1];
1054 K t6 = (*this)[0][0] * (*this)[1][2];
1055 K t8 = (*this)[0][1] * (*this)[1][0];
1056 K t10 = (*this)[0][2] * (*this)[1][0];
1057 K t12 = (*this)[0][1] * (*this)[2][0];
1058 K t14 = (*this)[0][2] * (*this)[2][0];
1060 K det = (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+
1061 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]);
1064 K matrix01 = (*this)[0][1];
1065 K matrix00 = (*this)[0][0];
1066 K matrix10 = (*this)[1][0];
1067 K matrix11 = (*this)[1][1];
1069 (*this)[0][0] = ((*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this)[2][1])*t17;
1070 (*this)[0][1] = -((*this)[0][1] * (*this)[2][2] - (*this)[0][2] * (*this)[2][1])*t17;
1071 (*this)[0][2] = (matrix01 * (*this)[1][2] - (*this)[0][2] * (*this)[1][1])*t17;
1072 (*this)[1][0] = -((*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this)[2][0])*t17;
1073 (*this)[1][1] = (matrix00 * (*this)[2][2] - t14) * t17;
1074 (*this)[1][2] = -(t6-t10) * t17;
1075 (*this)[2][0] = (matrix10 * (*this)[2][1] - matrix11 * (*this)[2][0]) * t17;
1076 (*this)[2][1] = -(matrix00 * (*this)[2][1] - t12) * t17;
1077 (*this)[2][2] = (t4-t8) * t17;
1082 AutonomousValue<MAT> A(asImp());
1083 std::vector<simd_index_type> pivot(rows());
1084 Simd::Mask<typename FieldTraits<value_type>::real_type>
1085 nonsingularLanes(
true);
1086 AutonomousValue<MAT>::luDecomposition(A, ElimPivot(pivot), nonsingularLanes,
true, doPivoting);
1093 for(size_type
i=0;
i<rows(); ++
i)
1097 for (size_type
i=0;
i<rows();
i++)
1098 for (size_type j=0; j<
i; j++)
1099 for (size_type k=0; k<rows(); k++)
1100 (*
this)[
i][k] -= L[
i][j]*(*this)[j][k];
1103 for (size_type
i=rows();
i>0;) {
1105 for (size_type k=0; k<rows(); k++) {
1106 for (size_type j=
i+1; j<rows(); j++)
1107 (*
this)[
i][k] -= U[
i][j]*(*this)[j][k];
1108 (*this)[
i][k] /= U[
i][
i];
1112 for(size_type
i=rows();
i>0; ) {
1114 for(std::size_t l = 0; l <
Simd::lanes((*
this)[0][0]); ++l)
1118 for(size_type j=0; j<rows(); ++j)
1127 template<
typename MAT>
1128 inline typename DenseMatrix<MAT>::field_type
1129 DenseMatrix<MAT>::determinant(
bool doPivoting)
const 1133 DUNE_THROW(FMatrixError,
"There is no determinant for a " << rows() <<
"x" << cols() <<
" matrix!");
1136 return (*
this)[0][0];
1139 return (*
this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0];
1143 field_type t4 = (*this)[0][0] * (*this)[1][1];
1144 field_type t6 = (*this)[0][0] * (*this)[1][2];
1145 field_type t8 = (*this)[0][1] * (*this)[1][0];
1146 field_type t10 = (*this)[0][2] * (*this)[1][0];
1147 field_type t12 = (*this)[0][1] * (*this)[2][0];
1148 field_type t14 = (*this)[0][2] * (*this)[2][0];
1150 return (t4*(*
this)[2][2]-t6*(*
this)[2][1]-t8*(*
this)[2][2]+
1151 t10*(*
this)[2][1]+t12*(*
this)[1][2]-t14*(*
this)[1][1]);
1155 AutonomousValue<MAT> A(asImp());
1157 Simd::Mask<typename FieldTraits<value_type>::real_type>
1158 nonsingularLanes(
true);
1160 AutonomousValue<MAT>::luDecomposition(A, ElimDet(det), nonsingularLanes,
false, doPivoting);
1161 det =
Simd::cond(nonsingularLanes, det, field_type(0));
1163 for (size_type
i = 0;
i < rows(); ++
i)
1170 namespace DenseMatrixHelp {
1173 template <
typename MAT,
typename V1,
typename V2>
1180 for(size_type
i=0;
i<matrix.
rows(); ++
i)
1183 for(size_type j=0; j<matrix.
cols(); ++j)
1185 ret[
i] += matrix[
i][j]*x[j];
1191 template <
typename K,
int rows,
int cols>
1197 for(size_type
i=0;
i<cols(); ++
i)
1200 for(size_type j=0; j<rows(); ++j)
1201 ret[
i] += matrix[j][
i]*x[j];
1206 template <
typename K,
int rows,
int cols>
1207 static inline FieldVector<K,rows>
mult(
const FieldMatrix<K,rows,cols> &matrix,
const FieldVector<K,cols> & x)
1209 FieldVector<K,rows> ret;
1215 template <
typename K,
int rows,
int cols>
1216 static inline FieldVector<K,cols>
multTransposed(
const FieldMatrix<K,rows,cols> &matrix,
const FieldVector<K,rows> & x)
1218 FieldVector<K,cols> ret;
1227 template<
typename MAT>
1228 std::ostream& operator<< (std::ostream& s, const DenseMatrix<MAT>& a)
1231 s << a[
i] << std::endl;
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition: simd/interface.hh:305
constexpr Iterator begin()
begin iterator
Definition: densematrix.hh:221
constexpr FieldTraits< vt >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: densematrix.hh:566
Traits::derived_type derived_type
type of derived matrix class
Definition: densematrix.hh:159
constexpr void umtv(const X &x, Y &y) const
y += A^T x
Definition: densematrix.hh:424
constexpr derived_type & operator/=(const field_type &k)
vector space division by scalar
Definition: densematrix.hh:334
constexpr derived_type & operator+=(const DenseMatrix< Other > &x)
vector space addition
Definition: densematrix.hh:294
K value_type
Definition: dynmatrix.hh:44
requires(((std::is_integral_v< I > or Dune::IsIntegralConstant< I >::value) &&...)) HybridMultiIndex(I... i) -> HybridMultiIndex< decltype(Impl::castToHybridSizeT(i))... >
constexpr size_type N() const
number of rows
Definition: densematrix.hh:702
A dense n x m matrix.
Definition: densematrix.hh:39
const T1 cond(bool b, const T1 &v1, const T2 &v2)
conditional evaluate
Definition: conditional.hh:28
constexpr bool operator!=(const DenseMatrix< Other > &x) const
Binary matrix incomparison.
Definition: densematrix.hh:363
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: bigunsignedint.hh:628
Some useful basic math stuff.
constexpr K conjugateComplex(const K &x)
compute conjugate complex of x
Definition: math.hh:146
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:489
constexpr ConstIterator end() const
end iterator
Definition: densematrix.hh:262
constexpr void umv(const X &x, Y &y) const
y += A x
Definition: densematrix.hh:411
constexpr void mmtv(const X &x, Y &y) const
y -= A^T x
Definition: densematrix.hh:463
container_type::size_type size_type
Definition: dynmatrix.hh:45
constexpr size_type size() const
size method
Definition: densevector.hh:351
you have to specialize this structure for any type that should be assignable to a DenseMatrix ...
Definition: densematrix.hh:61
MAT & rightmultiply(const DenseMatrix< M2 > &M)
Multiplies M from the right to this matrix.
Definition: densematrix.hh:650
constexpr Iterator end()
end iterator
Definition: densematrix.hh:227
constexpr derived_type & operator=(const RHS &rhs)
Definition: densematrix.hh:284
constexpr void mmv(const X &x, Y &y) const
y -= A x
Definition: densematrix.hh:450
constexpr void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A x
Definition: densematrix.hh:489
constexpr ConstIterator beforeEnd() const
Definition: densematrix.hh:269
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition: debugalign.hh:533
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition: boundschecking.hh:30
constexpr ConstIterator begin() const
begin iterator
Definition: densematrix.hh:256
Definition: matvectraits.hh:31
constexpr void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition: densematrix.hh:503
Various precision settings for calculations with FieldMatrix and FieldVector.
DenseIterator< const DenseMatrix, const row_type, const_row_reference > ConstIterator
Iterator class for sequential access.
Definition: densematrix.hh:247
I i
Definition: hybridmultiindex.hh:328
T real_type
export the type representing the real type of the field
Definition: ftraits.hh:30
constexpr void mtv(const X &x, Y &y) const
y = A^T x
Definition: densematrix.hh:392
Macro for wrapping boundary checks.
static constexpr FieldVector< K, rows > mult(const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, cols > &x)
calculates ret = matrix * x
Definition: fmatrix.hh:837
static constexpr int blocklevel
The number of block levels we contain. This is the leaf, that is, 1.
Definition: densematrix.hh:183
constexpr int sign(const T &val)
Return the sign of the value.
Definition: math.hh:162
constexpr derived_type & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: densematrix.hh:326
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
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:846
Base::size_type size_type
Definition: fmatrix.hh:128
constexpr ConstIterator beforeBegin() const
Definition: densematrix.hh:276
constexpr derived_type & operator-=(const DenseMatrix< Other > &x)
vector space subtraction
Definition: densematrix.hh:317
Traits::size_type size_type
The type used for the index access and size operation.
Definition: densematrix.hh:171
constexpr size_type cols() const
number of columns
Definition: densematrix.hh:720
Dune namespace
Definition: alignedallocator.hh:12
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:823
A free function to provide the demangled class name of a given object or type as a string...
constexpr Iterator beforeBegin()
Definition: densematrix.hh:241
static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret)
calculates ret = matrix * x
Definition: densematrix.hh:1174
Traits::row_type row_type
The type used to represent a row (must fulfill the Dune::DenseVector interface)
Definition: densematrix.hh:174
const FieldTraits< typename DenseMatVecTraits< M >::value_type >::real_type real_type
Definition: densematrix.hh:36
Interface for a class of dense vectors over a given field.
Definition: densevector.hh:23
std::remove_reference< row_reference >::type::Iterator ColIterator
rename the iterators for easier access
Definition: densematrix.hh:218
bool allTrue(ADLTag< 0 >, const Mask &mask)
implements Simd::allTrue()
Definition: defaults.hh:104
vector space out of a tensor product of fields.
Definition: densematrix.hh:40
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
Traits::value_type field_type
export the type representing the field
Definition: densematrix.hh:165
Construct a matrix with a dynamic size.
Definition: dynmatrix.hh:31
A dense n x m matrix.
Definition: densematrix.hh:30
Traits::value_type block_type
export the type representing the components
Definition: densematrix.hh:168
typename Overloads::RebindType< std::decay_t< S >, std::decay_t< V > >::type Rebind
Construct SIMD type with different scalar type.
Definition: simd/interface.hh:253
Iterator iterator
typedef for stl compliant access
Definition: densematrix.hh:214
constexpr FieldTraits< vt >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition: densematrix.hh:551
std::remove_reference< const_row_reference >::type::ConstIterator ConstColIterator
rename the iterators for easier access
Definition: densematrix.hh:253
Iterator RowIterator
rename the iterators for easier access
Definition: densematrix.hh:216
const FieldTraits< typename DenseMatVecTraits< M >::value_type >::field_type field_type
Definition: densematrix.hh:35
MAT & leftmultiply(const DenseMatrix< M2 > &M)
Multiplies M from the left to this matrix.
Definition: densematrix.hh:632
constexpr FieldTraits< value_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition: densematrix.hh:533
Definition: ftraits.hh:25
Implements a vector constructed from a given type representing a field and a compile-time given size...
constexpr size_type M() const
number of columns
Definition: densematrix.hh:708
Error thrown if operations of a FieldMatrix fail.
Definition: densematrix.hh:131
A few common exception classes.
DenseIterator< DenseMatrix, row_type, row_reference > Iterator
Iterator class for sequential access.
Definition: densematrix.hh:212
constexpr derived_type & axpy(const field_type &a, const DenseMatrix< Other > &x)
vector space axpy operation (*this += a x)
Definition: densematrix.hh:343
constexpr auto sqrt(T t) requires(std
Definition: cmath.hh:39
Default exception class for mathematical errors.
Definition: exceptions.hh:335
void solve(V1 &x, const V2 &b, bool doPivoting=true) const
Solve system A x = b.
static void luDecomposition(DenseMatrix< MAT > &A, Func func, Mask &nonsingularLanes, bool throwEarly, bool doPivoting)
do an LU-Decomposition on matrix A
constexpr size_type rows() const
number of rows
Definition: densematrix.hh:714
T field_type
export the type representing the field
Definition: ftraits.hh:28
constexpr row_reference operator[](size_type i)
random access
Definition: densematrix.hh:194
constexpr void mmhv(const X &x, Y &y) const
y -= A^H x
Definition: densematrix.hh:476
Traits::value_type value_type
export the type representing the field
Definition: densematrix.hh:162
constexpr void umhv(const X &x, Y &y) const
y += A^H x
Definition: densematrix.hh:437
Traits::row_reference row_reference
The type used to represent a reference to a row (usually row_type &)
Definition: densematrix.hh:177
ConstIterator ConstRowIterator
rename the iterators for easier access
Definition: densematrix.hh:251
Rebind< bool, V > Mask
Mask type type of some SIMD type.
Definition: simd/interface.hh:289
Generic iterator class for dense vector and matrix implementations.
Definition: densevector.hh:130
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition: debugalign.hh:556
constexpr derived_type operator-() const
Matrix negation.
Definition: densematrix.hh:303
void swap(T &v1, T &v2, bool mask)
Definition: simd.hh:472
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition: defaults.hh:153
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition: typetraits.hh:566
constexpr bool exists([[maybe_unused]] size_type i, [[maybe_unused]] size_type j) const
return true when (i,j) is in pattern
Definition: densematrix.hh:728
constexpr void mv(const X &x, Y &y) const
y = A x
Definition: densematrix.hh:373
constexpr Iterator beforeEnd()
Definition: densematrix.hh:234
Traits for type conversions and type information.
constexpr size_type size() const
size method (number of rows)
Definition: densematrix.hh:205
constexpr FieldTraits< value_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition: densematrix.hh:541
constexpr T abs(T t)
Definition: cmath.hh:27
void invert(bool doPivoting=true)
Compute inverse.
field_type determinant(bool doPivoting=true) const
calculates the determinant of this matrix
Include file for users of the SIMD abstraction layer.
Implements a scalar vector view wrapper around an existing scalar.
constexpr bool operator==(const DenseMatrix< Other > &x) const
Binary matrix comparison.
Definition: densematrix.hh:353
ConstIterator const_iterator
typedef for stl compliant access
Definition: densematrix.hh:249
concept indirectly_copyable
The std::indirectly_copyable concept specifies the relationship between an indirectly_readable type a...
Definition: iterator.hh:22
constexpr void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition: densematrix.hh:517
V cond(M &&mask, const V &ifTrue, const V &ifFalse)
Like the ?: operator.
Definition: simd/interface.hh:386