Eigenvalue and Eigenvector calculation

Discussion in 'Questions (Windows Mobile)' started by klaus, Nov 19, 2007.

  1. klaus

    klaus Expert Licensed 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
     

    Attached Files:

  2. agraham

    agraham Expert Licensed User

    I assume that it is in Basic. Can't you restucture it to run under B4PPC? If not then post the source and someone here might have a go!
     
  3. klaus

    klaus Expert Licensed User

  4. agraham

    agraham Expert Licensed 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.
     

    Attached Files:

  5. klaus

    klaus Expert Licensed User

    Hello agraham
    Thank you very much for your help, I will check the routine with different matrices, higher order ones and perhaps more specific.
    I will keep you informed.
    Klaus
     
  6. klaus

    klaus Expert Licensed User

    Hello agraham

    I tested the routine with higher order matrices and it works well, where the other routine I have failes.

    Thank you once again for your precious help

    Klaus
     
  7. agraham

    agraham Expert Licensed 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.
     
  8. klaus

    klaus Expert Licensed 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.basic4ppc.com/forum/showthread.php?t=1245

    Klaus
    Switzerland
     
  9. agraham

    agraham Expert Licensed User

    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
    Code:
    Dim someArray(someSize) As double
     
  10. klaus

    klaus Expert Licensed User

    Hello agraham,
    Thank you for your advice.
    It's done and brings 7 sec more time saving.

    Best regards
    Klaus
     
Loading...