SSPR2, DSPR2, SSYR2, DSYR2, SSLR2, and DSLR2 compute the rank-two update of a real symmetric matrix, using the scalar alpha, matrix A, vectors x and y, and their transposes xT and yT:
CHPR2, ZHPR2, CHER2, and ZHER2, compute the rank-two update of a complex Hermitian matrix, using the scalar alpha, matrix A, vectors x and y, and their conjugate transposes xH and yH:

The following storage modes are used:
| alpha, A, x, y | Subprogram |
| Short-precision real | SSPR2, SSYR2, and SSLR2 |
| Long-precision real | DSPR2, DSYR2, and DSLR2 |
| Short-precision complex | CHPR2 and CHER2 |
| Long-precision complex | ZHPR2 and ZHER2 |
| Fortran | CALL SSPR2 | DSPR2 | CHPR2 | ZHPR2 (uplo, n,
alpha, x, incx, y, incy,
ap)
CALL SSYR2 | DSYR2 | CHER2 | ZHER2 (uplo, n, alpha, x, incx, y, incy, a, lda) CALL SSLR2 | DSLR2 (n, alpha, x, incx, y, incy, ap) |
| C and C++ | sspr2 | dspr2 | chpr2 | zhpr2 (uplo, n, alpha,
x, incx, y, incy, ap);
ssyr2 | dsyr2 | cher2 | zher2 (uplo, n, alpha, x, incx, y, incy, a, lda); sslr2 | dslr2 (n, alpha, x, incx, y, incy, ap); |
| PL/I | CALL SSPR2 | DSPR2 | CHPR2 | ZHPR2 (uplo, n,
alpha, x, incx, y, incy,
ap);
CALL SSYR2 | DSYR2 | CHER2 | ZHER2 (uplo, n, alpha, x, incx, y, incy, a lda); CALL SSLR2 | DSLR2 (n, alpha, x, incx, y, incy, ap); |
If uplo = 'U', A is stored in upper-packed or upper storage mode.
If uplo = 'L', A is stored in lower-packed or lower storage mode.
Specified as: a single character. It must be 'U' or 'L'.
Specified as: a fullword integer, where:
For SSPR2, DSPR2, CHPR2, ZHPR2, SSYR2, DSYR2, CHER2, and ZHER2, incx < 0 or incx > 0.
For SSLR2 and DSLR2, incx can have any value.
For SSPR2, DSPR2, CHPR2, ZHPR2, SSYR2, DSYR2, CHER2, and ZHER2, incy < 0 or incy > 0.
For SSLR2 and DSLR2, incy can have any value.
For SSPR2 and DSPR2, ap is the real symmetric matrix A of order n, stored in upper- or lower-packed storage mode.
For CHPR2 and ZHPR2, ap is the complex Hermitian matrix A of order n, stored in upper- or lower-packed storage mode.
For SSLR2 and DSLR2, ap is the real symmetric matrix A of order n, stored in lower-packed storage mode.
Specified as: a one-dimensional array of (at least) length n(n+1)/2, containing numbers of the data type indicated in Table 66.
For SSYR2 and DSYR2, a is the real symmetric matrix A of order n, stored in upper or lower storage mode.
For CHER2 and ZHER2, a is the complex Hermitian matrix A of order n, stored in upper or lower storage mode.
Specified as: an lda by (at least) n array, containing numbers of the data type indicated in Table 66.
These subroutines perform the computation described in the two sections below. See references [34], [35], and [79]. If n or alpha is zero, no computation is performed.
For SSPR2, SSYR2, SSLR2, CHPR2, and CHER2, intermediate results are accumulated in long precision.
These subroutines compute the rank-two update of a real symmetric matrix:
where:
It is expressed as follows:

These subroutines compute the rank-two update of a complex Hermitian matrix:

where:
It is expressed as follows:

None
This example shows vectors x and y with positive strides and a real symmetric matrix A of order 3, stored in lower-packed storage mode. Matrix A is:
* *
| 8.0 4.0 2.0 |
| 4.0 6.0 7.0 |
| 2.0 7.0 3.0 |
* *
UPLO N ALPHA X INCX Y INCY AP
| | | | | | | |
CALL SSPR2( 'L' , 3 , 1.0 , X , 1 , Y , 2 , AP )
X = (3.0, 2.0, 1.0)
Y = (5.0, . , 3.0, . , 2.0)
AP = (8.0, 4.0, 2.0, 6.0, 7.0, 3.0)
AP = (38.0, 23.0, 13.0, 18.0, 14.0, 7.0)
This example shows vector x and y having strides of opposite signs. For x, which has negative stride, processing begins at element X(5), which is 3.0. The real symmetric matrix A of order 3 is stored in upper-packed storage mode. It uses the same input matrix A as in Example 1.
UPLO N ALPHA X INCX Y INCY AP
| | | | | | | |
CALL SSPR2( 'U' , 3 , 1.0 , X , -2 , Y , 2 , AP )
X = (1.0, . , 2.0, . , 3.0)
Y = (5.0, . , 3.0, . , 2.0)
AP = (8.0, 4.0, 6.0, 2.0, 7.0, 3.0)
AP = (38.0, 23.0, 18.0, 13.0, 14.0, 7.0)
This example shows vector x and y with positive stride and a complex Hermitian matrix A of order 3, stored in lower-packed storage mode. Matrix A is:
* *
| (1.0, 0.0) (3.0, 5.0) (2.0, -3.0) |
| (3.0, -5.0) (7.0, 0.0) (4.0, -8.0) |
| (2.0, 3.0) (4.0, 8.0) (6.0, 0.0) |
* *
UPLO N ALPHA X INCX Y INCY AP
| | | | | | | |
CALL CHPR2( 'L' , 3 , ALPHA , X , 1 , Y , 2 , AP )
ALPHA = (1.0, 0.0)
X = ((1.0, 2.0), (4.0, 0.0), (3.0, 4.0))
Y = ((1.0, 0.0), . , (2.0, -1.0), . , (2.0, 1.0))
AP = ((1.0, . ), (3.0, -5.0), (2.0, 3.0), (7.0, . ),
(4.0, 8.0), (6.0, . ))
AP = ((3.0, 0.0), (7.0, -10.0), (9.0, 4.0), (23.0, 0.0),
(14.0, 23.0), (26.0, 0.0))
This example shows vector x and y having strides of opposite signs. For x, which has negative stride, processing begins at element X(5), which is (1.0,2.0). The complex Hermitian matrix A of order 3 is stored in upper-packed storage mode. It uses the same input matrix A as in Example 3.
UPLO N ALPHA X INCX Y INCY AP
| | | | | | | |
CALL CHPR2( 'U' , 3 , ALPHA , X , -2 , Y , 2 , AP )
ALPHA = (1.0, 0.0)
X = ((3.0, 4.0), . , (4.0, 0.0), . , (1.0, 2.0))
Y = ((1.0, 0.0), . , (2.0, -1.0), . , (2.0, 1.0))
AP = ((1.0, . ), (3.0, 5.0), (7.0, . ), (2.0, -3.0),
(4.0, -8.0), (6.0, . ))
AP = ((3.0, 0.0), (7.0, 10.0), (23.0, 0.0), (9.0, -4.0),
(14.0, -23.0), (26.0, 0.0))
This example shows vectors x and y with positive strides, and a real symmetric matrix A of order 3, stored in lower storage mode. It uses the same input matrix A as in Example 1.
UPLO N ALPHA X INCX Y INCY A LDA
| | | | | | | | |
CALL SSYR2( 'L' , 3 , 1.0 , X , 1 , Y , 2 , A , 3 )
X = (3.0, 2.0, 1.0)
Y = (5.0, . , 3.0, . , 2.0)
* *
| 8.0 . . |
A = | 4.0 6.0 . |
| 2.0 7.0 3.0 |
* *
* *
| 38.0 . . |
A = | 23.0 18.0 . |
| 13.0 14.0 7.0 |
* *
This example shows vector x and y having strides of opposite signs. For x, which has negative stride, processing begins at element X(5), which is 3.0. The real symmetric matrix A of order 3 is stored in upper storage mode. It uses the same input matrix A as in Example 1.
UPLO N ALPHA X INCX Y INCY A LDA
| | | | | | | | |
CALL SSYR2( 'U' , 3 , 1.0 , X , -2 , Y , 2 , A , 4 )
X = (1.0, . , 2.0, . , 3.0)
Y = (5.0, . , 3.0, . , 2.0)
* *
| 8.0 4.0 2.0 |
A = | . 6.0 7.0 |
| . . 3.0 |
| . . . |
* *
* *
| 38.0 23.0 13.0 |
A = | . 18.0 14.0 |
| . . 7.0 |
| . . . |
* *
This example shows vector x and y with positive stride, and a complex Hermitian matrix A of order 3, stored in lower storage mode. It uses the same input matrix A as in Example 3.
UPLO N ALPHA X INCX Y INCY A LDA
| | | | | | | | |
CALL CHER2( 'L' , 3 , ALPHA , X , 1 , Y , 2 , A , 3 )
ALPHA = (1.0, 0.0)
X = ((1.0, 2.0), (4.0, 0.0), (3.0, 4.0))
Y = ((1.0, 0.0), . , (2.0, -1.0), . , (2.0, 1.0))
* *
| (1.0, . ) . . |
A = | (3.0, -5.0) (7.0, . ) . |
| (2.0, 3.0) (4.0, 8.0) (6.0, . ) |
* *
* *
| (3.0, 0.0) . . |
A = | (7.0, -10.0) (23.0, 0.0 ) . |
| (9.0, 4.0) (14.0, 23.0) (26.0, 0.0 ) |
* *
This example shows vector x and y having strides of opposite signs. For x, which has negative stride, processing begins at element X(5), which is (1.0, 2.0). The complex Hermitian matrix A of order 3 is stored in upper storage mode. It uses the same input matrix A as in Example 3.
UPLO N ALPHA X INCX Y INCY A LDA
| | | | | | | | |
CALL CHER2( 'U' , 3 , ALPHA , X , -2 , Y , 2 , A , 3 )
ALPHA = (1.0, 0.0)
X = ((3.0, 4.0), . , (4.0, 0.0), . , (1.0, 2.0))
Y = ((1.0, 0.0), . , (2.0, -1.0), . , (2.0, 1.0))
* *
| (1.0, . ) (3.0, 5.0) (2.0, -3.0) |
A = | . (7.0, . ) (4.0, -8.0) |
| . . (6.0, . ) |
* *
* *
| (3.0, 0.0) (7.0, 10.0) (9.0, -4.0) |
A = | . (23.0, 0.0) (14.0, -23.0) |
| . . (26.0, 0.0) |
* *
This example shows vectors x and y with positive strides and a real symmetric matrix A of order 3, stored in lower-packed storage mode. It uses the same input matrix A as in Example 1.
N ALPHA X INCX Y INCY AP
| | | | | | |
CALL SSLR2( 3 , 1.0 , X , 1 , Y , 2 , AP )
X = (3.0, 2.0, 1.0)
Y = (5.0, . , 3.0, . , 2.0)
AP = (8.0, 4.0, 2.0, 6.0, 7.0, 3.0)
AP = (38.0, 23.0, 13.0, 18.0, 14.0, 7.0)