?axpby
Add the products of two scaled vectors, that is,
.
alpha and beta are multiplication coefficients, and x and y are vectors with a length of n.
Interface Definition
C interface:
void cblas_saxpby(const BLASINT n, const float alpha, const float *x, const BLASINT incx, const float beta, float *y, const BLASINT incy);
void cblas_daxpby(const BLASINT n, const double alpha, const double *x, const BLASINT incx, const double beta, double *y, const BLASINT incy);
void cblas_caxpby(const BLASINT n, const void *alpha, const void *x, const BLASINT incx, const void *beta, void *y, const BLASINT incy);
void cblas_zaxpby(const BLASINT n, const void *alpha, const void *x, const BLASINT incx, const void *beta, void *y, const BLASINT incy);
Fortran interface:
CALL SAXPBY(N, ALPHA, X, INCX, BETA, Y, INCY)
CALL DAXPBY(N, ALPHA, X, INCX, BETA, Y, INCY)
CALL CAXPBY(N, ALPHA, X, INCX, BETA, Y, INCY)
CALL ZAXPBY(N, ALPHA, X, INCX, BETA, Y, INCY)
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
n |
Integer |
Number of elements in the x vector |
Input |
alpha |
|
Multiplication coefficient |
Input |
x |
|
Vector x. The vector size is at least (1+(n-1)*abs(incx)). |
Input |
incx |
Integer |
Increment for the elements of vector x |
Input |
beta |
|
Multiplication coefficient |
Input |
y |
|
Vector y. The vector size is at least (1+(n-1)*abs(incy)). |
Input/Output |
incy |
Integer |
Increment for the elements of vector y |
Input |
Dependencies
#include "kblas.h"
Examples
C interface:
float alpha = 2.0;
float beta = 3.0;
int n = 5, incx = 1, incy = 1;
/**
* X:f 0.340188, -0.105617, 0.283099, 0.298440, 0.411647
* Y: -0.302449, -0.164777, 0.268230, -0.222225, 0.053970
*/
float x[5] = {0.340188, -0.105617, 0.283099, 0.298440, 0.411647};
float y[5] = {-0.302449, -0.164777, 0.268230, -0.222225, 0.053970};
cblas_saxpby(n, alpha, x, incx, beta, y, incy);
/**
* Output Y: -0.226971, -0.705565, 1.370888, -0.069795, 0.985204
*/
Fortran interface:
REAL(4) :: ALPHA=2.0
REAL(4) :: BETA=3.0
INTEGER :: N=5
INTEGER :: INCX=1
INTEGER :: INCY=1
REAL(4) :: X(5)
DATA X /0.340188, -0.105617, 0.283099, 0.298440, 0.411647/
REAL(4) :: Y(5)
DATA Y /-0.302449, -0.164777, 0.268230, -0.222225, 0.053970/
CALL SAXPBY(N, ALPHA, X, INCX, BETA, Y, INCY)
* Output Y : -0.226971, -0.705565, 1.370888, -0.069795, 0.985204