Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1035324 // eigenvaluesOfSymmetricMatrix

JavaX fragment (include) [tags: use-pretranspiled]

Uses 652K of libraries. Click here for Pure Java version (7928L/44K).

1  
!include once #1035331 // EJML Include (Matrix library)
2  
3  
static Complex[] eigenvaluesOfSymmetricMatrix(double[][] matrixData) {
4  
  var matrix = new DMatrixRMaj(matrixData);
5  
6  
  var evd = new SymmetricQRAlgorithmDecomposition_DDRM(false); // false = don't need vectors
7  
  if (!evd.decompose(matrix))
8  
    null;
9  
  
10  
  int n = evd.getNumberOfEigenvalues();
11  
  Complex[] eigenvalues = new[n];
12  
  for i to n: {
13  
    var v = evd.getEigenvalue(i);
14  
    eigenvalues[i] = Complex(v.real, v.imaginary);
15  
  }
16  
  ret eigenvalues;
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035324
Snippet name: eigenvaluesOfSymmetricMatrix
Eternal ID of this version: #1035324/5
Text MD5: 5f4192414454229b65db8dcabb6501bb
Transpilation MD5: 61f9b373d684184ed2692600153b1fa1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-01 16:36:24
Source code size: 524 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 127 / 202
Version history: 4 change(s)
Referenced in: [show references]