@@ -35,8 +35,9 @@ module stdlib_specialfunctions
35
35
!!
36
36
!! gaussian function
37
37
#:for rk, rt in REAL_KINDS_TYPES
38
- elemental ${rt}$ module function gaussian_${rk}$( x ) result( y )
38
+ elemental module function gaussian_${rk}$( x ) result( y )
39
39
${rt}$, intent(in) :: x
40
+ ${rt}$ :: y
40
41
end function
41
42
#:endfor
42
43
end interface
@@ -47,8 +48,9 @@ module stdlib_specialfunctions
47
48
!!
48
49
!! gradient of the gaussian function
49
50
#:for rk, rt in REAL_KINDS_TYPES
50
- elemental ${rt}$ module function gaussian_grad_${rk}$( x ) result( y )
51
+ elemental module function gaussian_grad_${rk}$( x ) result( y )
51
52
${rt}$, intent(in) :: x
53
+ ${rt}$ :: y
52
54
end function
53
55
#:endfor
54
56
end interface
@@ -59,9 +61,10 @@ module stdlib_specialfunctions
59
61
!!
60
62
!! exponential linear unit function
61
63
#:for rk, rt in REAL_KINDS_TYPES
62
- elemental ${rt}$ module function elu_${rk}$( x , a ) result( y )
64
+ elemental module function elu_${rk}$( x , a ) result( y )
63
65
${rt}$, intent(in) :: x
64
66
${rt}$, intent(in) :: a
67
+ ${rt}$ :: y
65
68
end function
66
69
#:endfor
67
70
end interface
@@ -72,9 +75,10 @@ module stdlib_specialfunctions
72
75
!!
73
76
!! gradient of the exponential linear unit function
74
77
#:for rk, rt in REAL_KINDS_TYPES
75
- elemental ${rt}$ module function elu_grad_${rk}$( x , a ) result( y )
78
+ elemental module function elu_grad_${rk}$( x , a ) result( y )
76
79
${rt}$, intent(in) :: x
77
80
${rt}$, intent(in) :: a
81
+ ${rt}$ :: y
78
82
end function
79
83
#:endfor
80
84
end interface
@@ -85,8 +89,9 @@ module stdlib_specialfunctions
85
89
!!
86
90
!! Rectified linear unit function
87
91
#:for rk, rt in REAL_KINDS_TYPES
88
- elemental ${rt}$ module function relu_${rk}$( x ) result( y )
92
+ elemental module function relu_${rk}$( x ) result( y )
89
93
${rt}$, intent(in) :: x
94
+ ${rt}$ :: y
90
95
end function
91
96
#:endfor
92
97
end interface
@@ -97,8 +102,9 @@ module stdlib_specialfunctions
97
102
!!
98
103
!! Gradient rectified linear unit function
99
104
#:for rk, rt in REAL_KINDS_TYPES
100
- elemental ${rt}$ module function relu_grad_${rk}$( x ) result( y )
105
+ elemental module function relu_grad_${rk}$( x ) result( y )
101
106
${rt}$, intent(in) :: x
107
+ ${rt}$ :: y
102
108
end function
103
109
#:endfor
104
110
end interface
@@ -109,8 +115,9 @@ module stdlib_specialfunctions
109
115
!!
110
116
!! Gaussian error linear unit function
111
117
#:for rk, rt in REAL_KINDS_TYPES
112
- elemental ${rt}$ module function gelu_${rk}$( x ) result( y )
118
+ elemental module function gelu_${rk}$( x ) result( y )
113
119
${rt}$, intent(in) :: x
120
+ ${rt}$ :: y
114
121
end function
115
122
#:endfor
116
123
end interface
@@ -121,8 +128,9 @@ module stdlib_specialfunctions
121
128
!!
122
129
!! Gradient of the gaussian error linear unit function
123
130
#:for rk, rt in REAL_KINDS_TYPES
124
- elemental ${rt}$ module function gelu_grad_${rk}$( x ) result( y )
131
+ elemental module function gelu_grad_${rk}$( x ) result( y )
125
132
${rt}$, intent(in) :: x
133
+ ${rt}$ :: y
126
134
end function
127
135
#:endfor
128
136
end interface
@@ -133,8 +141,9 @@ module stdlib_specialfunctions
133
141
!!
134
142
!! Approximated gaussian error linear unit function
135
143
#:for rk, rt in REAL_KINDS_TYPES
136
- elemental ${rt}$ module function gelu_approx_${rk}$( x ) result( y )
144
+ elemental module function gelu_approx_${rk}$( x ) result( y )
137
145
${rt}$, intent(in) :: x
146
+ ${rt}$ :: y
138
147
end function
139
148
#:endfor
140
149
end interface
@@ -145,8 +154,9 @@ module stdlib_specialfunctions
145
154
!!
146
155
!! Gradient of the approximated gaussian error linear unit function
147
156
#:for rk, rt in REAL_KINDS_TYPES
148
- elemental ${rt}$ module function gelu_approx_grad_${rk}$( x ) result( y )
157
+ elemental module function gelu_approx_grad_${rk}$( x ) result( y )
149
158
${rt}$, intent(in) :: x
159
+ ${rt}$ :: y
150
160
end function
151
161
#:endfor
152
162
end interface
@@ -157,8 +167,9 @@ module stdlib_specialfunctions
157
167
!!
158
168
!! Sigmoid function
159
169
#:for rk, rt in REAL_KINDS_TYPES
160
- elemental ${rt}$ module function sigmoid_${rk}$( x ) result( y )
170
+ elemental module function sigmoid_${rk}$( x ) result( y )
161
171
${rt}$, intent(in) :: x
172
+ ${rt}$ :: y
162
173
end function
163
174
#:endfor
164
175
end interface
@@ -169,8 +180,9 @@ module stdlib_specialfunctions
169
180
!!
170
181
!! Gradient of the sigmoid function
171
182
#:for rk, rt in REAL_KINDS_TYPES
172
- elemental ${rt}$ module function sigmoid_grad_${rk}$( x ) result( y )
183
+ elemental module function sigmoid_grad_${rk}$( x ) result( y )
173
184
${rt}$, intent(in) :: x
185
+ ${rt}$ :: y
174
186
end function
175
187
#:endfor
176
188
end interface
@@ -181,8 +193,9 @@ module stdlib_specialfunctions
181
193
!!
182
194
!! Step function
183
195
#:for rk, rt in REAL_KINDS_TYPES
184
- elemental ${rt}$ module function step_${rk}$( x ) result( y )
196
+ elemental module function step_${rk}$( x ) result( y )
185
197
${rt}$, intent(in) :: x
198
+ ${rt}$ :: y
186
199
end function
187
200
#:endfor
188
201
end interface
@@ -193,13 +206,40 @@ module stdlib_specialfunctions
193
206
!!
194
207
!! Gradient of the step function
195
208
#:for rk, rt in REAL_KINDS_TYPES
196
- elemental ${rt}$ module function step_grad_${rk}$( x ) result( y )
209
+ elemental module function step_grad_${rk}$( x ) result( y )
197
210
${rt}$, intent(in) :: x
211
+ ${rt}$ :: y
198
212
end function
199
213
#:endfor
200
214
end interface
201
215
public :: step_grad
202
216
217
+ interface tanh
218
+ !! Version: experimental
219
+ !!
220
+ !! gaussian function
221
+ #:for rk, rt in REAL_KINDS_TYPES
222
+ elemental module function tanh_${rk}$( x ) result( y )
223
+ ${rt}$, intent(in) :: x
224
+ ${rt}$ :: y
225
+ end function
226
+ #:endfor
227
+ end interface
228
+ public :: tanh
229
+
230
+ interface tanh_grad
231
+ !! Version: experimental
232
+ !!
233
+ !! gradient of the gaussian function
234
+ #:for rk, rt in REAL_KINDS_TYPES
235
+ elemental module function tanh_grad_${rk}$( x ) result( y )
236
+ ${rt}$, intent(in) :: x
237
+ ${rt}$ :: y
238
+ end function
239
+ #:endfor
240
+ end interface
241
+ public :: tanh_grad
242
+
203
243
interface Softmax
204
244
!! Version: experimental
205
245
!!
@@ -261,8 +301,9 @@ module stdlib_specialfunctions
261
301
!!
262
302
!! Softplus function
263
303
#:for rk, rt in REAL_KINDS_TYPES
264
- elemental ${rt}$ module function Softplus_${rk}$( x ) result( y )
304
+ elemental module function Softplus_${rk}$( x ) result( y )
265
305
${rt}$, intent(in) :: x
306
+ ${rt}$ :: y
266
307
end function
267
308
#:endfor
268
309
end interface
@@ -273,8 +314,9 @@ module stdlib_specialfunctions
273
314
!!
274
315
!! Gradient of the softplus function
275
316
#:for rk, rt in REAL_KINDS_TYPES
276
- elemental ${rt}$ module function Softplus_grad_${rk}$( x ) result( y )
317
+ elemental module function Softplus_grad_${rk}$( x ) result( y )
277
318
${rt}$, intent(in) :: x
319
+ ${rt}$ :: y
278
320
end function
279
321
#:endfor
280
322
end interface
@@ -286,8 +328,9 @@ module stdlib_specialfunctions
286
328
!! Fast approximation of the tanh function
287
329
!! Source: https://fortran-lang.discourse.group/t/fastgpt-faster-than-pytorch-in-300-lines-of-fortran/5385/31
288
330
#:for rk, rt in REAL_KINDS_TYPES
289
- elemental ${rt}$ module function ftanh_${rk}$( x ) result( y )
331
+ elemental module function ftanh_${rk}$( x ) result( y )
290
332
${rt}$, intent(in) :: x
333
+ ${rt}$ :: y
291
334
end function
292
335
#:endfor
293
336
end interface
@@ -299,8 +342,9 @@ module stdlib_specialfunctions
299
342
!! Fast approximation of the erf function
300
343
!! Source: https://fortran-lang.discourse.group/t/fastgpt-faster-than-pytorch-in-300-lines-of-fortran/5385/31
301
344
#:for rk, rt in REAL_KINDS_TYPES
302
- elemental ${rt}$ module function ferf_${rk}$( x ) result( y )
345
+ elemental module function ferf_${rk}$( x ) result( y )
303
346
${rt}$, intent(in) :: x
347
+ ${rt}$ :: y
304
348
end function
305
349
#:endfor
306
350
end interface
0 commit comments