?swap
Exchange elements between two vectors.
Interface Definition
C interface:
void cblas_sswap(const BLASINT n, float *x, const BLASINT incx, float *y, const BLASINT incy);
void cblas_dswap(const BLASINT n, double *x, const BLASINT incx, double *y, const BLASINT incy);
void cblas_cswap(const BLASINT n, void *x, const BLASINT incx, void *y, const BLASINT incy);
void cblas_zswap(const BLASINT n, void *x, const BLASINT incx, void *y, const BLASINT incy);
Fortran interface:
CALL SSWAP(N, SX, INCX, SY, INCY)
CALL DSWAP(N, SX, INCX, SY, INCY)
CALL CSWAP(N, SX, INCX, SY, INCY)
CALL ZSWAP(N, SX, INCX, SY, INCY)
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
n |
Integer |
Number of elements in the x and y vectors |
Input |
x |
|
Vector x. The vector size is at least (1+(n-1)*abs(incx)). |
Input/Output |
incx |
Integer |
Increment for the elements of vector x |
Input |
y |
|
Vector y. The vector size is at least (1+(n-1)*abs(incy)). |
Input/Output |
incy |
Integer |
Vector unit increment step in y |
Input |
Dependencies
#include "kblas.h"
Examples
C interface:
int n = 5, incx = 1, incy = 1;
/*
* Input X: 0.340188, -0.105617, 0.283099, 0.298440, 0.411647
* Input 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_sswap(n, x, incx, y, incy);
/*
* Output X: -0.302449, -0.164777, 0.268230, -0.222225, 0.053970
* Output Y: 0.340188, -0.105617, 0.283099, 0.298440, 0.411647
* */
Fortran interface:
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/
EXTERNAL SSWAP
CALL SSWAP(N, X, INCX, Y, INCY)
* Output X: -0.302449, -0.164777, 0.268230, -0.222225, 0.053970
* Output Y: 0.340188, -0.105617, 0.283099, 0.298440, 0.411647