1

I am modelling physical system with heat conduction, and to do numerical calculations I need to solve system of linear equations with tridiagonal matrix. I am using this algorithm to get results: http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm But I am afraid that my method is straightforward and not optimal. What C++ library should be used to solve that system in the fastest way? I should also mention that matrix is not changed often (only right part of the equation is changed). Thanks!

user517893
  • 471
  • 4
  • 14

3 Answers3

3

Check out Eigen.

janneb
  • 36,249
  • 2
  • 81
  • 97
  • To my knowledge, Eigen doesn't yet have the concept of tridiagonal or band matrices yet. You can still make a dense matrix and solve that but not sure it would be efficient – Simmovation Apr 05 '17 at 10:13
1

The performance of this algorithm is likely dominated by floating-point division. Use SSE2 to perform two divisions (of ci and di) at once, and you will get close to optimal performance.

Marat Dukhan
  • 11,993
  • 4
  • 27
  • 41
0

It is worth looking at the LAPACK and BLAS interfaces, of which there are several implementation libraries. Originally netlib which is open-source, and then other such as MKL that you have to pay for. The function dgtsv does what you are looking for. The open-source netlib versions don't do any explicit SIMD instructions, but MKL does and will perform best on intel chips.

Simmovation
  • 223
  • 2
  • 9