SAXPY

From Wikipedia, the free encyclopedia

SAXPY (Scalar Alpha X Plus Y) is one of the functions in the Basic Linear Algebra Subprograms (BLAS) package, and is a common operation in computations with vector processors . SAXPY is a combination of scalar multiplication and vector addition,

\mathbf{y} = \alpha \cdot \mathbf{x} + \mathbf{y},

where α is a scalar, and \mathbf{x} and \mathbf{y} are vectors. As with most functions, there exist four variants of SAXPY in the BLAS package, namely SAXPY, DAXPY, CAXPY and ZAXPY. These variants differ only in the datatype of scalar α.

Contents

[edit] Different Datatypes

[edit] SAXPY

SAXPY is not only the generic term for the combined scalar multiplication plus vector addition operation, but also the specific variant where the scalar α and the vectors \mathbf{x} and \mathbf{y} are of single precision.

[edit] DAXPY

DAXPY denotes SAXPY with double precision α, \mathbf{x} and \mathbf{y}.

[edit] CAXPY

CAXPY denotes SAXPY with complex α, \mathbf{x} and \mathbf{y}.

[edit] ZAXPY

ZAXPY denotes SAXPY with double precision complex α, \mathbf{x} and \mathbf{y}.

[edit] Generic Implementation

The most generic implementation of SAXPY looks like the following:

for (int i = m; i < n; i++) {
   y[i] = a * x[i] + y[i];
}