Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lapackpp vs Boost BLAS

for start, i am newbie in C++.

i am writing a program for my Master thesis which part of it suppose to solve regression in a recursive way.

I would like to solve:

Ax = y

In my case computation speed is not neglectable, that is way i would like to know if Boost::BLAS using

x = (A^T A)^{-1}A^Ty

will require less computation time then Lapackpp (I am using gentoo).

P.S. I was able to find at Lapackpp project site Class documentations but not examples. Could someone provides me some examples in case Lapack is faster then Boost::BLAS

Thanks

like image 813
Eagle Avatar asked Dec 28 '22 03:12

Eagle


1 Answers

From a numerical analysis standpoint, you never want to write code that

  • Explicitly inverts a matrix, or
  • Forms the matrix of normal equations (A^T A) for a regression

Both of these are more work and less accurate (and likely less stable) than the alternatives that solve the same problem directly.

Whenever you see some math showing a matrix inversion, that should be read to mean "solve a system of linear equations", or factor the matrix and use the factorization to solve the system. Both BLAS and Lapack have routines to do this.

Similarly, for the regression, call a library function that computes a regression, or read how to do it yourself. The normal equations method is the textbook wrong way to do it.

like image 153
Phil Miller Avatar answered Jan 04 '23 00:01

Phil Miller