newling
newling

Reputation: 634

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.

Upvotes: 5

Views: 881

Answers (2)

Stephen Canon
Stephen Canon

Reputation: 106197

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.

Upvotes: 6

ztik
ztik

Reputation: 3612

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.

Upvotes: 4

Related Questions