Site Tools


saxpy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
saxpy [May 05, 2026 at 14:57] yanevskivsaxpy [June 13, 2026 at 03:13] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +# SAXPY
 +**SAXPY** is an algorithm in high-performance computing (HPC).
  
 +## Math
 +### Vectors
 +Let $\mathbf{y}^{(t)}, \mathbf{x}^{(t)}\in\mathbb{R}^n$ be vectors over real numbers at some discrete time $t\in\mathbb{N}$ and let $a\in\mathbb{R}$ be a real parameter.
 +
 +SAXPY is defined as a vector update of $\mathbf{y}$ at time $t+1$ according to the formula:
 +
 +$$\mathbf{y}^{(t+1)} = a\mathbf{x}^{(t)} + \mathbf{y}^{(t)}$$
 +
 +
 +### Elements
 +We can write $\mathbf{y}^{(t)} = (y_0^{(t)}, y_1^{(t)}, \dots, y_n^{(t)})$ and $\mathbf{x}^{(t)} = (x_0^{(t)}, x_1^{(t)}, \dots, x_n^{(t)})$ 
 +
 +
 +Thus if we look at individual vector elements, where $k\in\{0, 1, \dots, n\}$, we have the following formula:
 +$$y_k^{(t + 1)} = a\cdot x_k^{(t)} + y_k^{(t)}$$
 +
 +## C
 +```c
 +// y - Y vector
 +// x - X vector
 +// a - parameter
 +// N - size of both vectors
 +void saxpy(float* y, float* x, float a, size_t N)
 +{
 +    size_t i;
 +    for (i = 0; i < N; i++) {
 +        y[i] = a * x[i] + y[i];
 +    }
 +}
 +```