我要评分
获取效率
正确性
完整性
易理解

?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

  • Double-precision floating-point type for daxpby
  • Single-precision floating-point type for saxpby
  • Single-precision complex number type for caxpby
  • Double-precision complex number type for zaxpby

Multiplication coefficient

Input

x

  • For daxpby, x is of double-precision floating-point type.
  • For saxpby, x is of single-precision floating-point type.
  • For caxpby, x is of single-precision complex number type.
  • For zaxpby, x is of double-precision complex number type.

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

  • Double-precision floating-point type for daxpby
  • Single-precision floating-point type for saxpby
  • Single-precision complex number type for caxpby
  • Double-precision complex number type for zaxpby

Multiplication coefficient

Input

y

  • For daxpby, y is of double-precision floating-point type.
  • For saxpby, y is of single-precision floating-point type.
  • For caxpby, y is of single-precision complex number type.
  • For zaxpby, y is of double-precision complex number type.

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