Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there no BLAS routines for addition and subtraction

In BLAS there are routines like

dscal    scale a vector by a constant  
dinit    initialize a vector with given value
daxpy    perform y = a*x + y

and so on. But there are apparently no routines for vector addition or vector subtraction. If this is really true, what is the reason for it?

Especially since there are routines performing more trivial operations such as dinit or dscal. Sure one could use daxpy with a=1 or a=-1 to perform addition/subtraction from a given vector, but that seems to me to be overly complicated.

like image 216
Andreas H. Avatar asked Feb 07 '18 14:02

Andreas H.


People also ask

Why use BLAS?

Although the BLAS specification is general, BLAS implementations are often optimized for speed on a particular machine, so using them can bring substantial performance benefits. BLAS implementations will take advantage of special floating point hardware such as vector registers or SIMD instructions.

What is BLAS in c++?

The BLAS (Basic Linear Algebra Subprograms) are routines that provide standard building blocks for performing basic vector and matrix operations.

What is Blas and LAPACK?

BLAS (Basic Linear Algebra Subprograms) is a library of vector, vector-vector, matrix-vector and matrix-matrix operations. LAPACK, a library of dense and banded matrix linear algebra routines such as solving linear systems, the eigenvalue- and singular value decomposition.


1 Answers

To find a plausible explanation we have to go back to BLAS history

There we can learn that Level 1 was designed in the 70's, well before Level 2, 3 ( Level 2 was 1987, and Level 3 was 1989).

Concerning Level 1 history, in the 1979 paper Basic Linear Algebra Subprograms for Fortran Usage by CL Lawson et al. we can read, page 3

The criterion for including an operation in the package was that it should involve just one level of looping and occur in the usual algorithms of numerical linear algebra, such as Gaussian elimination or the various elimination methods using orthogonal transformations.

This paper is based on an initial specification, 1973 A Proposal for Standard Linear Algebra Subprograms by Hanson et al. In this document, again you can read:

For example, it has been found [Krogh (1)] that the use of assembly coded modules in a double precision program for solving linear equations based on Householder transfZormations with column scaling and column interchanges reduced the execution time on a Univac 1108 by 15% to 30% relative to the time required when carefully written Fortran modules were used.

and after

The operations which we feel belong in Class I according to the above stated criteria are: (1) the dot product (inner product) of two vectors, elementary vector operation, y := ax + y where x and y are n-vectors and a is a scalar, and (3) the Givens 2 x 2 orthogonal transformation applied to a 2 x n submatrix.

We can see that the main concern was to implement algorithms (linear solvers...) using linear substitution, Givens rotations or Householder transformations. In this context the most important operations as explained in the cited references, are axpy, scaling, dot, norm, etc. The goal was not to provide a complete set of vector operations like addition, subtraction etc... but only to concentrate the effort on a small set of procedures.

like image 83
Picaud Vincent Avatar answered Jan 01 '23 09:01

Picaud Vincent