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,7 +20,7 @@ limitations under the License.
20
20
21
21
# Versine
22
22
23
- > Compute the [ versed sine] [ versed-sine ] .
23
+ > Compute the [ versed sine] [ versed-sine ] of a single-precision floating-point number (in radians) .
24
24
25
25
<section class =" intro " >
26
26
@@ -32,11 +32,6 @@ The [versed sine][versed-sine] is defined as
32
32
\mathop{\mathrm{versin}}(\theta) = 1 - \cos \theta
33
33
```
34
34
35
- <!-- <div class="equation" align="center" data-raw-text="\operatorname{versin}(\theta) = 1 - \cos \theta" data-equation="eq:versine">
36
- <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/versin/docs/img/equation_versine.svg" alt="Versed sine.">
37
- <br>
38
- </div> -->
39
-
40
35
<!-- </equation> -->
41
36
42
37
</section >
@@ -48,21 +43,21 @@ The [versed sine][versed-sine] is defined as
48
43
## Usage
49
44
50
45
``` javascript
51
- var versin = require ( ' @stdlib/math/base/special/versin ' );
46
+ var versinf = require ( ' @stdlib/math/base/special/versinf ' );
52
47
```
53
48
54
- #### versin ( x )
49
+ #### versinf ( x )
55
50
56
- Computes the [ versed sine] [ versed-sine ] of a ` number ` (in radians).
51
+ Computes the [ versed sine] [ versed-sine ] of a single-precision floating-point number (in radians).
57
52
58
53
``` javascript
59
- var v = versin ( 0.0 );
54
+ var v = versinf ( 0.0 );
60
55
// returns 0.0
61
56
62
- v = versin ( 3.141592653589793 / 2.0 );
57
+ v = versinf ( 3.141592653589793 / 2.0 );
63
58
// returns ~1.0
64
59
65
- v = versin ( - 3.141592653589793 / 6.0 );
60
+ v = versinf ( - 3.141592653589793 / 6.0 );
66
61
// returns ~0.13397
67
62
```
68
63
@@ -79,15 +74,15 @@ v = versin( -3.141592653589793/6.0 );
79
74
``` javascript
80
75
var uniform = require ( ' @stdlib/random/array/uniform' );
81
76
var logEachMap = require ( ' @stdlib/console/log-each-map' );
82
- var TWO_PI = require ( ' @stdlib/constants/float64 /two-pi' );
83
- var versin = require ( ' @stdlib/math/base/special/versin ' );
77
+ var TWO_PI = require ( ' @stdlib/constants/float32 /two-pi' );
78
+ var versinf = require ( ' @stdlib/math/base/special/versinf ' );
84
79
85
80
var opts = {
86
- ' dtype' : ' float64 '
81
+ ' dtype' : ' float32 '
87
82
};
88
83
var x = uniform ( 100 , 0.0 , TWO_PI , opts );
89
84
90
- logEachMap ( ' versin (%0.4f) = %0.4f' , x, versin );
85
+ logEachMap ( ' versinf (%0.4f) = %0.4f' , x, versinf );
91
86
```
92
87
93
88
</section >
@@ -117,27 +112,27 @@ logEachMap( 'versin(%0.4f) = %0.4f', x, versin );
117
112
### Usage
118
113
119
114
``` c
120
- #include " stdlib/math/base/special/versin .h"
115
+ #include " stdlib/math/base/special/versinf .h"
121
116
```
122
117
123
- #### stdlib_base_versin ( x )
118
+ #### stdlib_base_versinf ( x )
124
119
125
- Computes the [ versed sine] [ versed-sine ] of a ` number ` (in radians).
120
+ Computes the [ versed sine] [ versed-sine ] of a single-precision floating-point number (in radians).
126
121
127
122
``` c
128
- double out = stdlib_base_versin ( 0.0 );
129
- // returns 0.0
123
+ float out = stdlib_base_versinf ( 0 .0f );
124
+ // returns 0.0f
130
125
131
- out = stdlib_base_versin ( 3.141592653589793 / 2.0 );
132
- // returns ~1.0
126
+ out = stdlib_base_versinf ( 3 .141592653589793f / 2 .0f );
127
+ // returns ~1.0f
133
128
```
134
129
135
130
The function accepts the following arguments:
136
131
137
- - ** x** : ` [in] double ` input value.
132
+ - ** x** : ` [in] float ` input value.
138
133
139
134
``` c
140
- double stdlib_base_versin ( const double x );
135
+ float stdlib_base_versinf ( const float x );
141
136
```
142
137
143
138
</section>
@@ -159,17 +154,17 @@ double stdlib_base_versin( const double x );
159
154
### Examples
160
155
161
156
```c
162
- #include "stdlib/math/base/special/versin .h"
157
+ #include "stdlib/math/base/special/versinf .h"
163
158
#include <stdio.h>
164
159
165
160
int main( void ) {
166
- const double x[] = { 0.0 , 0.523 , 0.785 , 1.047 , 3.14 };
161
+ const float x[] = { 0.0f , 0.523f , 0.785f , 1.047f , 3.14f };
167
162
168
- double y;
163
+ float y;
169
164
int i;
170
165
for ( i = 0; i < 5; i++ ) {
171
- y = stdlib_base_versin ( x[ i ] );
172
- printf( "versin(%lf ) = %lf \n", x[ i ], y );
166
+ y = stdlib_base_versinf ( x[ i ] );
167
+ printf( "versinf(%f ) = %f \n", x[ i ], y );
173
168
}
174
169
}
175
170
```
@@ -186,14 +181,6 @@ int main( void ) {
186
181
187
182
<section class =" related " >
188
183
189
- * * *
190
-
191
- ## See Also
192
-
193
- - <span class =" package-name " >[ ` @stdlib/math/base/special/cos ` ] [ @stdlib/math/base/special/cos ] </span ><span class =" delimiter " >: </span ><span class =" description " >compute the cosine of a number.</span >
194
- - <span class =" package-name " >[ ` @stdlib/math/base/special/sin ` ] [ @stdlib/math/base/special/sin ] </span ><span class =" delimiter " >: </span ><span class =" description " >compute the sine of a number.</span >
195
- - <span class =" package-name " >[ ` @stdlib/math/base/special/vercos ` ] [ @stdlib/math/base/special/vercos ] </span ><span class =" delimiter " >: </span ><span class =" description " >compute the versed cosine.</span >
196
-
197
184
</section >
198
185
199
186
<!-- /.related -->
@@ -206,12 +193,6 @@ int main( void ) {
206
193
207
194
<!-- <related-links> -->
208
195
209
- [ @stdlib/math/base/special/cos ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cos
210
-
211
- [ @stdlib/math/base/special/sin ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/sin
212
-
213
- [ @stdlib/math/base/special/vercos ] : https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/vercos
214
-
215
196
<!-- </related-links> -->
216
197
217
198
</section >
0 commit comments