0

I am trying to switch from Mathematica to C on a windows platform. My most difficult task is calculating Eigenvalues and Eigenvectors for real non-symmetric matrices up to about 50x50. I have succeeded in getting Microsoft Visual Studio to run the GNU GSL function gsl_eigen_nonsymmv. When I test the accuracy by using the results to calculate the original matrix, (evects*Diagonal(evals)*Invesre(evects)), the accuracy is acceptable for smaller matrices (<20x20), by breaks down compared to Mathematica above 30x30.

I know the process is iterative, but I can not figure out what the convergence criteria is. I assume the answer lies in the function "nonsymmv_get_right_eigenvectors", but the documentation does not even acknowledge the existence of this function. I was able to access and increase the variable "max_iterations" from the default of 1150 to 3000 with no change. I also blindly tried manipulating the following variable up or down by 5-10 orders of magnitude without ANY change in the results (smin, bignum, beta, xnorm).

Any help or insights would be greatly appreciated. I am a scientist who programs only when needed. Thanks

Jim C
  • 1
  • Are you calculating with doubles or floats? And what else do you know about your matrices? Symmetric / Hermitian ... – Kaveh Vahedipour May 26 '20 at 07:19
  • Programs like Mathematica and Matlab invest a lot of effort into analysing the matrices that they are faced with for any operation to use the best suited algorithm out there, Here are all the different Eigenvalue routines in Lapack for example. http://www.netlib.org/lapack/explore-html/d9/d8e/group__double_g_eeigen.html. Each routine will perform differently on different data. – Kaveh Vahedipour May 26 '20 at 07:26
  • Kaveh Vahedipour Thank you so much for your response. I am working with real non-symmetric double precision matrices. I was under the impression that the routines in gsl were taken from Lapack. Do you think I can find a more accurate routine in Lapack. I have been proceeding on the assumption that it uses an iterative process and if I change the convergence criterion, I could improve the accuracy. – Jim C Jun 02 '20 at 15:58
  • It depends on how you build GSL. They deliver own implementations or the ones you provide at link time: For example: `gcc example.o -lgsl -lgslcblas` vs `gcc example.o -lgsl -lopenblas`, where you can replace `lopenblas` with `latlas`,`lmkl_rt`.... – Kaveh Vahedipour Jun 02 '20 at 18:05
  • Have a look at `http://www.netlib.org/lapack/double/dgegv.f` and `http://www.netlib.org/lapack/double/dggev.f` i wouldn't also use GSL for this purpose. but got for the lapack drivers themselves. GSL wraps around those as dicussed. – Kaveh Vahedipour Jun 02 '20 at 18:15
  • @KavehVahedipour Thank you so much for taking the time to help me. I will try this soon. – Jim C Jun 04 '20 at 08:52
  • @KavehVahedipour Again, I want to thank you for your kindness in responding to my question. I have been struggling with Lapack for 2 weeks. I just can not get Visual Studio to compile dgeev. Is there a simple way to accurately calculate Eigenvalues and Eigenvectors using C that does not require a degree in Computer science? – Jim C Jun 17 '20 at 11:14
  • Once you get it right, you will find that it was not hard after all. The way there can be a bitch. Is what you have on github or anywhere one could review the code? – Kaveh Vahedipour Jun 18 '20 at 09:08

0 Answers0