I am following a course of computational material physics. The professor uses fortran to code and uses lapack to solve eigenvalue problems. So far I just know c++. There is an equivalent library that make the same as LAPACK but in c++? Which is the best one ? Should I prefer to use fortran rather than c++ for my scope? Thank you
Definitely use C++ and Eigen. Reasons:
- Sounds like it fits best for your case.
- Eigen beats LAPACK using optimization flags (
-O3) and a good compiler (GCC, Clang). At least for most tests I recently performed (dense linear algebra)
- Once you debug your application use the
-ffast-mathcompiler flag for a huge speedup, but test your output to see if it remains correct. I've noticed this is specially useful with Eigen.
- C++ is an actively evolving high-performance language. Eigen takes advantage of its advanced features to optimize your code and make most things compile-time and SIMD/vectorized.
- Virtually the only disadvantage of Eigen over LAPACK is that LAPACK has a standardized API. You can switch to another LAPACK library for higher performance in some cases.
- Still, keep an eye on LAPACK for any routines from Eigen that are not serving you well.
- Many production code in my field (computer vision, augmented reality, etc) that I've seen is using Eigen, and previously used LAPACK.
- You can always use LAPACK as well with your C++ code when you want to follow your professor more closely, and compare with Eigen to be a good student. But if you just wanted to follow the professor, without regard to the best alternative, you might as well just learn Fortran.
- See this: How does Eigen compare to BLAS/LAPACK