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.
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.
The BLAS (Basic Linear Algebra Subprograms) are routines that provide standard building blocks for performing basic vector and matrix operations.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With