---
title: ?spr
description: "对称展开矩阵秩1更新。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0046.html
sourcePath: /source/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0046.html
indexId: bd051e6991a5121ce9a025aea0fcc442e96698dd2f66ef2347109457f297f49176
---
# ?spr

对称展开矩阵秩1更新。

即：。alpha为乘法系数，x为包含n个元素的向量，A为n*n的三角展开对称矩阵。

#### 接口定义

C interface：

void cblas_sspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const BLASINT N, const float alpha, const float *X, const BLASINT incX, float *Ap);

void cblas_dspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const BLASINT N, const double alpha, const double *X, const BLASINT incX, double *Ap);

Fortran interface：

CALL SSPR(UPLO, N, ALPHA, X, INCX, AP)

CALL DSPR(UPLO, N, ALPHA, X, INCX, AP)


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| order | 枚举类型CBLAS\_ORDER | 表示矩阵是行主序或列主序。 | 输入 |
| Uplo | 枚举类型CBLAS\_UPLO | 对称矩阵展开存储方式（上三角或下三角展开）。 如果Uplo=CblasUpper，则使用A的上三角展开。 如果Uplo=CblasLower，则使用A的下三角展开。 | 输入 |
| N | 整型数 | 向量X的元素个数。 | 输入 |
| alpha | 在sspr中是单精度浮点类型。 在dspr中是双精度浮点类型。 | 乘法系数。 | 输入 |
| X | 在sspr中是单精度浮点类型。 在dspr中是双精度浮点类型。 | 矩阵X，长度至少1+(n\-1)\*abs(incX)。 | 输入 |
| incX | 整型数 | 向量X的增长步长，不能为零。 | 输入 |
| Ap | 在sspr中是单精度浮点类型。 在dspr中是双精度浮点类型。 | 矩阵A。 | 输出 |


#### 依赖

#include "kblas.h"


#### 示例

C interface：

```
int n = 3;
float alpha = 1.0;
int incx = 1;
float x[3] = {2.0, 2.0, 1.0};
/**
*             | 3.0  1.0  2.0 |
*         A = | 1.0  6.0  3.0 |
*             | 2.0  3.0  3.0 |
*/
float a[6] = {3.0, 1.0, 2.0, 6.0, 3.0, 3.0};
cblas_sspr(CblasColMajor,CblasLower, n, alpha, x, incx, a);
/**
*  Output a = |7.0, 5.0, 4.0, 10.0, 5.0, 4.0|
*/
```

Fortran interface：

```
INTEGER :: N=3, INCX=1
REAL(4) :: ALPHA=2.0
REAL(4) :: X(3), A(6)
DATA X/2.0, 2.0, 1.0/
DATA A/3.0, 1.0, 2.0, 6.0, 3.0, 3.0/
EXTERNAL SSPR
CALL SSPR('L', N, ALPHA, X, INCX, A)
*     Output A = |7.0, 5.0, 4.0, 10.0, 5.0, 4.0|
```
