Eigenvalue and Eigenvector calculation

klaus

Expert
Licensed User
Longtime User
Hello,
Does somebody have a routine to calculate eigenvalues and eigenvectors of real non symetric matrices ?

I have an old one, with several goto's in, but Basic4ppc does'nt like these goto's.
I have another one but it is not acurate enough.


I need this routine for a program which calculates eigenfrequencies and eigenvectors of mecanical systems.
I added some screenshots of the program. The user draws, directly on the screen, the model composed of reference points, springs and masses, introduces the values of the different elements and makes the calculation.

If there is any interest in this program I can submit to the forum.

Thank's in advance.

Klaus
Switzerland
 

Attachments

  • FreqModel.jpg
    FreqModel.jpg
    19.1 KB · Views: 212
  • FreqResults.jpg
    FreqResults.jpg
    20.9 KB · Views: 215
  • FreqData.jpg
    FreqData.jpg
    17.5 KB · Views: 190

agraham

Expert
Licensed User
Longtime User
Here you are Klaus. The program is so appalling that I didn't bother to restructure it as I don't understand the program flow. I have been as minimally invasive as I can and have replaced the three For...Next loops that were causing the trouple with synthesised versions - you can easily see where as I have commented out the original code and put a line of "####################" at each location.

I think that I have not altered the calculation in any way but you must run your own cross-checks to make sure.
 

Attachments

  • TestEigenFixed.sbp
    20.4 KB · Views: 191

agraham

Expert
Licensed User
Longtime User
Hi Klaus. I saw in the German forum that your Eigenvalue code doesn't work under the optimising compiler. You should have let me know! Having got it to work before I will not let you down. Version attached that does work. One label ( m2100: ) was out of scope so I moved it and "Do .. Loop" at about line 625 is not valid for the new compiler so I replaced it with a "Do While true .. Loop". Changes commented as before. Usual caveats about testing but the example gives the same results compiled as in the IDE.
 

klaus

Expert
Licensed User
Longtime User
Hello agraham,
This is really good news, I was afraid that with the Goto restrictions of new compiler it would have been much more difficult to make the Eigenvalue routine run again, so I left it besides. Yes I should have let you know about it.

I introduced your modifications in the whole program and of course it works fine.
Speed incease about 8 times, the calculation of an 18*18 matrix takes 5min, yes 300 sec, with the old compiler and now 37 sec. That's a very big improvement !

Thank you very very much for your help. This shows again the big value of this forum.
I have updated the program.
http://www.b4x.com/forum/showthread.php?t=1245

Klaus
Switzerland
 

agraham

Expert
Licensed User
Longtime User
and now 37 sec. That's a very big improvement !
I guess that your program uses a lot of arrays containing numeric data. Try declaring those arrays as doubles, this overrides B4PPCs' weak typing, and see if that shaves a few more seconds off the execution time
B4X:
Dim someArray(someSize) As double
 
Top