3 #ifndef DUNE_DYNMATRIXEIGENVALUES_HH 4 #define DUNE_DYNMATRIXEIGENVALUES_HH 22 namespace DynamicMatrixHelp {
26 const char* jobvl,
const char* jobvr,
const long 27 int* n,
double* a,
const long int* lda,
double* wr,
double* wi,
double* vl,
28 const long int* ldvl,
double* vr,
const long int* ldvr,
double* work,
29 const long int* lwork,
const long int* info);
38 template <
typename K,
class C>
43 const long int N = matrix.
rows();
44 const char jobvl =
'n';
45 const char jobvr =
'n';
49 std::unique_ptr<double[]> matrixVector = Std::make_unique<double[]>(N*N);
53 for(
int i=0; i<N; ++i)
55 for(
int j=0; j<N; ++j, ++row)
57 matrixVector[ row ] = matrix[ i ][ j ];
62 std::unique_ptr<double[]> eigenR = Std::make_unique<double[]>(N);
63 std::unique_ptr<double[]> eigenI = Std::make_unique<double[]>(N);
64 std::unique_ptr<double[]> work = Std::make_unique<double[]>(3*N);
72 &eigenR[0], &eigenI[0], 0, &N, 0, &N, &work[0],
77 std::cerr <<
"For matrix " << matrix <<
" eigenvalue calculation failed! " << std::endl;
82 for (
int i=0; i<N; ++i)
83 eigenValues[i] = std::complex<double>(eigenR[i], eigenI[i]);
size_type rows() const
number of rows
Definition: densematrix.hh:695
static void eigenValuesNonSym(const DynamicMatrix< K > &matrix, DynamicVector< C > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition: dynmatrixev.hh:39
Construct a vector with a dynamic size.
Definition: dynvector.hh:30
void eigenValuesNonsymLapackCall(const char *jobvl, const char *jobvr, const long int *n, double *a, const long int *lda, double *wr, double *wi, double *vl, const long int *ldvl, double *vr, const long int *ldvr, double *work, const long int *lwork, const long int *info)
Definition: dynmatrixev.cc:136
Construct a matrix with a dynamic size.
Definition: dynmatrix.hh:26
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
static void eigenValues(const FieldMatrix< K, 1, 1 > &matrix, FieldVector< K, 1 > &eigenvalues)
calculates the eigenvalues of a symmetric field matrix
Definition: fmatrixev.hh:45
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:306
Dune namespace.
Definition: alignment.hh:9
void resize(size_type n, value_type c=value_type())
Definition: dynvector.hh:130
This file implements a dense matrix with dynamic numbers of rows and columns.