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

?her2k

Perform a rank-2 update of a Hermitian matrix.

or .

alpha and beta are multiplication coefficients, and C is an n*n Hermitian matrix. In the first case, the matrix A and the matrix B are n*k, and in the second case, the matrix A and the matrix B are k*n.

Interface Definition

C interface:

void cblas_cher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE Trans, const BLASINT N, const BLASINT K, const void *alpha, const void *A, const BLASINT lda, const void *B, const BLASINT ldb, const float beta, void *C, const BLASINT ldc);

void cblas_zher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE Trans, const BLASINT N, const BLASINT K, const void *alpha, const void *A, const BLASINT lda, const void *B, const BLASINT ldb, const double beta, void *C, const BLASINT ldc);

Fortran interface:

CALL CHER2K(UPLO, TRANS, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)

CALL ZHER2K(UPLO, TRANS, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)

Parameters

Parameter

Type

Description

Input/Output

order

Enumeration type CBLAS_ORDER

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

Input

Uplo

Enumeration type CBLAS_UPLO

Storage mode of matrix C

Input

Trans

Enumeration type CBLAS_TRANSPOSE

The matrices A and B are conventional matrices, transpose matrices, or conjugate matrices.

  • When Trans = CblasNoTrans,

    .

  • If Trans = CblasConjTrans, then

    .

Input

N

Integer

Number of rows of matrix C.

Input

K

Integer

Indicates the columns of matrix A and matrix B when Trans = CblasNoTrans.

Indicates the rows of matrix A and matrix B when Trans = CblasConjTrans.

Input

alpha

  • For cher2k, alpha is of single-precision complex number type.
  • For zher2k, alpha is of double-precision complex number type.

Multiplication coefficient

Input

A

  • For cher2k, A is of single-precision complex number type.
  • For zher2k, A is of double-precision complex number type.

Matrix A (lda, ka).

If Trans = CblasNoTrans, ka = k; otherwise, ka = n.

Input

lda

Integer

  • If the matrix is column store and Trans = CblasNoTrans, lda must be at least max(1, n); otherwise, lda must be at least max(1, k).
  • If the matrix is column store and Trans = CblasNoTrans, lda must be at least max(1, k); otherwise, lda must be at least max(1, n).

Input

B

  • For cher2k, B is of single-precision complex number type.
  • For zher2k, B is of double-precision complex number type.

Matrix B (ldb, kb).

If Trans = CblasNoTrans, kb = k; otherwise, kb = n.

Input

ldb

Integer

  • If the matrix is column store and Trans = CblasNoTrans, ldb must be at least max(1, n); otherwise, ldb must be at least max(1, k).
  • If the matrix is column store and Trans = CblasNoTrans, ldb must be at least max(1, k). Otherwise, ldb must be at least max(1, n).

Input

beta

  • For cher2k, beta is of single-precision complex number type.
  • For zher2k, beta is of double-precision complex number type.

Multiplication coefficient

Input

C

  • For cher2k, C is of single-precision complex number type.
  • For zher2k, C is of double-precision complex number type.

Matrix C (ldc, n)

Input/Output

ldc

Integer

The value of ldc is at least max(1, n).

Input

Dependencies

#include "kblas.h"

Examples

C interface:

    int n = 2, lda = 2, k = 2, ldb =3, ldc = 3; 
    float alpha[2] = {2.0, 1.0}, beta = 2.0; 
    /** 
     *                    | 4.0 1.0   1.0 2.0 | 
     *     A(2 * 2)    =  | 3.0 2.0   4.0 1.0 | 
     * 
     *     B(2 * 2)    =  | 2.0 1.0   3.0  2.0 | 
     *                    | 11.0 2.0 -2.0  1.0 | 
     * 
     *                    |  3.0 1.0  2.0  1.0 | 
     *     C(3 * 2)    =  | -1.0 1.0  -6.0 2.0 | 
     *                    |   .           .    | 
     */ 
    float a[8] = {4.0, 1.0, 3.0, 2.0, 1.0, 2.0, 4.0, 1.0}; 
    float b[8] = {2.0, 1.0, 11.0, 2.0, 3.0, 2.0, -2.0, 1.0}; 
    float c[12] = {3.0, 1.0, -1.0, 1.0, 0, 0, 2.0, 1.0, -6.0, 2.0, 0, 0}; 
 
    cblas_cher2k(CblasColMajor, CblasUpper, CblasConjTrans, n, k, alpha, a, lda, b, ldb, beta, c, ldc); 
    /** 
     * Output C 
     *                   | (218.0, 0.0)  (123.0, -27.0) | 
     *    C(3 * 2)    =  | (-1.0 1.0)    (46.0, 0.0)    | 
     *                   |   .                 .        | 
     * 
     */

Fortran interface:

      INTEGER :: N=2, K=2 
      INTEGER :: LDA=2, LDB=3, LDC=3 
      COMPLEX(4) :: ALPHA=(2.0, 1.0) 
      REAL(4) :: BETA=2.0 
      COMPLEX(4) :: A(2, 2), B(2, 2), C(3, 2) 
      DATA A/(4.0, 1.0), (3.0, 2.0), (1.0, 2.0), (4.0, 1.0)/ 
      DATA B/(2.0, 1.0), (11.0, 2.0), (3.0, 2.0), (-2.0, 1.0)/ 
      DATA C/(3.0, 1.0), (-1.0, 1.0), (0, 0), (2.0, 1.0), (-6.0, 2.0), 
     $       (0, 0)/ 
      EXTERNAL CHER2K 
      CALL CHER2K('U', 'C', N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC) 
 
*     Output C 
*                        | (218.0, 0.0)  (123.0, -27.0) | 
*         C(3 * 2)    =  | (-1.0 1.0)    (46.0, 0.0)    | 
*                        |   .                 .        |