2
2
3
3
@license Apache-2.0
4
4
5
- Copyright (c) 2018 The Stdlib Authors.
5
+ Copyright (c) 2025 The Stdlib Authors.
6
6
7
7
Licensed under the Apache License, Version 2.0 (the "License");
8
8
you may not use this file except in compliance with the License.
@@ -20,23 +20,18 @@ limitations under the License.
20
20
21
21
# Trigamma
22
22
23
- > [ Trigamma] [ trigamma-function ] function.
23
+ > [ Trigamma] [ trigamma-function ] function for a single-precision floating-point number .
24
24
25
25
<section class =" intro " >
26
26
27
- The [ trigamma function] [ trigamma-function ] ` ψ^(1) ` is the derivative of the [ digamma function] [ @stdlib/math/base/special/ digamma] .
27
+ The [ trigamma function] [ trigamma-function ] ` ψ^(1) ` is the derivative of the [ digamma function] [ digamma-function ] .
28
28
29
29
<!-- <equation class="equation" label="eq:trigamma_function" align="center" raw="\psi^{(1)}(x) =\frac{d}{dx} \Psi(x) = \sum_{k=0}^\infty \frac{1}{(k+x)^2}" alt="Trigamma function"> -->
30
30
31
31
``` math
32
32
\psi^{(1)}(x) =\frac{d}{dx} \Psi(x) = \sum_{k=0}^\infty \frac{1}{(k+x)^2}
33
33
```
34
34
35
- <!-- <div class="equation" align="center" data-raw-text="\psi^{(1)}(x) =\frac{d}{dx} \Psi(x) = \sum_{k=0}^\infty \frac{1}{(k+x)^2}" data-equation="eq:trigamma_function">
36
- <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/trigamma/docs/img/equation_trigamma_function.svg" alt="Trigamma function">
37
- <br>
38
- </div> -->
39
-
40
35
<!-- </equation> -->
41
36
42
37
</section >
@@ -48,41 +43,41 @@ The [trigamma function][trigamma-function] `ψ^(1)` is the derivative of the [di
48
43
## Usage
49
44
50
45
``` javascript
51
- var trigamma = require ( ' @stdlib/math/base/special/trigamma ' );
46
+ var trigammaf = require ( ' @stdlib/math/base/special/trigammaf ' );
52
47
```
53
48
54
- #### trigamma ( x )
49
+ #### trigammaf ( x )
55
50
56
- Evaluates the [ trigamma function] [ trigamma-function ] .
51
+ Evaluates the [ trigamma function] [ trigamma-function ] for a single-precision floating-point number .
57
52
58
53
``` javascript
59
- var v = trigamma ( - 2.5 );
54
+ var v = trigammaf ( - 2.5 );
60
55
// returns ~9.539
61
56
62
- v = trigamma ( 1.0 );
57
+ v = trigammaf ( 1.0 );
63
58
// returns ~1.645
64
59
65
- v = trigamma ( 10.0 );
60
+ v = trigammaf ( 10.0 );
66
61
// returns ~0.105
67
62
```
68
63
69
64
If ` x ` is ` 0 ` or a negative ` integer ` , the function returns ` NaN ` .
70
65
71
66
``` javascript
72
- var v = trigamma ( 0.0 );
67
+ var v = trigammaf ( 0.0 );
73
68
// returns NaN
74
69
75
- v = trigamma ( - 1.0 );
70
+ v = trigammaf ( - 1.0 );
76
71
// returns NaN
77
72
78
- v = trigamma ( - 2.0 );
73
+ v = trigammaf ( - 2.0 );
79
74
// returns NaN
80
75
```
81
76
82
77
If provided ` NaN ` , the function returns ` NaN ` .
83
78
84
79
``` javascript
85
- var v = trigamma ( NaN );
80
+ var v = trigammaf ( NaN );
86
81
// returns NaN
87
82
```
88
83
@@ -99,14 +94,14 @@ var v = trigamma( NaN );
99
94
``` javascript
100
95
var uniform = require ( ' @stdlib/random/array/uniform' );
101
96
var logEachMap = require ( ' @stdlib/console/log-each-map' );
102
- var trigamma = require ( ' @stdlib/math/base/special/trigamma ' );
97
+ var trigammaf = require ( ' @stdlib/math/base/special/trigammaf ' );
103
98
104
99
var opts = {
105
- ' dtype' : ' float64 '
100
+ ' dtype' : ' float32 '
106
101
};
107
102
var x = uniform ( 100 , - 50.0 , 50.0 , opts );
108
103
109
- logEachMap ( ' x: %0.4f, ψ^(1)(x): %0.4f' , x, trigamma );
104
+ logEachMap ( ' x: %0.4f, ψ^(1)(x): %0.4f' , x, trigammaf );
110
105
```
111
106
112
107
</section >
@@ -136,27 +131,27 @@ logEachMap( 'x: %0.4f, ψ^(1)(x): %0.4f', x, trigamma );
136
131
### Usage
137
132
138
133
``` c
139
- #include " stdlib/math/base/special/trigamma .h"
134
+ #include " stdlib/math/base/special/trigammaf .h"
140
135
```
141
136
142
- #### stdlib_base_trigamma ( x )
137
+ #### stdlib_base_trigammaf ( x )
143
138
144
- Evaluates the [ trigamma function] [ trigamma-function ] .
139
+ Evaluates the [ trigamma function] [ trigamma-function ] for a single-precision floating-point number .
145
140
146
141
``` c
147
- double out = stdlib_base_trigamma ( -2.5 );
148
- // returns ~9.539
142
+ float out = stdlib_base_trigammaf ( -2 .5f );
143
+ // returns ~9.539f
149
144
150
- out = stdlib_base_trigamma ( 1.0 );
151
- // returns ~1.645
145
+ out = stdlib_base_trigammaf ( 1 .0f );
146
+ // returns ~1.645f
152
147
```
153
148
154
149
The function accepts the following arguments:
155
150
156
- - ** x** : ` [in] double ` input value.
151
+ - ** x** : ` [in] float ` input value.
157
152
158
153
``` c
159
- double stdlib_base_trigamma ( const double x );
154
+ float stdlib_base_trigammaf ( const float x );
160
155
```
161
156
162
157
</section>
@@ -178,17 +173,17 @@ double stdlib_base_trigamma( const double x );
178
173
### Examples
179
174
180
175
```c
181
- #include "stdlib/math/base/special/trigamma .h"
176
+ #include "stdlib/math/base/special/trigammaf .h"
182
177
#include <stdio.h>
183
178
184
179
int main( void ) {
185
- const double x[] = { 4.0 , -1.5 , -0.5 , 0.5 };
180
+ const float x[] = { 4.0f , -1.5f , -0.5f , 0.5f };
186
181
187
- double y;
182
+ float y;
188
183
int i;
189
184
for ( i = 0; i < 4; i++ ) {
190
- y = stdlib_base_trigamma ( x[ i ] );
191
- printf( "trigamma(%lf) = %lf \n", x[ i ], y );
185
+ y = stdlib_base_trigammaf ( x[ i ] );
186
+ printf( "x: %f, ψ^(1)(x): %f \n", x[ i ], y );
192
187
}
193
188
}
194
189
```
@@ -205,13 +200,6 @@ int main( void ) {
205
200
206
201
<section class =" related " >
207
202
208
- * * *
209
-
210
- ## See Also
211
-
212
- - <span class =" package-name " >[ ` @stdlib/math/base/special/digamma ` ] [ @stdlib/math/base/special/digamma ] </span ><span class =" delimiter " >: </span ><span class =" description " >digamma function.</span >
213
- - <span class =" package-name " >[ ` @stdlib/math/base/special/gamma ` ] [ @stdlib/math/base/special/gamma ] </span ><span class =" delimiter " >: </span ><span class =" description " >gamma function.</span >
214
-
215
203
</section >
216
204
217
205
<!-- /.related -->
@@ -222,11 +210,9 @@ int main( void ) {
222
210
223
211
[ trigamma-function ] : https://en.wikipedia.org/wiki/Trigamma_function
224
212
225
- <!-- <related-links> -->
213
+ [ digamma-function ] : https://en.wikipedia.org/wiki/Digamma_function
226
214
227
- [ @stdlib/math/base/special/digamma ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/digamma
228
-
229
- [ @stdlib/math/base/special/gamma ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/gamma
215
+ <!-- <related-links> -->
230
216
231
217
<!-- </related-links> -->
232
218
0 commit comments