3#ifndef DUNE_DYNMATRIXEIGENVALUES_HH
4#define DUNE_DYNMATRIXEIGENVALUES_HH
8#include <dune/common/std/memory.hh>
22 namespace DynamicMatrixHelp {
25 extern void eigenValuesNonsymLapackCall(
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);
71 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, &matrixVector[0], &N,
72 &eigenR[0], &eigenI[0], 0, &N, 0, &N, &work[0],
77 std::cerr <<
"For matrix " << matrix <<
" eigenvalue calculation failed! " << std::endl;
81 eigenValues.resize(N);
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:683
Construct a matrix with a dynamic size.
Definition: dynmatrix.hh:59
Construct a vector with a dynamic size.
Definition: dynvector.hh:57
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:279
This file implements a dense matrix with dynamic numbers of rows and columns.
static void eigenValuesNonSym(const DynamicMatrix< K > &matrix, DynamicVector< C > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition: dynmatrixev.hh:39
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignment.hh:11