Skip to content

Commit 7054d66

Browse files
committed
modify: example and src
1 parent 867cf4e commit 7054d66

5 files changed

Lines changed: 53 additions & 47 deletions

File tree

example/specialmatrices/example_sym_tridiagonal_dp_type.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
program example_sym_tridiagonal_matrix
22
use stdlib_linalg_constants, only: dp
3-
use stdlib_specialmatrices
3+
use stdlib_specialmatrices, only: sym_tridiagonal_dp_type, sym_tridiagonal
44
implicit none
55

66
integer, parameter :: n = 5
@@ -11,7 +11,7 @@ program example_sym_tridiagonal_matrix
1111
call random_number(du)
1212
call random_number(dv)
1313

14-
! Create the corresponding Tridiagonal matrix.
14+
! Create the corresponding symmetric tridiagonal matrix.
1515
A = sym_tridiagonal(du, dv)
1616

1717
end program example_sym_tridiagonal_matrix

example/specialmatrices/example_tridiagonal_dp_type.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
program example_tridiagonal_matrix
22
use stdlib_linalg_constants, only: dp
3-
use stdlib_specialmatrices
3+
use stdlib_specialmatrices, only: tridiagonal_dp_type, tridiagonal
44
implicit none
55

66
integer, parameter :: n = 5

src/specialmatrices/stdlib_specialmatrices.fypp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module stdlib_specialmatrices
2727
!--------------------------------------
2828

2929
!--> Tridiagonal matrices
30-
#:for k1, t1, s1 in (KINDS_TYPES)
30+
#:for k1, t1, s1 in KINDS_TYPES
3131
type, public :: tridiagonal_${s1}$_type
3232
!! Base type to define a `tridiagonal` matrix.
3333
private
@@ -37,7 +37,7 @@ module stdlib_specialmatrices
3737
#:endfor
3838

3939
!--> Symmetric tridiagonal matrices
40-
#:for k1, t1, s1 in (KINDS_TYPES)
40+
#:for k1, t1, s1 in KINDS_TYPES
4141
type, public :: sym_tridiagonal_${s1}$_type
4242
!! Base type to define a `symmetric tridiagonal` matrix.
4343
private
@@ -78,7 +78,9 @@ module stdlib_specialmatrices
7878
!! type(tridiagonal_rdp_type) :: A
7979
!! integer :: i
8080
!!
81-
!! dl = [(i, i=1, n-1)]; dv = [(2*i, i=1, n)]; du = [(3*i, i=1, n)]
81+
!! dl = [(i, i=1, n-1)]
82+
!! dv = [(2*i, i=1, n)]
83+
!! du = [(3*i, i=1, n)]
8284
!! A = Tridiagonal(dl, dv, du)
8385
!! ```
8486
!!
@@ -91,7 +93,7 @@ module stdlib_specialmatrices
9193
!!
9294
!! A = Tridiagonal(a, b, c, n)
9395
!! ```
94-
#:for k1, t1, s1 in (KINDS_TYPES)
96+
#:for k1, t1, s1 in KINDS_TYPES
9597
pure module function initialize_tridiagonal_pure_${s1}$(dl, dv, du) result(A)
9698
!! Construct a `tridiagonal` matrix from the rank-1 arrays
9799
!! `dl`, `dv` and `du`.
@@ -102,7 +104,7 @@ module stdlib_specialmatrices
102104
end function
103105

104106
pure module function initialize_constant_tridiagonal_pure_${s1}$(dl, dv, du, n) result(A)
105-
!! Construct a `tridiagonal` matrix with constant elements.
107+
!! Construct a `tridiagonal` matrix with scalar elements.
106108
${t1}$, intent(in) :: dl, dv, du
107109
!! Tridiagonal matrix elements.
108110
integer(ilp), intent(in) :: n
@@ -123,7 +125,7 @@ module stdlib_specialmatrices
123125
end function
124126

125127
module function initialize_constant_tridiagonal_impure_${s1}$(dl, dv, du, n, err) result(A)
126-
!! Construct a `tridiagonal` matrix with constant elements.
128+
!! Construct a `tridiagonal` matrix with scalar elements.
127129
${t1}$, intent(in) :: dl, dv, du
128130
!! Tridiagonal matrix elements.
129131
integer(ilp), intent(in) :: n
@@ -163,7 +165,8 @@ module stdlib_specialmatrices
163165
!! type(sym_tridiagonal_rdp_type) :: A
164166
!! integer :: i
165167
!!
166-
!! du = [(i, i=1, n-1)]; dv = [(2*i, i=1, n)]
168+
!! du = [(i, i=1, n-1)]
169+
!! dv = [(2*i, i=1, n)]
167170
!! A = sym_tridiagonal(du, dv)
168171
!! ```
169172
!!
@@ -176,7 +179,7 @@ module stdlib_specialmatrices
176179
!!
177180
!! A = sym_tridiagonal(a, b, n)
178181
!! ```
179-
#:for k1, t1, s1 in (KINDS_TYPES)
182+
#:for k1, t1, s1 in KINDS_TYPES
180183
pure module function initialize_sym_tridiagonal_pure_${s1}$(du, dv) result(A)
181184
!! Construct a `symmetric tridiagonal matrix` from rank-1 arrays `du` and `dv`.
182185
${t1}$, intent(in) :: du(:), dv(:)
@@ -186,7 +189,7 @@ module stdlib_specialmatrices
186189
end function
187190

188191
pure module function initialize_constant_sym_tridiagonal_pure_${s1}$(du, dv, n) result(A)
189-
!! Construct a `symmetric tridiagonal matrix` with constant elements.
192+
!! Construct a `symmetric tridiagonal matrix` with scalar elements.
190193
${t1}$, intent(in) :: du, dv
191194
!! Symmetric tridiagonal matrix elements.
192195
integer(ilp), intent(in) :: n
@@ -206,7 +209,7 @@ module stdlib_specialmatrices
206209
end function
207210

208211
module function initialize_constant_sym_tridiagonal_impure_${s1}$(du, dv, n, err) result(A)
209-
!! Construct a `symmetric tridiagonal matrix` with constant elements.
212+
!! Construct a `symmetric tridiagonal matrix` with scalar elements.
210213
${t1}$, intent(in) :: du, dv
211214
!! Symmetric tridiagonal matrix elements.
212215
integer(ilp), intent(in) :: n
@@ -220,7 +223,7 @@ module stdlib_specialmatrices
220223
end interface
221224

222225
interface build_tridiagonal
223-
#:for k1, t1, s1 in (KINDS_TYPES)
226+
#:for k1, t1, s1 in KINDS_TYPES
224227
pure module subroutine build_tridiagonal_from_arrays_${s1}$(dl, dv, du, A, err)
225228
${t1}$, intent(in) :: dl(:), dv(:), du(:)
226229
type(tridiagonal_${s1}$_type), intent(out) :: A
@@ -244,7 +247,7 @@ module stdlib_specialmatrices
244247
end interface
245248

246249
interface build_sym_tridiagonal
247-
#:for k1, t1, s1 in (KINDS_TYPES)
250+
#:for k1, t1, s1 in KINDS_TYPES
248251
pure module subroutine build_sym_tridiagonal_from_arrays_${s1}$(du, dv, A, err)
249252
${t1}$, intent(in) :: du(:), dv(:)
250253
type(sym_tridiagonal_${s1}$_type), intent(out) :: A
@@ -280,7 +283,7 @@ module stdlib_specialmatrices
280283
!! $$ y = \alpha \mathrm{op}(A) x + \beta y$$
281284
!!
282285
!! for the different matrix types defined by `stdlib_specialmatrices`.
283-
#:for k1, t1, s1 in (KINDS_TYPES)
286+
#:for k1, t1, s1 in KINDS_TYPES
284287
#:for rank in RANKS
285288
module subroutine spmv_tridiag_${rank}$d_${s1}$(A, x, y, alpha, beta, op)
286289
type(tridiagonal_${s1}$_type), intent(in) :: A
@@ -293,7 +296,7 @@ module stdlib_specialmatrices
293296
#:endfor
294297
#:endfor
295298

296-
#:for k1, t1, s1 in (KINDS_TYPES)
299+
#:for k1, t1, s1 in KINDS_TYPES
297300
#:for rank in RANKS
298301
module subroutine spmv_sym_tridiag_${rank}$d_${s1}$(A, x, y, alpha, beta, op)
299302
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
@@ -317,7 +320,7 @@ module stdlib_specialmatrices
317320
!! This interface provides methods to convert a matrix of one of the
318321
!! types defined by `stdlib_specialmatrices` to a standard rank-2 array.
319322
!! ([Specifications](../page/specs/stdlib_specialmatrices.html#dense))
320-
#:for k1, t1, s1 in (KINDS_TYPES)
323+
#:for k1, t1, s1 in KINDS_TYPES
321324
pure module function tridiagonal_to_dense_${s1}$(A) result(B)
322325
!! Convert a `tridiagonal` matrix to its dense representation.
323326
type(tridiagonal_${s1}$_type), intent(in) :: A
@@ -327,7 +330,7 @@ module stdlib_specialmatrices
327330
end function
328331
#:endfor
329332

330-
#:for k1, t1, s1 in (KINDS_TYPES)
333+
#:for k1, t1, s1 in KINDS_TYPES
331334
pure module function sym_tridiagonal_to_dense_${s1}$(A) result(B)
332335
!! Convert a `symmetric tridiagonal` matrix to its dense representation.
333336
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
@@ -342,15 +345,15 @@ module stdlib_specialmatrices
342345
!! This interface provides methods to compute the transpose operation for
343346
!! the different matrix types defined by `stdlib_specialmatrices`.
344347
!! [Specifications](../page/specs/stdlib_specialmatrices.html#transpose)
345-
#:for k1, t1, s1 in (KINDS_TYPES)
348+
#:for k1, t1, s1 in KINDS_TYPES
346349
pure module function transpose_tridiagonal_${s1}$(A) result(B)
347350
type(tridiagonal_${s1}$_type), intent(in) :: A
348351
!! Input matrix.
349352
type(tridiagonal_${s1}$_type) :: B
350353
end function
351354
#:endfor
352355

353-
#:for k1, t1, s1 in (KINDS_TYPES)
356+
#:for k1, t1, s1 in KINDS_TYPES
354357
pure module function transpose_sym_tridiagonal_${s1}$(A) result(B)
355358
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
356359
!! Input matrix.
@@ -364,15 +367,15 @@ module stdlib_specialmatrices
364367
!! the different matrix types defined by `stdlib_specialmatrices`. For
365368
!! real-valued matrices, this is equivalent to the standard `transpose`.
366369
!! [Specifications](../page/specs/stdlib_specialmatrices.html#hermitian)
367-
#:for k1, t1, s1 in (KINDS_TYPES)
370+
#:for k1, t1, s1 in KINDS_TYPES
368371
pure module function hermitian_tridiagonal_${s1}$(A) result(B)
369372
type(tridiagonal_${s1}$_type), intent(in) :: A
370373
!! Input matrix.
371374
type(tridiagonal_${s1}$_type) :: B
372375
end function
373376
#:endfor
374377

375-
#:for k1, t1, s1 in (KINDS_TYPES)
378+
#:for k1, t1, s1 in KINDS_TYPES
376379
pure module function hermitian_sym_tridiagonal_${s1}$(A) result(B)
377380
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
378381
!! Input matrix.
@@ -391,7 +394,7 @@ module stdlib_specialmatrices
391394
!! Overload the `*` for scalar-matrix multiplications for the different matrix
392395
!! types provided by `stdlib_specialmatrices`.
393396
!! [Specifications](../page/specs/stdlib_specialmatrices.html#operators)
394-
#:for k1, t1, s1 in (KINDS_TYPES)
397+
#:for k1, t1, s1 in KINDS_TYPES
395398
pure module function scalar_multiplication_tridiagonal_${s1}$(alpha, A) result(B)
396399
${t1}$, intent(in) :: alpha
397400
type(tridiagonal_${s1}$_type), intent(in) :: A
@@ -404,7 +407,7 @@ module stdlib_specialmatrices
404407
end function
405408
#:endfor
406409

407-
#:for k1, t1, s1 in (KINDS_TYPES)
410+
#:for k1, t1, s1 in KINDS_TYPES
408411
pure module function scalar_multiplication_sym_tridiagonal_${s1}$(alpha, A) result(B)
409412
${t1}$, intent(in) :: alpha
410413
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
@@ -422,15 +425,15 @@ module stdlib_specialmatrices
422425
!! Overload the `+` operator for matrix-matrix addition. The two matrices need to
423426
!! be of the same type and kind.
424427
!! [Specifications](../page/specs/stdlib_specialmatrices.html#operators)
425-
#:for k1, t1, s1 in (KINDS_TYPES)
428+
#:for k1, t1, s1 in KINDS_TYPES
426429
pure module function matrix_add_tridiagonal_${s1}$(A, B) result(C)
427430
type(tridiagonal_${s1}$_type), intent(in) :: A
428431
type(tridiagonal_${s1}$_type), intent(in) :: B
429432
type(tridiagonal_${s1}$_type) :: C
430433
end function
431434
#:endfor
432435

433-
#:for k1, t1, s1 in (KINDS_TYPES)
436+
#:for k1, t1, s1 in KINDS_TYPES
434437
pure module function matrix_add_sym_tridiagonal_${s1}$(A, B) result(C)
435438
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
436439
type(sym_tridiagonal_${s1}$_type), intent(in) :: B
@@ -443,15 +446,15 @@ module stdlib_specialmatrices
443446
!! Overload the `-` operator for matrix-matrix subtraction. The two matrices need to
444447
!! be of the same type and kind.
445448
!! [Specifications](../page/specs/stdlib_specialmatrices.html#operators)
446-
#:for k1, t1, s1 in (KINDS_TYPES)
449+
#:for k1, t1, s1 in KINDS_TYPES
447450
pure module function matrix_sub_tridiagonal_${s1}$(A, B) result(C)
448451
type(tridiagonal_${s1}$_type), intent(in) :: A
449452
type(tridiagonal_${s1}$_type), intent(in) :: B
450453
type(tridiagonal_${s1}$_type) :: C
451454
end function
452455
#:endfor
453456

454-
#:for k1, t1, s1 in (KINDS_TYPES)
457+
#:for k1, t1, s1 in KINDS_TYPES
455458
pure module function matrix_sub_sym_tridiagonal_${s1}$(A, B) result(C)
456459
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
457460
type(sym_tridiagonal_${s1}$_type), intent(in) :: B

src/specialmatrices/stdlib_specialmatrices_sym_tridiagonal.fypp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
1515
!----- -----
1616
!--------------------------------
1717

18-
#:for k1, t1, s1 in (KINDS_TYPES)
18+
#:for k1, t1, s1 in KINDS_TYPES
1919
pure module function initialize_sym_tridiagonal_pure_${s1}$(du, dv) result(A)
2020
!! Construct a `symmetric tridiagonal` matrix from the rank-1 arrays `du` and `dv`.
2121
${t1}$, intent(in) :: du(:), dv(:)
@@ -65,7 +65,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
6565
end function
6666
#:endfor
6767

68-
#:for k1, t1, s1 in (KINDS_TYPES)
68+
#:for k1, t1, s1 in KINDS_TYPES
6969
pure module subroutine build_sym_tridiagonal_from_arrays_${s1}$(du, dv, A, err)
7070
${t1}$, intent(in) :: du(:), dv(:)
7171
type(sym_tridiagonal_${s1}$_type), intent(out) :: A
@@ -90,7 +90,8 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
9090
! Description of the matrix.
9191
A%n = n
9292
! Matrix elements.
93-
A%du = du ; A%dv = dv
93+
A%du = du
94+
A%dv = dv
9495
endif
9596
end subroutine
9697

@@ -125,7 +126,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
125126
!-----------------------------------------
126127

127128
!! spmv_sym_tridiag
128-
#:for k1, t1, s1 in (KINDS_TYPES)
129+
#:for k1, t1, s1 in KINDS_TYPES
129130
#:for rank in RANKS
130131
module subroutine spmv_sym_tridiag_${rank}$d_${s1}$(A, x, y, alpha, beta, op)
131132
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
@@ -189,7 +190,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
189190
!----- UTILITY FUNCTIONS -----
190191
!----- -----
191192
!-------------------------------------
192-
#:for k1, t1, s1 in (KINDS_TYPES)
193+
#:for k1, t1, s1 in KINDS_TYPES
193194
pure module function sym_tridiagonal_to_dense_${s1}$(A) result(B)
194195
!! Convert a `symmetric tridiagonal` matrix to its dense representation.
195196
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
@@ -217,7 +218,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
217218
end function
218219
#:endfor
219220

220-
#:for k1, t1, s1 in (KINDS_TYPES)
221+
#:for k1, t1, s1 in KINDS_TYPES
221222
pure module function transpose_sym_tridiagonal_${s1}$(A) result(B)
222223
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
223224
!! Input matrix.
@@ -226,7 +227,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
226227
end function
227228
#:endfor
228229

229-
#:for k1, t1, s1 in (KINDS_TYPES)
230+
#:for k1, t1, s1 in KINDS_TYPES
230231
pure module function hermitian_sym_tridiagonal_${s1}$(A) result(B)
231232
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
232233
!! Input matrix.
@@ -239,7 +240,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
239240
end function
240241
#:endfor
241242

242-
#:for k1, t1, s1 in (KINDS_TYPES)
243+
#:for k1, t1, s1 in KINDS_TYPES
243244
pure module function scalar_multiplication_sym_tridiagonal_${s1}$(alpha, A) result(B)
244245
${t1}$, intent(in) :: alpha
245246
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
@@ -257,7 +258,7 @@ submodule (stdlib_specialmatrices) sym_tridiagonal_matrices
257258
end function
258259
#:endfor
259260

260-
#:for k1, t1, s1 in (KINDS_TYPES)
261+
#:for k1, t1, s1 in KINDS_TYPES
261262
pure module function matrix_add_sym_tridiagonal_${s1}$(A, B) result(C)
262263
type(sym_tridiagonal_${s1}$_type), intent(in) :: A
263264
type(sym_tridiagonal_${s1}$_type), intent(in) :: B

0 commit comments

Comments
 (0)