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

?ger

That is, . alpha is a multiplication coefficient, A is a general m*n matrix, x is a vector including m elements, and y is a vector including n elements.

Interface Definition

C interface:

void cblas_sger (const enum CBLAS_ORDER order, const BLASINT M, const BLASINT N, const float alpha, const float *X, const BLASINT incX, const float *Y, const BLASINT incY, float *A, const BLASINT lda);

void cblas_dger (const enum CBLAS_ORDER order, const BLASINT M, const BLASINT N, const double alpha, const double *X, const BLASINT incX, const double *Y, const BLASINT incY, double *A, const BLASINT lda);

Fortran interface:

CALL SGER(M, N, ALPHA, X, INCX, Y, INCY, A, LDA)

CALL DGER(M, N, ALPHA, X, INCX, Y, INCY, A, LDA)

Parameters

Parameter

Type

Description

Input/Output

order

Enumeration type CBLAS_ORDER

Indicates whether the matrix is in row- or column-major order.

Input

M

Integer

Number of rows in matrix A. The value of M must be greater than or equal to 0.

Input

N

Integer

Number of columns in matrix A. The value of N must be greater than or equal to 0.

Input

alpha

  • Single-precision floating-point type for sger
  • Double-precision floating-point type for dger

Multiplication coefficient.

Input

X

  • Single-precision floating-point type for sger
  • Double-precision floating-point type for dger

Matrix X. The vector scale is at least (1+(M-1)*abs(incx)).

Input

incX

Integer

Increment for elements in vector X. The value cannot be 0.

Input

Y

  • Single-precision floating-point type for sger
  • Double-precision floating-point type for dger

Matrix Y. The vector size is at least (1+(N-1)*abs(incy)).

Input

incY

Integer

Increment for elements in vector Y. The value cannot be 0.

Input

A

  • Single-precision floating-point type for sger
  • Double-precision floating-point type for dger

Matrix A(lda, n).

Output

lda

Integer

Length of the leading dimension in matrix A. If A is a column-store matrix, lda must be greater than or equal to max(1, m). Otherwise, lda must be greater than or equal to max(1, n).

Input

Dependency

#include "kblas.h"

Examples

C interface:

    int m = 4, n = 4, lda =4; 
    float alpha = 1.0; 
    int incx = 1, incy = 1; 
    /** 
     * X: 
     *    0.340188, -0.105617, 0.283099, 0.298440 
     * Y: 
     *    0.411647, -0.302449, -0.164777, 0.268230 
     * 
     * Input A: 
     *    -0.222225       -0.135216       0.135712        -0.483699 
     *    0.053970        0.013401        0.217297        -0.257113 
     *    -0.022603       0.452230        -0.358397       -0.362768 
     *    0.128871        0.416195        0.106969        0.304177 
     */ 
    float x[4] = {0.340188, -0.105617, 0.283099, 0.298440}; 
    float y[4] = {0.411647, -0.302449, -0.164777, 0.268230}; 
    float a[16] = {-0.222225, -0.135216, 0.135712, -0.483699, 
                   0.053970 , 0.013401, 0.217297 , -0.257113, 
                   -0.022603, 0.452230, -0.358397, -0.362768, 
                   0.128871 , 0.416195, 0.106969, 0.304177}; 
 
    cblas_sger(CblasColMajor, m, n, alpha, x, incx, y, incy, a, lda); 
    /** 
     * Output A: 
     *    -0.082188       -0.048920       -0.078658        0.220120
     *    -0.178693        0.045345        0.469633        0.387865 
     *    0.252249         0.131674       -0.405045        0.182905
     *    -0.360847       -0.347376       -0.411944        0.384228
     */

Fortran interface:

      INTEGER :: M=4 
      INTEGER :: N=4 
      INTEGER :: LDA=4 
      INTEGER :: INCX=1 
      INTEGER :: INCY=1 
      REAL(4) :: ALPHA=1.0 
      REAL(4) :: A(4, 4) 
      DATA A/-0.222225, -0.135216, 0.135712, -0.483699, 
     $       0.053970 , 0.013401, 0.217297 , -0.257113, 
     $       -0.022603, 0.452230, -0.358397, -0.362768, 
     $       0.128871 , 0.416195, 0.106969, 0.304177/ 
      REAL(4) :: X(4) 
      DATA X/0.340188, -0.105617, 0.283099, 0.298440/ 
      REAL(4) :: Y(4) 
      DATA Y/0.411647, -0.302449, -0.164777, 0.268230/ 
      EXTERNAL SGER 
      CALL SGER(M, N, ALPHA, X, INCX, Y, INCY, A, LDA) 
*     Output A: 
*     -0.082188       -0.048920       -0.078658        0.220120
*     -0.178693        0.045345        0.469633        0.387865 
*      0.252249        0.131674       -0.405045        0.182905
*     -0.360847       -0.347376       -0.411944        0.384228