Skip to content

Commit 6818ee8

Browse files
committed
Refactor add-on
1 parent 67ac2de commit 6818ee8

File tree

8 files changed

+145
-84
lines changed

8 files changed

+145
-84
lines changed

lib/node_modules/@stdlib/math/base/special/inv/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ var x;
2626
var i;
2727

2828
for ( i = 0; i < 100; i++ ) {
29-
x = round( randu() * 100.0 ) - 50.0;
29+
x = round( randu()*100.0 ) - 50.0;
3030
console.log( 'inv(%d) = %d', x, inv( x ) );
3131
}

lib/node_modules/@stdlib/math/base/special/invf/README.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var x;
8787
var i;
8888

8989
for ( i = 0; i < 100; i++ ) {
90-
x = round( randu() * 100.0 ) - 50.0;
90+
x = round( randu()*100.0 ) - 50.0;
9191
console.log( 'invf(%d) = %d', x, invf( x ) );
9292
}
9393
```
@@ -96,6 +96,91 @@ for ( i = 0; i < 100; i++ ) {
9696

9797
<!-- /.examples -->
9898

99+
<!-- C interface documentation. -->
100+
101+
* * *
102+
103+
<section class="c">
104+
105+
## C APIs
106+
107+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
108+
109+
<section class="intro">
110+
111+
</section>
112+
113+
<!-- /.intro -->
114+
115+
<!-- C usage documentation. -->
116+
117+
<section class="usage">
118+
119+
### Usage
120+
121+
```c
122+
#include "stdlib/math/base/special/invf.h"
123+
```
124+
125+
#### stdlib_base_invf( x )
126+
127+
Computes the multiplicative inverse of a single-precision floating-point number.
128+
129+
```c
130+
float y = stdlib_base_invf( 2.0f );
131+
// returns 0.5f
132+
```
133+
134+
The function accepts the following arguments:
135+
136+
- **x**: `[in] float` input value.
137+
138+
```c
139+
float stdlib_base_inv( const float x );
140+
```
141+
142+
</section>
143+
144+
<!-- /.usage -->
145+
146+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
147+
148+
<section class="notes">
149+
150+
</section>
151+
152+
<!-- /.notes -->
153+
154+
<!-- C API usage examples. -->
155+
156+
<section class="examples">
157+
158+
### Examples
159+
160+
```c
161+
#include "stdlib/math/base/special/invf.h"
162+
#include <stdio.h>
163+
164+
int main() {
165+
float x[] = { 3.0f, 4.0f, 5.0f, 12.0f };
166+
167+
float y;
168+
int i;
169+
for ( i = 0; i < 4; i++ ) {
170+
y = stdlib_base_invf( x[ i ] );
171+
printf( "inv(%f) = %f\n", x[ i ], y );
172+
}
173+
}
174+
```
175+
176+
</section>
177+
178+
<!-- /.examples -->
179+
180+
</section>
181+
182+
<!-- /.c -->
183+
99184
<section class="links">
100185

101186
[multiplicative-inverse]: https://en.wikipedia.org/wiki/Multiplicative_inverse

lib/node_modules/@stdlib/math/base/special/invf/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ var x;
2626
var i;
2727

2828
for ( i = 0; i < 100; i++ ) {
29-
x = round( randu() * 100.0 ) - 50.0;
29+
x = round( randu()*100.0 ) - 50.0;
3030
console.log( 'invf(%d) = %d', x, invf( x ) );
3131
}

lib/node_modules/@stdlib/math/base/special/invf/include.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Source files:
3838
'src_files': [
39-
'<(src_dir)/addon.cpp',
39+
'<(src_dir)/addon.c',
4040
'<!@(node -e "var arr = require(\'@stdlib/tools/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
4141
],
4242

lib/node_modules/@stdlib/math/base/special/invf/manifest.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"options": {},
2+
"options": {
3+
"task": "build"
4+
},
35
"fields": [
46
{
57
"field": "src",
@@ -24,6 +26,33 @@
2426
],
2527
"confs": [
2628
{
29+
"task": "build",
30+
"src": [
31+
"./src/invf.c"
32+
],
33+
"include": [
34+
"./include"
35+
],
36+
"libraries": [],
37+
"libpath": [],
38+
"dependencies": [
39+
"@stdlib/math/base/napi/unary"
40+
]
41+
},
42+
{
43+
"task": "benchmark",
44+
"src": [
45+
"./src/invf.c"
46+
],
47+
"include": [
48+
"./include"
49+
],
50+
"libraries": [],
51+
"libpath": [],
52+
"dependencies": []
53+
},
54+
{
55+
"task": "examples",
2756
"src": [
2857
"./src/invf.c"
2958
],
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "stdlib/math/base/special/invf.h"
20+
#include "stdlib/math/base/napi/unary.h"
21+
22+
STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_invf )

lib/node_modules/@stdlib/math/base/special/invf/src/addon.cpp

Lines changed: 0 additions & 79 deletions
This file was deleted.

lib/node_modules/@stdlib/math/base/special/invf/src/invf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
*
2424
* @param x number
2525
* @return multiplicative inverse
26+
*
27+
* @example
28+
* float y = stdlib_base_invf( 2.0f );
29+
* // returns 0.5f
2630
*/
2731
float stdlib_base_invf( const float x ) {
2832
return 1.0f / x;

0 commit comments

Comments
 (0)