Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there a blas subroutine (ISAMAX) for argmax abs but none for argmax?

Why is there a blas subroutine ISAMAX for argmax abs but not for argmax ?

In C++ using std::max_element with compiler optimisation flag -O3 I am getting speeds comparable to blas_isamax (16 ms vs 9 ms), so at the moment my question is more out of interest than out of a need for speed.

like image 222
newling Avatar asked Feb 10 '15 16:02

newling


2 Answers

BLAS was designed to provide low-level routines necessary to implement common linear-algebra operations (it is the "Basic Linear Algebra Subprograms", after all).

To name just one of many uses, getting the largest-magnitude element of a vector is necessary for pivot selection in LU factorization, which is one of the most fundamental workhorses of linear algebra. By comparison, getting the max element turns out to basically never be necessary for linear algebra, which is why it's not one of the BLAS operations*.

(*) it was actually recommended that the max operation be added to the BLAS in the 2001 BLAS Technical Forum Standard, but it hasn't yet seen widespread adoption.

like image 159
Stephen Canon Avatar answered Nov 20 '22 03:11

Stephen Canon


The BLAS library is a scientific computing library and it was designed in parallel with LAPACK. The ISAMAX subroutine utilizes the infinity norm of a vector. For more information you can refer to wikipedia's link. Many LAPACK algorithms need the infinity norm, so BLAS library defined this standard subroutine.

On the other hand, the maximum value of a vector is needed extensively in general computing and C++ introduced std::max_element. However this function is not common for scientific computing.

like image 4
ztik Avatar answered Nov 20 '22 03:11

ztik