?syr2
Symmetric matrix rank 2 update, that is,
.
Alpha is a multiplication coefficient, x and y are vectors including n elements, and A is an n x n symmetric matrix.
Interface Definition
C interface:
void cblas_ssyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,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_dsyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, 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 SSYR2(UPLO, N, ALPHA, X, INCX, Y, INCY, A, LDA)
CALL DSYR2(UPLO, 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 |
Uplo |
Enumeration type CBLAS_UPLO |
Indicates whether to use the upper triangle or lower triangle of matrix A.
|
Input |
N |
Integer |
Number of elements in vector X |
Input |
alpha |
|
Multiplication coefficient |
Input |
X |
|
Matrix X. The length must be at least 1+(n-1)*abs(incX). |
Input |
incX |
Integer |
Increase step of vector X. The value cannot be 0. |
Input |
Y |
|
Matrix Y. The length must be at least 1+(n-1)*abs(incY). |
Input |
incY |
Integer |
Increase step of vector Y. The value cannot be 0. |
Input |
A |
|
Matrix A(lda, n) |
Input/Output |
lda |
Integer |
Length of the main dimension of matrix A. The value of lda must be greater than or equal to the value of max(1, n). |
Input |
Dependencies
#include "kblas.h"
Examples
C interface:
int n = 3, lda = 4;
float alpha = 1.0;
int incx = 1, incy = 1;
float x[3] = {1.0, 3.0, 2.0};
float y[3] = {2.0, 3.0, 2.0};
/**
* | 3.0 1.0 1.0 |
* A = | . 16.0 10.0 |
* | . . 1.0 |
* | . . . |
*/
float a[12] = {3.0, 0, 0, 0, 1.0, 16.0, 0, 0, 1.0, 10.0, 1.0, 0};
cblas_ssyr2(CblasColMajor,CblasUpper, n, alpha, x, incx, y, incy, a, lda);
/***
* | 7.0 10. 7.0 |
* | . 34. 22.0|
* Output A = | . . 9.0 |
* | . . . |
*/
Fortran interface:
INTEGER :: N=3, LDA=4
INTEGER :: INCX=1, INCY=1
REAL(4) :: ALPHA=1.0
REAL(4) :: X(3), Y(3), A(12)
DATA X/1.0, 3.0, 2.0/
DATA Y/2.0, 3.0, 2.0/
DATA A/3.0, 0, 0, 0, 1.0, 16.0, 0, 0, 1.0, 10.0, 1.0, 0/
EXTERNAL SSYR2
CALL SSYR2('U', N, ALPHA, X, INCX, Y, INCY, A, LDA)
* | 7.0 10. 7.0 |
* | . 34. 22.0|
* Output A = | . . 9.0 |
* | . . . |