1
1
#:include "common.fypp"
2
+ #:set I_KINDS_TYPES = list(zip(INT_KINDS, INT_TYPES, INT_KINDS))
2
3
#:set R_KINDS_TYPES = list(zip(REAL_KINDS, REAL_TYPES, REAL_SUFFIX))
3
4
#:set C_KINDS_TYPES = list(zip(CMPLX_KINDS, CMPLX_TYPES, CMPLX_SUFFIX))
4
- #:set RC_KINDS_TYPES = R_KINDS_TYPES + C_KINDS_TYPES
5
5
#:set RANKS = range(2, MAXRANK + 1)
6
6
7
7
module stdlib_intrinsics
@@ -25,27 +25,27 @@ module stdlib_intrinsics
25
25
!! The `N-D` interfaces calls upon the `(N-1)-D` implementation.
26
26
!! Supported data types include `real` and `complex`.
27
27
!!
28
- #:for rk, rt, rs in RC_KINDS_TYPES
29
- pure module function stdlib_sum_1d_${rs }$(a) result(s)
30
- ${rt }$, intent(in) :: a(:)
31
- ${rt }$ :: s
28
+ #:for k, t, s in I_KINDS_TYPES + R_KINDS_TYPES + C_KINDS_TYPES
29
+ pure module function stdlib_sum_1d_${s }$(a) result(s)
30
+ ${t }$, intent(in) :: a(:)
31
+ ${t }$ :: s
32
32
end function
33
- pure module function stdlib_sum_1d_${rs }$_mask(a,mask) result(s)
34
- ${rt }$, intent(in) :: a(:)
33
+ pure module function stdlib_sum_1d_${s }$_mask(a,mask) result(s)
34
+ ${t }$, intent(in) :: a(:)
35
35
logical, intent(in) :: mask(:)
36
- ${rt }$ :: s
36
+ ${t }$ :: s
37
37
end function
38
38
#:for rank in RANKS
39
- pure module function stdlib_sum_${rank}$d_${rs }$( x, mask ) result( s )
40
- ${rt }$, intent(in) :: x${ranksuffix(rank)}$
39
+ pure module function stdlib_sum_${rank}$d_${s }$( x, mask ) result( s )
40
+ ${t }$, intent(in) :: x${ranksuffix(rank)}$
41
41
logical, intent(in), optional :: mask${ranksuffix(rank)}$
42
- ${rt }$ :: s
42
+ ${t }$ :: s
43
43
end function
44
- pure module function stdlib_sum_${rank}$d_dim_${rs }$( x , dim, mask ) result( s )
45
- ${rt }$, intent(in) :: x${ranksuffix(rank)}$
44
+ pure module function stdlib_sum_${rank}$d_dim_${s }$( x , dim, mask ) result( s )
45
+ ${t }$, intent(in) :: x${ranksuffix(rank)}$
46
46
integer, intent(in):: dim
47
47
logical, intent(in), optional :: mask${ranksuffix(rank)}$
48
- ${rt }$ :: s${reduced_shape('x', rank, 'dim')}$
48
+ ${t }$ :: s${reduced_shape('x', rank, 'dim')}$
49
49
end function
50
50
#:endfor
51
51
#:endfor
@@ -66,27 +66,27 @@ module stdlib_intrinsics
66
66
!! The `N-D` interfaces calls upon the `(N-1)-D` implementation.
67
67
!! Supported data types include `real` and `complex`.
68
68
!!
69
- #:for rk, rt, rs in RC_KINDS_TYPES
70
- pure module function stdlib_sum_kahan_1d_${rs }$(a) result(s)
71
- ${rt }$, intent(in) :: a(:)
72
- ${rt }$ :: s
69
+ #:for k, t, s in R_KINDS_TYPES + C_KINDS_TYPES
70
+ pure module function stdlib_sum_kahan_1d_${s }$(a) result(s)
71
+ ${t }$, intent(in) :: a(:)
72
+ ${t }$ :: s
73
73
end function
74
- pure module function stdlib_sum_kahan_1d_${rs }$_mask(a,mask) result(s)
75
- ${rt }$, intent(in) :: a(:)
74
+ pure module function stdlib_sum_kahan_1d_${s }$_mask(a,mask) result(s)
75
+ ${t }$, intent(in) :: a(:)
76
76
logical, intent(in) :: mask(:)
77
- ${rt }$ :: s
77
+ ${t }$ :: s
78
78
end function
79
79
#:for rank in RANKS
80
- pure module function stdlib_sum_kahan_${rank}$d_${rs }$( x, mask ) result( s )
81
- ${rt }$, intent(in) :: x${ranksuffix(rank)}$
80
+ pure module function stdlib_sum_kahan_${rank}$d_${s }$( x, mask ) result( s )
81
+ ${t }$, intent(in) :: x${ranksuffix(rank)}$
82
82
logical, intent(in), optional :: mask${ranksuffix(rank)}$
83
- ${rt }$ :: s
83
+ ${t }$ :: s
84
84
end function
85
- pure module function stdlib_sum_kahan_${rank}$d_dim_${rs }$( x , dim, mask ) result( s )
86
- ${rt }$, intent(in) :: x${ranksuffix(rank)}$
85
+ pure module function stdlib_sum_kahan_${rank}$d_dim_${s }$( x , dim, mask ) result( s )
86
+ ${t }$, intent(in) :: x${ranksuffix(rank)}$
87
87
integer, intent(in):: dim
88
88
logical, intent(in), optional :: mask${ranksuffix(rank)}$
89
- ${rt }$ :: s${reduced_shape('x', rank, 'dim')}$
89
+ ${t }$ :: s${reduced_shape('x', rank, 'dim')}$
90
90
end function
91
91
#:endfor
92
92
#:endfor
@@ -106,11 +106,11 @@ module stdlib_intrinsics
106
106
!! The 1-D base implementation follows a chunked approach for optimizing performance and increasing accuracy.
107
107
!! Supported data types include `real` and `complex`.
108
108
!!
109
- #:for rk, rt, rs in RC_KINDS_TYPES
110
- pure module function stdlib_dot_product_${rs }$(a,b) result(p)
111
- ${rt }$, intent(in) :: a(:)
112
- ${rt }$, intent(in) :: b(:)
113
- ${rt }$ :: p
109
+ #:for k, t, s in I_KINDS_TYPES + R_KINDS_TYPES + C_KINDS_TYPES
110
+ pure module function stdlib_dot_product_${s }$(a,b) result(p)
111
+ ${t }$, intent(in) :: a(:)
112
+ ${t }$, intent(in) :: b(:)
113
+ ${t }$ :: p
114
114
end function
115
115
#:endfor
116
116
end interface
@@ -129,43 +129,43 @@ module stdlib_intrinsics
129
129
!! The implementation follows a chunked approach combined with a kahan kernel for optimizing performance and increasing accuracy.
130
130
!! Supported data types include `real` and `complex`.
131
131
!!
132
- #:for rk, rt, rs in RC_KINDS_TYPES
133
- pure module function stdlib_dot_product_kahan_${rs }$(a,b) result(p)
134
- ${rt }$, intent(in) :: a(:)
135
- ${rt }$, intent(in) :: b(:)
136
- ${rt }$ :: p
132
+ #:for k, t, s in R_KINDS_TYPES + C_KINDS_TYPES
133
+ pure module function stdlib_dot_product_kahan_${s }$(a,b) result(p)
134
+ ${t }$, intent(in) :: a(:)
135
+ ${t }$, intent(in) :: b(:)
136
+ ${t }$ :: p
137
137
end function
138
138
#:endfor
139
139
end interface
140
140
public :: stdlib_dot_product_kahan
141
141
142
142
interface kahan_kernel
143
- #:for rk, rt, rs in RC_KINDS_TYPES
144
- module procedure :: kahan_kernel_${rs }$
145
- module procedure :: kahan_kernel_m_${rs }$
143
+ #:for k, t, s in R_KINDS_TYPES + C_KINDS_TYPES
144
+ module procedure :: kahan_kernel_${s }$
145
+ module procedure :: kahan_kernel_m_${s }$
146
146
#:endfor
147
147
end interface
148
148
public :: kahan_kernel
149
149
150
150
contains
151
151
152
- #:for rk, rt, rs in RC_KINDS_TYPES
153
- elemental subroutine kahan_kernel_${rs }$(a,s,c)
154
- ${rt }$, intent(in) :: a
155
- ${rt }$, intent(inout) :: s
156
- ${rt }$, intent(inout) :: c
157
- ${rt }$ :: t, y
152
+ #:for k, t, s in R_KINDS_TYPES + C_KINDS_TYPES
153
+ elemental subroutine kahan_kernel_${s }$(a,s,c)
154
+ ${t }$, intent(in) :: a
155
+ ${t }$, intent(inout) :: s
156
+ ${t }$, intent(inout) :: c
157
+ ${t }$ :: t, y
158
158
y = a - c
159
159
t = s + y
160
160
c = (t - s) - y
161
161
s = t
162
162
end subroutine
163
- elemental subroutine kahan_kernel_m_${rs }$(a,s,c,m)
164
- ${rt }$, intent(in) :: a
165
- ${rt }$, intent(inout) :: s
166
- ${rt }$, intent(inout) :: c
163
+ elemental subroutine kahan_kernel_m_${s }$(a,s,c,m)
164
+ ${t }$, intent(in) :: a
165
+ ${t }$, intent(inout) :: s
166
+ ${t }$, intent(inout) :: c
167
167
logical, intent(in) :: m
168
- ${rt }$ :: t, y
168
+ ${t }$ :: t, y
169
169
y = a - c
170
170
t = s + y
171
171
c = (t - s) - y
0 commit comments