@@ -5,6 +5,7 @@ module stdlib_linalg
5
5
!! ([Specification](../page/specs/stdlib_linalg.html))
6
6
use stdlib_kinds, only: sp, dp, qp, &
7
7
int8, int16, int32, int64
8
+ use stdlib_error, only: error_stop
8
9
implicit none
9
10
private
10
11
@@ -92,7 +93,7 @@ module stdlib_linalg
92
93
interface is_square
93
94
!! version: experimental
94
95
!!
95
- !! Checks if a matrix (rank-2 array) is square.
96
+ !! Checks if a matrix (rank-2 array) is square
96
97
!! ([Specification](../page/specs/stdlib_linalg.html#description_4))
97
98
#:for k1, t1 in RCI_KINDS_TYPES
98
99
module procedure is_square_${t1[0]}$${k1}$
@@ -104,7 +105,7 @@ module stdlib_linalg
104
105
interface is_diagonal
105
106
!! version: experimental
106
107
!!
107
- !! Checks if a matrix (rank-2 array) is diagonal.
108
+ !! Checks if a matrix (rank-2 array) is diagonal
108
109
!! ([Specification](../page/specs/stdlib_linalg.html#description_5))
109
110
#:for k1, t1 in RCI_KINDS_TYPES
110
111
module procedure is_diagonal_${t1[0]}$${k1}$
@@ -116,7 +117,7 @@ module stdlib_linalg
116
117
interface is_symmetric
117
118
!! version: experimental
118
119
!!
119
- !! Checks if a matrix (rank-2 array) is symmetric.
120
+ !! Checks if a matrix (rank-2 array) is symmetric
120
121
!! ([Specification](../page/specs/stdlib_linalg.html#description_6))
121
122
#:for k1, t1 in RCI_KINDS_TYPES
122
123
module procedure is_symmetric_${t1[0]}$${k1}$
@@ -128,7 +129,7 @@ module stdlib_linalg
128
129
interface is_skew_symmetric
129
130
!! version: experimental
130
131
!!
131
- !! Checks if a matrix (rank-2 array) is skew-symmetric.
132
+ !! Checks if a matrix (rank-2 array) is skew-symmetric
132
133
!! ([Specification](../page/specs/stdlib_linalg.html#description_7))
133
134
#:for k1, t1 in RCI_KINDS_TYPES
134
135
module procedure is_skew_symmetric_${t1[0]}$${k1}$
@@ -140,7 +141,7 @@ module stdlib_linalg
140
141
interface is_hermitian
141
142
!! version: experimental
142
143
!!
143
- !! Checks if a matrix (rank-2 array) is Hermitian.
144
+ !! Checks if a matrix (rank-2 array) is Hermitian
144
145
!! ([Specification](../page/specs/stdlib_linalg.html#description_8))
145
146
#:for k1, t1 in CMPLX_KINDS_TYPES
146
147
module procedure is_hermitian_${t1[0]}$${k1}$
@@ -152,7 +153,7 @@ module stdlib_linalg
152
153
interface is_triangular
153
154
!! version: experimental
154
155
!!
155
- !! Checks if a matrix (rank-2 array) is triangular.
156
+ !! Checks if a matrix (rank-2 array) is triangular
156
157
!! ([Specification](../page/specs/stdlib_linalg.html#description_9))
157
158
#:for k1, t1 in RCI_KINDS_TYPES
158
159
module procedure is_triangular_${t1[0]}$${k1}$
@@ -223,15 +224,15 @@ contains
223
224
A_shape = shape(A)
224
225
m = A_shape(1)
225
226
n = A_shape(2)
226
- do j=1, n !loop over all columns
227
+ do j = 1, n !loop over all columns
227
228
o = min(j-1,m) !index of row above diagonal (or last row)
228
- do i=1, o !loop over rows above diagonal
229
+ do i = 1, o !loop over rows above diagonal
229
230
if (.not. (A(i,j) .eq. zero)) then
230
231
res = .false.
231
232
return
232
233
end if
233
234
end do
234
- do i= o+2,m !loop over rows below diagonal
235
+ do i = o+2, m !loop over rows below diagonal
235
236
if (.not. (A(i,j) .eq. zero)) then
236
237
res = .false.
237
238
return
@@ -254,8 +255,8 @@ contains
254
255
end if
255
256
A_shape = shape(A)
256
257
n = A_shape(1) !symmetric dimension of A
257
- do j=1, n !loop over all columns
258
- do i=1, j-1 !loop over all rows above diagonal
258
+ do j = 1, n !loop over all columns
259
+ do i = 1, j-1 !loop over all rows above diagonal
259
260
if (.not. (A(i,j) .eq. A(j,i))) then
260
261
res = .false.
261
262
return
@@ -278,8 +279,8 @@ contains
278
279
end if
279
280
A_shape = shape(A)
280
281
n = A_shape(1) !symmetric dimension of A
281
- do j=1, n !loop over all columns
282
- do i=1, j !loop over all rows above diagonal (and diagonal)
282
+ do j = 1, n !loop over all columns
283
+ do i = 1, j !loop over all rows above diagonal (and diagonal)
283
284
if (.not. (A(i,j) .eq. -A(j,i))) then
284
285
res = .false.
285
286
return
@@ -302,8 +303,8 @@ contains
302
303
end if
303
304
A_shape = shape(A)
304
305
n = A_shape(1) !symmetric dimension of A
305
- do j=1, n !loop over all columns
306
- do i=1, j !loop over all rows above diagonal (and diagonal)
306
+ do j = 1, n !loop over all columns
307
+ do i = 1, j !loop over all rows above diagonal (and diagonal)
307
308
if (.not. (A(i,j) .eq. conjg(A(j,i)))) then
308
309
res = .false.
309
310
return
@@ -316,7 +317,7 @@ contains
316
317
317
318
318
319
#:for k1, t1 in RCI_KINDS_TYPES
319
- pure function is_triangular_${t1[0]}$${k1}$(A,uplo) result(res)
320
+ function is_triangular_${t1[0]}$${k1}$(A,uplo) result(res)
320
321
${t1}$, intent(in) :: A(:,:)
321
322
character, intent(in) :: uplo
322
323
logical :: res
@@ -327,9 +328,9 @@ contains
327
328
m = A_shape(1)
328
329
n = A_shape(2)
329
330
if ((uplo .eq. 'u') .or. (uplo .eq. 'U')) then !check for upper triangularity
330
- do j=1, n !loop over all columns
331
+ do j = 1, n !loop over all columns
331
332
o = min(j-1,m) !index of row above diagonal (or last row)
332
- do i= o+2,m !loop over rows below diagonal
333
+ do i = o+2, m !loop over rows below diagonal
333
334
if (.not. (A(i,j) .eq. zero)) then
334
335
res = .false.
335
336
return
@@ -347,7 +348,7 @@ contains
347
348
end do
348
349
end do
349
350
else
350
- !return error on uplo parameter needing to be in {u,U,l,L}
351
+ call error_stop("ERROR (is_triangular): second argument must be one of {'u','U','l','L'}")
351
352
end if
352
353
353
354
res = .true. !otherwise A is triangular of the requested type
@@ -356,7 +357,7 @@ contains
356
357
357
358
358
359
#:for k1, t1 in RCI_KINDS_TYPES
359
- pure function is_hessenberg_${t1[0]}$${k1}$(A,uplo) result(res)
360
+ function is_hessenberg_${t1[0]}$${k1}$(A,uplo) result(res)
360
361
${t1}$, intent(in) :: A(:,:)
361
362
character, intent(in) :: uplo
362
363
logical :: res
@@ -367,27 +368,27 @@ contains
367
368
m = A_shape(1)
368
369
n = A_shape(2)
369
370
if ((uplo .eq. 'u') .or. (uplo .eq. 'U')) then !check for upper Hessenberg
370
- do j=1, n !loop over all columns
371
+ do j = 1, n !loop over all columns
371
372
o = min(j-2,m) !index of row two above diagonal (or last row)
372
- do i= o+4,m !loop over rows two or more below main diagonal
373
+ do i = o+4, m !loop over rows two or more below main diagonal
373
374
if (.not. (A(i,j) .eq. zero)) then
374
375
res = .false.
375
376
return
376
377
end if
377
378
end do
378
379
end do
379
380
else if ((uplo .eq. 'l') .or. (uplo .eq. 'L')) then !check for lower Hessenberg
380
- do j=1, n !loop over all columns
381
+ do j = 1, n !loop over all columns
381
382
o = min(j-2,m) !index of row two above diagonal (or last row)
382
- do i=1, o !loop over rows one or more above main diagonal
383
+ do i = 1, o !loop over rows one or more above main diagonal
383
384
if (.not. (A(i,j) .eq. zero)) then
384
385
res = .false.
385
386
return
386
387
end if
387
388
end do
388
389
end do
389
390
else
390
- !return error on uplo parameter needing to be in {u,U,l,L}
391
+ call error_stop("ERROR (is_hessenberg): second argument must be one of {'u','U','l','L'}")
391
392
end if
392
393
res = .true. !otherwise A is Hessenberg of the requested type
393
394
end function is_hessenberg_${t1[0]}$${k1}$
0 commit comments