I'm trying to solve Generalized Eigenvalue Problem with Java and I'm currently using OjAlgo, but it cannot solve random symmetrical A
and B
. Only positive definite symmetrical A
and B
for the moment. My A
and B
are random symmetrical. Not positive definite.
So I will try with Python this time. Calling Python code from Java. I have one question.
Calling this MATLAB code:
[V, D] = eig(A, B)
Will solve this problem:
A*V = B*V*D
What is the equivalent code for [V, D] = eig(A, B)
in Python, or other language/library that can be controlled from Java?
The current setup to solve this problem, I have been used GNU Octave for the moment, by writing a file AB
, then use ProcessBuilder
class to run a .m
file that will load that AB
and then do its procedure and then save a file VD
and then after that, Java will read that VD
file. Yes...it's working. But I think there must be a better way to do it?
Have a look at my project. It's image classification in Java. It's working with Yale database and Jaffed Database. Very good.
https://github.com/DanielMartensson/jFaces---Image-classification-in-Java-
Example how I solve A
and B
in octave:
>> A
A =
3.509281 -0.290541 0.849415 2.013013 0.063750
-0.290541 1.818891 -0.474449 0.278068 -1.287872
0.849415 -0.474449 1.340873 0.739895 0.882484
2.013013 0.278068 0.739895 1.645680 0.414309
0.063750 -1.287872 0.882484 0.414309 4.045986
>> B
B =
5.4158 2.8121 2.6082 3.7357 -3.8168
2.8121 6.7481 1.6286 2.6166 -1.5062
2.6082 1.6286 3.9394 1.7020 -3.1379
3.7357 2.6166 1.7020 3.2538 -2.6001
-3.8168 -1.5062 -3.1379 -2.6001 3.4518
>> [V, D] = eig(A, B)
V =
0.300780 -0.195288 0.209747 0.946256 1.940305
0.366251 -0.228222 -0.050912 -0.057503 -0.652739
0.243410 0.292928 0.295219 -0.315470 2.340029
-0.538232 0.328562 -0.767245 -0.821764 0.776394
0.098344 -0.251445 0.047482 -0.026229 4.613170
D =
Diagonal Matrix
0.086670 0 0 0 0
0 0.219835 0 0 0
0 0 0.420197 0 0
0 0 0 1.207737 0
0 0 0 0 157.713007
>>