Skip to content

Commit 3c00fed

Browse files
committed
feat: basic files added
1 parent bf8cd07 commit 3c00fed

File tree

5 files changed

+602
-0
lines changed

5 files changed

+602
-0
lines changed
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# ahaversinf
22+
23+
> Compute the [inverse half-value versed sine][archaversine] of a single-precision floating-point number.
24+
25+
<section class="intro">
26+
27+
The [inverse half-value versed sine][archaversine] is defined as
28+
29+
<!-- <equation class="equation" label="eq:archaversine" align="center" raw="\operatorname{ahaversin}(\theta) = 2 \cdot \arcsin(\sqrt{\theta})" alt="Inverse half-value versed sine."> -->
30+
31+
```math
32+
\mathop{\mathrm{ahaversin}}(\theta) = 2 \cdot \arcsin(\sqrt{\theta})
33+
```
34+
35+
<!-- <div class="equation" align="center" data-raw-text="\operatorname{ahaversin}(\theta) = 2 \cdot \arcsin(\sqrt{\theta})" data-equation="eq:archaversine">
36+
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/ahaversin/docs/img/equation_archaversine.svg" alt="Inverse half-value versed sine.">
37+
<br>
38+
</div> -->
39+
40+
<!-- </equation> -->
41+
42+
</section>
43+
44+
<!-- /.intro -->
45+
46+
<section class="usage">
47+
48+
## Usage
49+
50+
```javascript
51+
var ahaversinf = require( '@stdlib/math/base/special/ahaversinf' );
52+
```
53+
54+
#### ahaversinf( x )
55+
56+
Computes the [inverse half-value versed sine][archaversine] of a single-precision floating-point number.
57+
58+
```javascript
59+
var v = ahaversinf( 0.0 );
60+
// returns 0.0
61+
62+
v = ahaversinf( 1.0 );
63+
// returns ~3.1416
64+
65+
v = ahaversinf( 0.5 );
66+
// returns ~1.5708
67+
```
68+
69+
If `x < 0`, `x > 1`, or `x` is `NaN`, the function returns `NaN`.
70+
71+
```javascript
72+
var v = ahaversinf( 1.5 );
73+
// returns NaN
74+
75+
v = ahaversinf( -3.14 );
76+
// returns NaN
77+
78+
v = ahaversinf( NaN );
79+
// returns NaN
80+
```
81+
82+
</section>
83+
84+
<!-- /.usage -->
85+
86+
<section class="examples">
87+
88+
## Examples
89+
90+
<!-- eslint no-undef: "error" -->
91+
92+
```javascript
93+
var linspace = require( '@stdlib/array/base/linspace' );
94+
var ahaversinf = require( '@stdlib/math/base/special/ahaversinf' );
95+
96+
var x = linspace( 0.0, 1.0, 100 );
97+
98+
var i;
99+
for ( i = 0; i < x.length; i++ ) {
100+
console.log( ahaversinf( x[ i ] ) );
101+
}
102+
```
103+
104+
</section>
105+
106+
<!-- /.examples -->
107+
108+
<!-- C interface documentation. -->
109+
110+
* * *
111+
112+
<section class="c">
113+
114+
## C APIs
115+
116+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
117+
118+
<section class="intro">
119+
120+
</section>
121+
122+
<!-- /.intro -->
123+
124+
<!-- C usage documentation. -->
125+
126+
<section class="usage">
127+
128+
### Usage
129+
130+
```c
131+
#include "stdlib/math/base/special/ahaversinf.h"
132+
```
133+
134+
#### stdlib_base_ahaversinf( x )
135+
136+
Computes the [inverse half-value versed sine][archaversine] of a single-precision floating-point number (in radians).
137+
138+
```c
139+
float out = stdlib_base_ahaversinf( 0.0f );
140+
// returns 0.0f
141+
```
142+
143+
If `x < 0`, `x > 1`, or `x` is `NaN`, the function returns `NaN`.
144+
145+
```c
146+
float out = stdlib_base_ahaversinf( -3.14f );
147+
// returns NaN
148+
```
149+
150+
The function accepts the following arguments:
151+
152+
- **x**: `[in] float` input value.
153+
154+
```c
155+
float stdlib_base_ahaversinf( const float x );
156+
```
157+
158+
</section>
159+
160+
<!-- /.usage -->
161+
162+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
163+
164+
<section class="notes">
165+
166+
</section>
167+
168+
<!-- /.notes -->
169+
170+
<!-- C API usage examples. -->
171+
172+
<section class="examples">
173+
174+
### Examples
175+
176+
```c
177+
#include "stdlib/math/base/special/ahaversinf.h"
178+
#include <stdio.h>
179+
180+
int main( void ) {
181+
const float x[] = { -2.0f, -1.6f, -1.2f, -0.8f, -0.4f, 0.4f, 0.8f, 1.2f, 1.6f, 2.0f };
182+
183+
float v;
184+
int i;
185+
for ( i = 0; i < 10; i++ ) {
186+
v = stdlib_base_ahaversinf( x[ i ] );
187+
printf( "ahaversin(%f) = %f\n", x[ i ], v );
188+
}
189+
}
190+
```
191+
192+
</section>
193+
194+
<!-- /.examples -->
195+
196+
</section>
197+
198+
<!-- /.c -->
199+
200+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
201+
202+
<section class="related">
203+
204+
</section>
205+
206+
<!-- /.related -->
207+
208+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
209+
210+
<section class="links">
211+
212+
[archaversine]: https://en.wikipedia.org/wiki/Versine
213+
214+
<!-- <related-links> -->
215+
216+
<!-- </related-links> -->
217+
218+
</section>
219+
220+
<!-- /.links -->
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# @license Apache-2.0
2+
#
3+
# Copyright (c) 2024 The Stdlib Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# A `.gyp` file for building a Node.js native add-on.
18+
#
19+
# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
20+
# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
21+
{
22+
# List of files to include in this file:
23+
'includes': [
24+
'./include.gypi',
25+
],
26+
27+
# Define variables to be used throughout the configuration for all targets:
28+
'variables': {
29+
# Target name should match the add-on export name:
30+
'addon_target_name%': 'addon',
31+
32+
# Set variables based on the host OS:
33+
'conditions': [
34+
[
35+
'OS=="win"',
36+
{
37+
# Define the object file suffix:
38+
'obj': 'obj',
39+
},
40+
{
41+
# Define the object file suffix:
42+
'obj': 'o',
43+
}
44+
], # end condition (OS=="win")
45+
], # end conditions
46+
}, # end variables
47+
48+
# Define compile targets:
49+
'targets': [
50+
51+
# Target to generate an add-on:
52+
{
53+
# The target name should match the add-on export name:
54+
'target_name': '<(addon_target_name)',
55+
56+
# Define dependencies:
57+
'dependencies': [],
58+
59+
# Define directories which contain relevant include headers:
60+
'include_dirs': [
61+
# Local include directory:
62+
'<@(include_dirs)',
63+
],
64+
65+
# List of source files:
66+
'sources': [
67+
'<@(src_files)',
68+
],
69+
70+
# Settings which should be applied when a target's object files are used as linker input:
71+
'link_settings': {
72+
# Define libraries:
73+
'libraries': [
74+
'<@(libraries)',
75+
],
76+
77+
# Define library directories:
78+
'library_dirs': [
79+
'<@(library_dirs)',
80+
],
81+
},
82+
83+
# C/C++ compiler flags:
84+
'cflags': [
85+
# Enable commonly used warning options:
86+
'-Wall',
87+
88+
# Aggressive optimization:
89+
'-O3',
90+
],
91+
92+
# C specific compiler flags:
93+
'cflags_c': [
94+
# Specify the C standard to which a program is expected to conform:
95+
'-std=c99',
96+
],
97+
98+
# C++ specific compiler flags:
99+
'cflags_cpp': [
100+
# Specify the C++ standard to which a program is expected to conform:
101+
'-std=c++11',
102+
],
103+
104+
# Linker flags:
105+
'ldflags': [],
106+
107+
# Apply conditions based on the host OS:
108+
'conditions': [
109+
[
110+
'OS=="mac"',
111+
{
112+
# Linker flags:
113+
'ldflags': [
114+
'-undefined dynamic_lookup',
115+
'-Wl,-no-pie',
116+
'-Wl,-search_paths_first',
117+
],
118+
},
119+
], # end condition (OS=="mac")
120+
[
121+
'OS!="win"',
122+
{
123+
# C/C++ flags:
124+
'cflags': [
125+
# Generate platform-independent code:
126+
'-fPIC',
127+
],
128+
},
129+
], # end condition (OS!="win")
130+
], # end conditions
131+
}, # end target <(addon_target_name)
132+
133+
# Target to copy a generated add-on to a standard location:
134+
{
135+
'target_name': 'copy_addon',
136+
137+
# Declare that the output of this target is not linked:
138+
'type': 'none',
139+
140+
# Define dependencies:
141+
'dependencies': [
142+
# Require that the add-on be generated before building this target:
143+
'<(addon_target_name)',
144+
],
145+
146+
# Define a list of actions:
147+
'actions': [
148+
{
149+
'action_name': 'copy_addon',
150+
'message': 'Copying addon...',
151+
152+
# Explicitly list the inputs in the command-line invocation below:
153+
'inputs': [],
154+
155+
# Declare the expected outputs:
156+
'outputs': [
157+
'<(addon_output_dir)/<(addon_target_name).node',
158+
],
159+
160+
# Define the command-line invocation:
161+
'action': [
162+
'cp',
163+
'<(PRODUCT_DIR)/<(addon_target_name).node',
164+
'<(addon_output_dir)/<(addon_target_name).node',
165+
],
166+
},
167+
], # end actions
168+
}, # end target copy_addon
169+
], # end targets
170+
}

0 commit comments

Comments
 (0)