?laset
Initialize an m*n matrix and set the diagonal elements to beta and the non-diagonal elements to alpha.
Interface Definition
C interface:
void slaset_(const char *uplo, const int *m, const int *n, const float *alpha, const float *beta, float *a, const int *lda);
void dlaset_(const char *uplo, const int *m, const int *n, const double *alpha, const double *beta, double *a, const int *lda);
void claset_(const char *uplo, const int *m, const int *n, const float _Complex *alpha, const float _Complex *beta, float _Complex *a, const int *lda);
void zlaset_(const char *uplo, const int *m, const int *n, const double _Complex *alpha, const double _Complex *beta, double _Complex *a, const int *lda);
Fortran interface:
SLASET(UPLO, M, N, ALPHA, BETA, A, LDA);
DLASET(UPLO, M, N, ALPHA, BETA, A, LDA);
CLASET(UPLO, M, N, ALPHA, BETA, A, LDA);
ZLASET(UPLO, M, N, ALPHA, BETA, A, LDA);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
UPLO |
Character |
|
Input |
M |
Integer |
Number of rows in matrix A. |
Input |
N |
Integer |
Number of columns in matrix A. |
Input |
ALPHA |
|
Non-diagonal element value in matrix A. |
Input |
BETA |
|
Diagonal element value of matrix A. |
Input |
A |
|
Matrix A, with a dimension of (LDA, N). |
Output |
LDA |
Integer |
Leading dimension of matrix A. |
Input |
Dependency
#include "klapack.h"
Examples
C interface:
const char uplo = 'U';
const int m = 4;
const int n = 4;
const int lda = m;
const double alpha = 2.0;
const double beta = 1.0;
double *a = (double*)malloc(lda * n * sizeof(double));
for (int i = 0; i < lda * n; i++) {
a[i] = -1;
}
dlaset_(&uplo, &m, &n, &alpha, &beta, a, &lda);
/*
* Output:
* a output (stored in column-major)
*
* 1.000000 2.000000 2.000000 2.000000
* -1.000000 1.000000 2.000000 2.000000
* -1.000000 -1.000000 1.000000 2.000000
* -1.000000 -1.000000 -1.000000 1.000000
Fortran interface:
CHARACTER :: uplo = "U" PARAMETER (m = 4) PARAMETER (n = 4) PARAMETER (lda = 4) REAL(8) :: alpha REAL(8) :: beta REAL(8) :: a(lda, n) DATA alpha / 2.0 / DATA beta / 1.0 / DATA a / -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 / EXTERNAL DLASET CALL DLASET(uplo, m, n, alpha, beta, a, lda); * * Output: * a output (stored in column-major) * 1.000000 2.000000 2.000000 2.000000 * -1.000000 1.000000 2.000000 2.000000 * -1.000000 -1.000000 1.000000 2.000000 * -1.000000 -1.000000 -1.000000 1.000000