Skip to content

Commit d8fd7b2

Browse files
authored
Merge pull request #980 from zoziha/pure-1
stdlib_linalg: declare the `diag` function as pure
2 parents 6aa5177 + 29cf716 commit d8fd7b2

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

doc/specs/stdlib_linalg.md

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ to the original.
187187

188188
Stable
189189

190+
### Class
191+
192+
Pure function.
193+
190194
### Description
191195

192196
Create a diagonal array or extract the diagonal elements of an array

src/stdlib_linalg.fypp

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ module stdlib_linalg
154154
! Vector to matrix
155155
!
156156
#:for k1, t1 in RCI_KINDS_TYPES
157-
module function diag_${t1[0]}$${k1}$(v) result(res)
157+
module pure function diag_${t1[0]}$${k1}$(v) result(res)
158158
${t1}$, intent(in) :: v(:)
159159
${t1}$ :: res(size(v),size(v))
160160
end function diag_${t1[0]}$${k1}$
161161
#:endfor
162162
#:for k1, t1 in RCI_KINDS_TYPES
163-
module function diag_${t1[0]}$${k1}$_k(v,k) result(res)
163+
module pure function diag_${t1[0]}$${k1}$_k(v,k) result(res)
164164
${t1}$, intent(in) :: v(:)
165165
integer, intent(in) :: k
166166
${t1}$ :: res(size(v)+abs(k),size(v)+abs(k))
@@ -171,13 +171,13 @@ module stdlib_linalg
171171
! Matrix to vector
172172
!
173173
#:for k1, t1 in RCI_KINDS_TYPES
174-
module function diag_${t1[0]}$${k1}$_mat(A) result(res)
174+
module pure function diag_${t1[0]}$${k1}$_mat(A) result(res)
175175
${t1}$, intent(in) :: A(:,:)
176176
${t1}$ :: res(minval(shape(A)))
177177
end function diag_${t1[0]}$${k1}$_mat
178178
#:endfor
179179
#:for k1, t1 in RCI_KINDS_TYPES
180-
module function diag_${t1[0]}$${k1}$_mat_k(A,k) result(res)
180+
module pure function diag_${t1[0]}$${k1}$_mat_k(A,k) result(res)
181181
${t1}$, intent(in) :: A(:,:)
182182
integer, intent(in) :: k
183183
${t1}$ :: res(minval(shape(A))-abs(k))

src/stdlib_linalg_diag.fypp

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ submodule (stdlib_linalg) stdlib_linalg_diag
77
contains
88

99
#:for k1, t1 in RCI_KINDS_TYPES
10-
module function diag_${t1[0]}$${k1}$(v) result(res)
10+
module pure function diag_${t1[0]}$${k1}$(v) result(res)
1111
${t1}$, intent(in) :: v(:)
1212
${t1}$ :: res(size(v),size(v))
1313
integer :: i
@@ -20,7 +20,7 @@ contains
2020

2121

2222
#:for k1, t1 in RCI_KINDS_TYPES
23-
module function diag_${t1[0]}$${k1}$_k(v,k) result(res)
23+
module pure function diag_${t1[0]}$${k1}$_k(v,k) result(res)
2424
${t1}$, intent(in) :: v(:)
2525
integer, intent(in) :: k
2626
${t1}$ :: res(size(v)+abs(k),size(v)+abs(k))
@@ -44,7 +44,7 @@ contains
4444
#:endfor
4545

4646
#:for k1, t1 in RCI_KINDS_TYPES
47-
module function diag_${t1[0]}$${k1}$_mat(A) result(res)
47+
module pure function diag_${t1[0]}$${k1}$_mat(A) result(res)
4848
${t1}$, intent(in) :: A(:,:)
4949
${t1}$ :: res(minval(shape(A)))
5050
integer :: i
@@ -55,7 +55,7 @@ contains
5555
#:endfor
5656

5757
#:for k1, t1 in RCI_KINDS_TYPES
58-
module function diag_${t1[0]}$${k1}$_mat_k(A,k) result(res)
58+
module pure function diag_${t1[0]}$${k1}$_mat_k(A,k) result(res)
5959
${t1}$, intent(in) :: A(:,:)
6060
integer, intent(in) :: k
6161
${t1}$ :: res(minval(shape(A))-abs(k))

0 commit comments

Comments
 (0)