LAPACK
3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
slaset.f
Go to the documentation of this file.
1
*> \brief \b SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
2
*
3
* =========== DOCUMENTATION ===========
4
*
5
* Online html documentation available at
6
* http://www.netlib.org/lapack/explore-html/
7
*
8
*> Download SLASET + dependencies
9
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slaset.f">
10
*> [TGZ]</a>
11
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slaset.f">
12
*> [ZIP]</a>
13
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slaset.f">
14
*> [TXT]</a>
15
*
16
* Definition:
17
* ===========
18
*
19
* SUBROUTINE SLASET( UPLO, M, N, ALPHA, BETA, A, LDA )
20
*
21
* .. Scalar Arguments ..
22
* CHARACTER UPLO
23
* INTEGER LDA, M, N
24
* REAL ALPHA, BETA
25
* ..
26
* .. Array Arguments ..
27
* REAL A( LDA, * )
28
* ..
29
*
30
*
31
*> \par Purpose:
32
* =============
33
*>
34
*> \verbatim
35
*>
36
*> SLASET initializes an m-by-n matrix A to BETA on the diagonal and
37
*> ALPHA on the offdiagonals.
38
*> \endverbatim
39
*
40
* Arguments:
41
* ==========
42
*
43
*> \param[in] UPLO
44
*> \verbatim
45
*> UPLO is CHARACTER*1
46
*> Specifies the part of the matrix A to be set.
47
*> = 'U': Upper triangular part is set; the strictly lower
48
*> triangular part of A is not changed.
49
*> = 'L': Lower triangular part is set; the strictly upper
50
*> triangular part of A is not changed.
51
*> Otherwise: All of the matrix A is set.
52
*> \endverbatim
53
*>
54
*> \param[in] M
55
*> \verbatim
56
*> M is INTEGER
57
*> The number of rows of the matrix A. M >= 0.
58
*> \endverbatim
59
*>
60
*> \param[in] N
61
*> \verbatim
62
*> N is INTEGER
63
*> The number of columns of the matrix A. N >= 0.
64
*> \endverbatim
65
*>
66
*> \param[in] ALPHA
67
*> \verbatim
68
*> ALPHA is REAL
69
*> The constant to which the offdiagonal elements are to be set.
70
*> \endverbatim
71
*>
72
*> \param[in] BETA
73
*> \verbatim
74
*> BETA is REAL
75
*> The constant to which the diagonal elements are to be set.
76
*> \endverbatim
77
*>
78
*> \param[out] A
79
*> \verbatim
80
*> A is REAL array, dimension (LDA,N)
81
*> On exit, the leading m-by-n submatrix of A is set as follows:
82
*>
83
*> if UPLO = 'U', A(i,j) = ALPHA, 1<=i<=j-1, 1<=j<=n,
84
*> if UPLO = 'L', A(i,j) = ALPHA, j+1<=i<=m, 1<=j<=n,
85
*> otherwise, A(i,j) = ALPHA, 1<=i<=m, 1<=j<=n, i.ne.j,
86
*>
87
*> and, for all UPLO, A(i,i) = BETA, 1<=i<=min(m,n).
88
*> \endverbatim
89
*>
90
*> \param[in] LDA
91
*> \verbatim
92
*> LDA is INTEGER
93
*> The leading dimension of the array A. LDA >= max(1,M).
94
*> \endverbatim
95
*
96
* Authors:
97
* ========
98
*
99
*> \author Univ. of Tennessee
100
*> \author Univ. of California Berkeley
101
*> \author Univ. of Colorado Denver
102
*> \author NAG Ltd.
103
*
104
*> \ingroup laset
105
*
106
* =====================================================================
107
SUBROUTINE
slaset
( UPLO, M, N, ALPHA, BETA, A, LDA )
108
*
109
* -- LAPACK auxiliary routine --
110
* -- LAPACK is a software package provided by Univ. of Tennessee, --
111
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
112
*
113
* .. Scalar Arguments ..
114
CHARACTER
UPLO
115
INTEGER
LDA, M, N
116
REAL
ALPHA, BETA
117
* ..
118
* .. Array Arguments ..
119
REAL
A( LDA, * )
120
* ..
121
*
122
* =====================================================================
123
*
124
* .. Local Scalars ..
125
INTEGER
I, J
126
* ..
127
* .. External Functions ..
128
LOGICAL
LSAME
129
EXTERNAL
lsame
130
* ..
131
* .. Intrinsic Functions ..
132
INTRINSIC
min
133
* ..
134
* .. Executable Statements ..
135
*
136
IF
( lsame( uplo,
'U'
) )
THEN
137
*
138
* Set the strictly upper triangular or trapezoidal part of the
139
* array to ALPHA.
140
*
141
DO
20 j = 2, n
142
DO
10 i = 1, min( j-1, m )
143
a( i, j ) = alpha
144
10
CONTINUE
145
20
CONTINUE
146
*
147
ELSE
IF
( lsame( uplo,
'L'
) )
THEN
148
*
149
* Set the strictly lower triangular or trapezoidal part of the
150
* array to ALPHA.
151
*
152
DO
40 j = 1, min( m, n )
153
DO
30 i = j + 1, m
154
a( i, j ) = alpha
155
30
CONTINUE
156
40
CONTINUE
157
*
158
ELSE
159
*
160
* Set the leading m-by-n submatrix to ALPHA.
161
*
162
DO
60 j = 1, n
163
DO
50 i = 1, m
164
a( i, j ) = alpha
165
50
CONTINUE
166
60
CONTINUE
167
END IF
168
*
169
* Set the first min(M,N) diagonal elements to BETA.
170
*
171
DO
70 i = 1, min( m, n )
172
a( i, i ) = beta
173
70
CONTINUE
174
*
175
RETURN
176
*
177
* End of SLASET
178
*
179
END
slaset
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition
slaset.f:108
SRC
slaset.f
Generated on Mon Jan 20 2025 17:18:12 for LAPACK by
1.11.0