3#ifndef DUNE_DENSEMATRIX_HH
4#define DUNE_DENSEMATRIX_HH
19#include <dune/common/simd.hh>
26 template<
typename M>
class DenseMatrix;
29 struct FieldTraits< DenseMatrix<M> >
31 typedef const typename FieldTraits< typename DenseMatVecTraits<M>::value_type >::field_type field_type;
32 typedef const typename FieldTraits< typename DenseMatVecTraits<M>::value_type >::real_type real_type;
39 template<
class K,
int N,
int M>
class FieldMatrix;
40 template<
class K,
int N>
class FieldVector;
45 static typename V::size_type size(
const V & v) {
return v.size(); }
48 template<
class K,
int N>
51 typedef FieldVector<K,N> V;
52 static typename V::size_type size(
const V & v)
78 template<
class DenseMatrix,
class RHS >
85 template<
class DenseMatrix,
class RHS,
class =
void >
89 template<
class DenseMatrix,
class RHS >
96 std::fill( denseMatrix.
begin(), denseMatrix.
end(),
static_cast< field_type
>( rhs ) );
100 template<
class DenseMatrix,
class RHS >
101 class DenseMatrixAssigner< DenseMatrix, RHS,
std::enable_if_t< !std::is_same< typename RHS::const_iterator, void >::value
102 && std::is_convertible< typename RHS::const_iterator::value_type, typename DenseMatrix::iterator::value_type >::value > >
105 static void apply ( DenseMatrix &denseMatrix,
const RHS &rhs )
110 typename RHS::const_iterator sIt = std::begin(rhs);
111 for(; sIt != std::end(rhs); ++tIt, ++sIt)
112 std::copy(std::begin(*sIt), std::end(*sIt), std::begin(*tIt));
120 template<
class DenseMatrix,
class RHS >
121 struct DenseMatrixAssigner
122 :
public Impl::DenseMatrixAssigner< DenseMatrix, RHS >
129 template<
class DenseMatrix,
class RHS >
132 std::false_type hasDenseMatrixAssigner ( ... );
136 template<
class DenseMatrix,
class RHS >
137 struct HasDenseMatrixAssigner
138 :
public decltype( Impl::hasDenseMatrixAssigner( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) )
158 template<
typename MAT>
161 typedef DenseMatVecTraits<MAT> Traits;
164 MAT & asImp() {
return static_cast<MAT&
>(*this); }
165 const MAT & asImp()
const {
return static_cast<const MAT&
>(*this); }
214 return asImp().mat_access(i);
219 return asImp().mat_access(i);
236 typedef typename std::remove_reference<row_reference>::type::Iterator
ColIterator;
271 typedef typename std::remove_reference<const_row_reference>::type::ConstIterator
ConstColIterator;
301 template< class RHS, class = std::enable_if_t< HasDenseMatrixAssigner< MAT, RHS >::value > >
311 template <
class Other>
321 template <
class Other>
347 template <
class Other>
352 (*
this)[ i ].axpy( k, y[ i ] );
357 template <
class Other>
362 if ((*
this)[i]!=y[i])
367 template <
class Other>
377 template<
class X,
class Y>
378 void mv (
const X& x, Y& y)
const
384 using field_type =
typename FieldTraits<Y>::field_type;
389 y[i] += (*
this)[i][j] * x[j];
394 template<
class X,
class Y >
395 void mtv (
const X &x, Y &y )
const
401 using field_type =
typename FieldTraits<Y>::field_type;
406 y[i] += (*
this)[j][i] * x[j];
411 template<
class X,
class Y>
412 void umv (
const X& x, Y& y)
const
418 y[i] += (*
this)[i][j] * x[j];
422 template<
class X,
class Y>
423 void umtv (
const X& x, Y& y)
const
429 y[j] += (*
this)[i][j]*x[i];
433 template<
class X,
class Y>
434 void umhv (
const X& x, Y& y)
const
444 template<
class X,
class Y>
445 void mmv (
const X& x, Y& y)
const
451 y[i] -= (*
this)[i][j] * x[j];
455 template<
class X,
class Y>
456 void mmtv (
const X& x, Y& y)
const
462 y[j] -= (*
this)[i][j]*x[i];
466 template<
class X,
class Y>
467 void mmhv (
const X& x, Y& y)
const
477 template<
class X,
class Y>
478 void usmv (
const typename FieldTraits<Y>::field_type & alpha,
479 const X& x, Y& y)
const
485 y[i] += alpha * (*
this)[i][j] * x[j];
489 template<
class X,
class Y>
490 void usmtv (
const typename FieldTraits<Y>::field_type & alpha,
491 const X& x, Y& y)
const
497 y[j] += alpha*(*
this)[i][j]*x[i];
501 template<
class X,
class Y>
502 void usmhv (
const typename FieldTraits<Y>::field_type & alpha,
503 const X& x, Y& y)
const
517 typename FieldTraits<value_type>::real_type sum=(0.0);
518 for (
size_type i=0; i<
rows(); ++i) sum += (*
this)[i].two_norm2();
519 return fvmeta::sqrt(sum);
525 typename FieldTraits<value_type>::real_type sum=(0.0);
526 for (
size_type i=0; i<
rows(); ++i) sum += (*
this)[i].two_norm2();
532 typename std::enable_if<!has_nan<vt>::value,
int>::type = 0>
534 using real_type =
typename FieldTraits<vt>::real_type;
538 for (
auto const &x : *
this) {
539 real_type
const a = x.one_norm();
547 typename std::enable_if<!has_nan<vt>::value,
int>::type = 0>
549 using real_type =
typename FieldTraits<vt>::real_type;
553 for (
auto const &x : *
this) {
554 real_type
const a = x.one_norm_real();
562 typename std::enable_if<has_nan<vt>::value,
int>::type = 0>
564 using real_type =
typename FieldTraits<vt>::real_type;
569 for (
auto const &x : *
this) {
570 real_type
const a = x.one_norm();
580 typename std::enable_if<has_nan<vt>::value,
int>::type = 0>
582 using real_type =
typename FieldTraits<vt>::real_type;
587 for (
auto const &x : *
this) {
588 real_type
const a = x.one_norm_real();
603 void solve (V& x,
const V& b)
const;
615 template<
typename M2>
626 (*
this)[i][j] +=
M[i][k]*C[k][j];
633 template<
typename M2>
644 (*
this)[i][j] += C[i][k]*
M[k][j];
660 C[i][j] +=
M[i][k]*(*
this)[k][j];
668 FieldMatrix<K,rows,l> rightmultiplyany (
const FieldMatrix<K,cols,l>&
M)
const
670 FieldMatrix<K,rows,l> C;
676 C[i][j] += (*
this)[i][k]*
M[k][j];
700 return asImp().mat_rows();
706 return asImp().mat_cols();
726 ElimPivot(std::vector<simd_index_type> & pivot);
728 void swap(std::size_t i, simd_index_type j);
731 void operator()(
const T&,
int,
int)
734 std::vector<simd_index_type> & pivot_;
742 void swap(std::size_t i, simd_index_type j);
744 void operator()(
const typename V::field_type& factor,
int k,
int i);
754 void swap(std::size_t i, simd_index_type j)
804 template<
class Func,
class Mask>
805 void luDecomposition(DenseMatrix<MAT>& A, Func func,
806 Mask &nonsingularLanes,
bool throwEarly)
const;
810 template<
typename MAT>
811 DenseMatrix<MAT>::ElimPivot::ElimPivot(std::vector<simd_index_type> & pivot)
814 typedef typename std::vector<size_type>::size_type
size_type;
815 for(
size_type i=0; i < pivot_.size(); ++i) pivot_[i]=i;
818 template<
typename MAT>
819 void DenseMatrix<MAT>::ElimPivot::swap(std::size_t i, simd_index_type j)
821 assign(pivot_[i], j, SimdScalar<simd_index_type>(i) != j);
824 template<
typename MAT>
826 DenseMatrix<MAT>::Elim<V>::Elim(V& rhs)
830 template<
typename MAT>
832 void DenseMatrix<MAT>::Elim<V>::swap(std::size_t i, simd_index_type j)
837 for(std::size_t l = 0; l <
lanes(j); ++l)
838 swap(
lane(l, (*rhs_)[ i ]),
842 template<
typename MAT>
844 void DenseMatrix<MAT>::
845 Elim<V>::operator()(
const typename V::field_type& factor,
int k,
int i)
847 (*rhs_)[k] -= factor*(*rhs_)[i];
850 template<
typename MAT>
851 template<
typename Func,
class Mask>
852 inline void DenseMatrix<MAT>::
853 luDecomposition(DenseMatrix<MAT>& A, Func func, Mask &nonsingularLanes,
854 bool throwEarly)
const
858 typedef typename FieldTraits<value_type>::real_type real_type;
864 real_type singthres =
869 for (size_type i=0; i<rows(); i++)
871 real_type pivmax = fvmeta::absreal(A[i][i]);
872 auto do_pivot = pivmax<pivthres;
875 if (any_true(do_pivot && nonsingularLanes))
878 simd_index_type imax=i;
879 for (size_type k=i+1; k<rows(); k++)
881 auto abs = fvmeta::absreal(A[k][i]);
882 auto mask = abs > pivmax && do_pivot;
883 pivmax =
cond(mask, abs, pivmax);
884 imax =
cond(mask, simd_index_type(k), imax);
887 if (any_true(imax != i && nonsingularLanes)) {
888 for (size_type j=0; j<rows(); j++)
898 for(std::size_t l = 0; l <
lanes(A[i][j]); ++l)
906 nonsingularLanes = nonsingularLanes && !(pivmax<singthres);
908 if(!all_true(nonsingularLanes))
909 DUNE_THROW(FMatrixError,
"matrix is singular");
912 if(!any_true(nonsingularLanes))
917 for (size_type k=i+1; k<rows(); k++)
921 field_type factor = A[k][i]/A[i][i];
923 for (size_type j=i+1; j<rows(); j++)
924 A[k][j] -= factor*A[i][j];
930 template<
typename MAT>
936 DUNE_THROW(FMatrixError,
"Can't solve for a " << rows() <<
"x" << cols() <<
" matrix!");
940#ifdef DUNE_FMatrix_WITH_CHECKING
941 if (any_true(fvmeta::absreal((*
this)[0][0])
943 DUNE_THROW(FMatrixError,
"matrix is singular");
945 x[0] = b[0]/(*this)[0][0];
948 else if (rows()==2) {
950 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
951#ifdef DUNE_FMatrix_WITH_CHECKING
952 if (any_true(fvmeta::absreal(detinv)
954 DUNE_THROW(FMatrixError,
"matrix is singular");
958 x[0] = detinv*((*this)[1][1]*b[0]-(*this)[0][1]*b[1]);
959 x[1] = detinv*((*this)[0][0]*b[1]-(*this)[1][0]*b[0]);
962 else if (rows()==3) {
964 field_type d = determinant();
965#ifdef DUNE_FMatrix_WITH_CHECKING
967 DUNE_THROW(FMatrixError,
"matrix is singular");
970 x[0] = (b[0]*(*this)[1][1]*(*this)[2][2] - b[0]*(*this)[2][1]*(*this)[1][2]
971 - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2]
972 + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / d;
974 x[1] = ((*this)[0][0]*b[1]*(*this)[2][2] - (*this)[0][0]*b[2]*(*this)[1][2]
975 - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2]
976 + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / d;
978 x[2] = ((*this)[0][0]*(*this)[1][1]*b[2] - (*this)[0][0]*(*this)[2][1]*b[1]
979 - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0]
980 + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / d;
989 SimdMask<typename FieldTraits<value_type>::real_type>
990 nonsingularLanes(
true);
992 luDecomposition(A, elim, nonsingularLanes,
true);
995 for(
int i=rows()-1; i>=0; i--) {
996 for (size_type j=i+1; j<rows(); j++)
997 rhs[i] -= A[i][j]*x[j];
998 x[i] = rhs[i]/A[i][i];
1003 template<
typename MAT>
1008 DUNE_THROW(FMatrixError,
"Can't invert a " << rows() <<
"x" << cols() <<
" matrix!");
1012#ifdef DUNE_FMatrix_WITH_CHECKING
1013 if (any_true(fvmeta::absreal((*
this)[0][0])
1015 DUNE_THROW(FMatrixError,
"matrix is singular");
1017 (*this)[0][0] = field_type( 1 ) / (*this)[0][0];
1020 else if (rows()==2) {
1022 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
1023#ifdef DUNE_FMatrix_WITH_CHECKING
1024 if (any_true(fvmeta::absreal(detinv)
1026 DUNE_THROW(FMatrixError,
"matrix is singular");
1028 detinv = field_type( 1 ) / detinv;
1030 field_type temp=(*this)[0][0];
1031 (*this)[0][0] = (*this)[1][1]*detinv;
1032 (*this)[0][1] = -(*this)[0][1]*detinv;
1033 (*this)[1][0] = -(*this)[1][0]*detinv;
1034 (*this)[1][1] = temp*detinv;
1039 using K = field_type;
1041 K t4 = (*this)[0][0] * (*this)[1][1];
1042 K t6 = (*this)[0][0] * (*this)[1][2];
1043 K t8 = (*this)[0][1] * (*this)[1][0];
1044 K t10 = (*this)[0][2] * (*this)[1][0];
1045 K t12 = (*this)[0][1] * (*this)[2][0];
1046 K t14 = (*this)[0][2] * (*this)[2][0];
1048 K det = (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+
1049 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]);
1052 K matrix01 = (*this)[0][1];
1053 K matrix00 = (*this)[0][0];
1054 K matrix10 = (*this)[1][0];
1055 K matrix11 = (*this)[1][1];
1057 (*this)[0][0] = ((*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this)[2][1])*t17;
1058 (*this)[0][1] = -((*this)[0][1] * (*this)[2][2] - (*this)[0][2] * (*this)[2][1])*t17;
1059 (*this)[0][2] = (matrix01 * (*this)[1][2] - (*this)[0][2] * (*this)[1][1])*t17;
1060 (*this)[1][0] = -((*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this)[2][0])*t17;
1061 (*this)[1][1] = (matrix00 * (*this)[2][2] - t14) * t17;
1062 (*this)[1][2] = -(t6-t10) * t17;
1063 (*this)[2][0] = (matrix10 * (*this)[2][1] - matrix11 * (*this)[2][0]) * t17;
1064 (*this)[2][1] = -(matrix00 * (*this)[2][1] - t12) * t17;
1065 (*this)[2][2] = (t4-t8) * t17;
1070 std::vector<simd_index_type> pivot(rows());
1071 SimdMask<typename FieldTraits<value_type>::real_type>
1072 nonsingularLanes(
true);
1073 luDecomposition(A, ElimPivot(pivot), nonsingularLanes,
true);
1074 DenseMatrix<MAT>& L=A;
1075 DenseMatrix<MAT>& U=A;
1080 for(size_type i=0; i<rows(); ++i)
1084 for (size_type i=0; i<rows(); i++)
1085 for (size_type j=0; j<i; j++)
1086 for (size_type k=0; k<rows(); k++)
1087 (*
this)[i][k] -= L[i][j]*(*this)[j][k];
1090 for (size_type i=rows(); i>0;) {
1092 for (size_type k=0; k<rows(); k++) {
1093 for (size_type j=i+1; j<rows(); j++)
1094 (*
this)[i][k] -= U[i][j]*(*this)[j][k];
1095 (*this)[i][k] /= U[i][i];
1099 for(size_type i=rows(); i>0; ) {
1101 for(std::size_t l = 0; l <
lanes((*
this)[0][0]); ++l)
1103 std::size_t pi =
lane(l, pivot[i]);
1105 for(size_type j=0; j<rows(); ++j)
1106 std::swap(
lane(l, (*
this)[j][pi]),
1107 lane(l, (*
this)[j][ i]));
1114 template<
typename MAT>
1120 DUNE_THROW(FMatrixError,
"There is no determinant for a " << rows() <<
"x" << cols() <<
" matrix!");
1123 return (*
this)[0][0];
1126 return (*
this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0];
1130 field_type t4 = (*this)[0][0] * (*this)[1][1];
1131 field_type t6 = (*this)[0][0] * (*this)[1][2];
1132 field_type t8 = (*this)[0][1] * (*this)[1][0];
1133 field_type t10 = (*this)[0][2] * (*this)[1][0];
1134 field_type t12 = (*this)[0][1] * (*this)[2][0];
1135 field_type t14 = (*this)[0][2] * (*this)[2][0];
1137 return (t4*(*
this)[2][2]-t6*(*
this)[2][1]-t8*(*
this)[2][2]+
1138 t10*(*
this)[2][1]+t12*(*
this)[1][2]-t14*(*
this)[1][1]);
1144 SimdMask<typename FieldTraits<value_type>::real_type>
1145 nonsingularLanes(
true);
1147 luDecomposition(A, ElimDet(det), nonsingularLanes,
false);
1148 assign(det, field_type(0), !nonsingularLanes);
1150 for (size_type i = 0; i < rows(); ++i)
1157 namespace DenseMatrixHelp {
1160 template <
typename MAT,
typename V1,
typename V2>
1167 for(size_type i=0; i<matrix.
rows(); ++i)
1170 for(size_type j=0; j<matrix.
cols(); ++j)
1172 ret[i] += matrix[i][j]*x[j];
1179 template <
typename K,
int rows,
int cols>
1182 typedef typename FieldMatrix<K,rows,cols>::size_type size_type;
1184 for(size_type i=0; i<cols(); ++i)
1187 for(size_type j=0; j<rows(); ++j)
1188 ret[i] += matrix[j][i]*x[j];
1193 template <
typename K,
int rows,
int cols>
1194 static inline FieldVector<K,rows> mult(
const FieldMatrix<K,rows,cols> &matrix,
const FieldVector<K,cols> & x)
1196 FieldVector<K,rows> ret;
1202 template <
typename K,
int rows,
int cols>
1203 static inline FieldVector<K,cols> multTransposed(
const FieldMatrix<K,rows,cols> &matrix,
const FieldVector<K,rows> & x)
1205 FieldVector<K,cols> ret;
1206 multAssignTransposed( matrix, x, ret );
1214 template<
typename MAT>
1218 s << a[i] << std::endl;
Macro for wrapping boundary checks.
Generic iterator class for dense vector and matrix implementations.
Definition: densevector.hh:128
A dense n x m matrix.
Definition: densematrix.hh:160
ConstIterator const_iterator
typedef for stl compliant access
Definition: densematrix.hh:267
bool operator!=(const DenseMatrix< Other > &y) const
Binary matrix incomparison.
Definition: densematrix.hh:368
void mv(const X &x, Y &y) const
y = A x
Definition: densematrix.hh:378
Traits::value_type field_type
export the type representing the field
Definition: densematrix.hh:177
void solve(V &x, const V &b) const
Solve system A x = b.
size_type cols() const
number of columns
Definition: densematrix.hh:704
ConstIterator beforeEnd() const
Definition: densematrix.hh:287
bool operator==(const DenseMatrix< Other > &y) const
Binary matrix comparison.
Definition: densematrix.hh:358
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition: densematrix.hh:456
FieldTraits< vt >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: densematrix.hh:548
std::remove_reference< const_row_reference >::type::ConstIterator ConstColIterator
rename the iterators for easier access
Definition: densematrix.hh:271
ConstIterator beforeBegin() const
Definition: densematrix.hh:294
Traits::value_type block_type
export the type representing the components
Definition: densematrix.hh:180
derived_type & axpy(const field_type &k, const DenseMatrix< Other > &y)
vector space axpy operation (*this += k y)
Definition: densematrix.hh:348
void mtv(const X &x, Y &y) const
y = A^T x
Definition: densematrix.hh:395
size_type size() const
size method (number of rows)
Definition: densematrix.hh:223
size_type M() const
number of columns
Definition: densematrix.hh:692
MAT & rightmultiply(const DenseMatrix< M2 > &M)
Multiplies M from the right to this matrix.
Definition: densematrix.hh:634
Iterator end()
end iterator
Definition: densematrix.hh:245
Iterator beforeBegin()
Definition: densematrix.hh:259
derived_type & operator/=(const field_type &k)
vector space division by scalar
Definition: densematrix.hh:339
derived_type & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: densematrix.hh:331
Iterator beforeEnd()
Definition: densematrix.hh:252
Traits::value_type value_type
export the type representing the field
Definition: densematrix.hh:174
void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A x
Definition: densematrix.hh:478
void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition: densematrix.hh:502
size_type rows() const
number of rows
Definition: densematrix.hh:698
void mmv(const X &x, Y &y) const
y -= A x
Definition: densematrix.hh:445
void invert()
Compute inverse.
MAT & leftmultiply(const DenseMatrix< M2 > &M)
Multiplies M from the left to this matrix.
Definition: densematrix.hh:616
void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition: densematrix.hh:490
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition: densematrix.hh:467
Traits::derived_type derived_type
type of derived matrix class
Definition: densematrix.hh:171
row_reference operator[](size_type i)
random access
Definition: densematrix.hh:212
bool exists(size_type i, size_type j) const
return true when (i,j) is in pattern
Definition: densematrix.hh:712
Iterator RowIterator
rename the iterators for easier access
Definition: densematrix.hh:234
FieldTraits< value_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition: densematrix.hh:515
void umv(const X &x, Y &y) const
y += A x
Definition: densematrix.hh:412
DenseIterator< const DenseMatrix, const row_type, const_row_reference > ConstIterator
Iterator class for sequential access.
Definition: densematrix.hh:265
derived_type & operator-=(const DenseMatrix< Other > &y)
vector space subtraction
Definition: densematrix.hh:322
size_type N() const
number of rows
Definition: densematrix.hh:686
FieldTraits< vt >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition: densematrix.hh:533
Traits::row_type row_type
The type used to represent a row (must fulfill the Dune::DenseVector interface)
Definition: densematrix.hh:186
Traits::size_type size_type
The type used for the index access and size operation.
Definition: densematrix.hh:183
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:192
FieldTraits< value_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition: densematrix.hh:523
std::remove_reference< row_reference >::type::Iterator ColIterator
rename the iterators for easier access
Definition: densematrix.hh:236
Traits::row_reference row_reference
The type used to represent a reference to a row (usually row_type &)
Definition: densematrix.hh:189
Iterator iterator
typedef for stl compliant access
Definition: densematrix.hh:232
ConstIterator ConstRowIterator
rename the iterators for easier access
Definition: densematrix.hh:269
field_type determinant() const
calculates the determinant of this matrix
DenseIterator< DenseMatrix, row_type, row_reference > Iterator
Iterator class for sequential access.
Definition: densematrix.hh:230
void umtv(const X &x, Y &y) const
y += A^T x
Definition: densematrix.hh:423
ConstIterator begin() const
begin iterator
Definition: densematrix.hh:274
@ blocklevel
The number of block levels we contain. This is 1.
Definition: densematrix.hh:197
Iterator begin()
begin iterator
Definition: densematrix.hh:239
void umhv(const X &x, Y &y) const
y += A^H x
Definition: densematrix.hh:434
derived_type & operator+=(const DenseMatrix< Other > &y)
vector space addition
Definition: densematrix.hh:312
ConstIterator end() const
end iterator
Definition: densematrix.hh:280
Interface for a class of dense vectors over a given field.
Definition: densevector.hh:235
size_type size() const
size method
Definition: densevector.hh:297
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: densevector.hh:678
Error thrown if operations of a FieldMatrix fail.
Definition: densematrix.hh:146
static ctype pivoting_limit()
return threshold to do pivoting
Definition: precision.hh:26
static ctype absolute_limit()
return threshold to declare matrix singular
Definition: precision.hh:50
static ctype singular_limit()
return threshold to declare matrix singular
Definition: precision.hh:38
A dense n x m matrix.
Definition: fmatrix.hh:68
vector space out of a tensor product of fields.
Definition: fvector.hh:93
constexpr FieldVector()
Constructor making default-initialized vector.
Definition: fvector.hh:113
Default exception class for mathematical errors.
Definition: exceptions.hh:239
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: matrix.hh:1006
A free function to provide the demangled class name of a given object or type as a string.
static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret)
calculates ret = matrix * x
Definition: densematrix.hh:1161
A few common exception classes.
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:28
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:58
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:25
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:10
typename SimdIndexTypeTraits< V >::type SimdIndex
An simd vector of indices corresponding to a simd vector V.
Definition: simd.hh:220
T lane(std::size_t l, const T &v)
access a lane of a simd vector (scalar version)
Definition: simd.hh:340
void assign(T &dst, const T &src, bool mask)
masked Simd assignment (scalar version)
Definition: simd.hh:421
const T1 cond(bool b, const T1 &v1, const T2 &v2)
conditional evaluate
Definition: conditional.hh:26
int sign(const T &val)
Return the sign of the value.
Definition: math.hh:121
K conjugateComplex(const K &x)
compute conjugate complex of x
Definition: math.hh:105
std::size_t lanes(const T &)
get the number of lanes of a simd vector (scalar version)
Definition: simd.hh:336
Various precision settings for calculations with FieldMatrix and FieldVector.
you have to specialize this structure for any type that should be assignable to a DenseMatrix
Definition: densematrix.hh:79
Traits for type conversions and type information.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.