Skip to content

Commit 2c58cce

Browse files
committed
Merge branch 'develop' into feat/cpolarf
2 parents 2f2dd8f + 8a590f0 commit 2c58cce

File tree

6 files changed

+73
-146
lines changed

6 files changed

+73
-146
lines changed

lib/node_modules/@stdlib/math/base/special/atan2/benchmark/c/cephes/Makefile

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
# limitations under the License.
1717
#/
1818

19-
2019
# VARIABLES #
2120

2221
ifndef VERBOSE
2322
QUIET := @
23+
else
24+
QUIET :=
2425
endif
2526

2627
# Specify the path to Cephes:
@@ -29,7 +30,7 @@ CEPHES ?=
2930
# Specify a list of Cephes source files:
3031
CEPHES_SRC ?=
3132

32-
# Determine the OS:
33+
# Determine the OS ([1][1], [2][2]).
3334
#
3435
# [1]: https://en.wikipedia.org/wiki/Uname#Examples
3536
# [2]: http://stackoverflow.com/a/27776822/2225624
@@ -42,6 +43,10 @@ ifneq (, $(findstring MSYS,$(OS)))
4243
else
4344
ifneq (, $(findstring CYGWIN,$(OS)))
4445
OS := WINNT
46+
else
47+
ifneq (, $(findstring Windows_NT,$(OS)))
48+
OS := WINNT
49+
endif
4550
endif
4651
endif
4752
endif
@@ -60,7 +65,7 @@ CFLAGS ?= \
6065
-Wall \
6166
-pedantic
6267

63-
# Determine whether to generate [position independent code][1]:
68+
# Determine whether to generate position independent code ([1][1], [2][2]).
6469
#
6570
# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
6671
# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
@@ -74,39 +79,55 @@ endif
7479
c_targets := benchmark.out
7580

7681

77-
# TARGETS #
82+
# RULES #
7883

79-
# Default target.
84+
#/
85+
# Compiles C source files.
8086
#
81-
# This target is the default target.
82-
87+
# @param {string} CEPHES_SRC - list of Cephes source files
88+
# @param {string} [C_COMPILER] - C compiler
89+
# @param {string} [CFLAGS] - C compiler flags
90+
# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code
91+
#
92+
# @example
93+
# make
94+
#
95+
# @example
96+
# make all
97+
#/
8398
all: $(c_targets)
8499

85100
.PHONY: all
86101

87-
88-
# Compile C source.
102+
#/
103+
# Compiles C source files.
89104
#
90-
# This target compiles C source files.
91-
105+
# @private
106+
# @param {string} CC - C compiler
107+
# @param {string} CFLAGS - C compiler flags
108+
# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code
109+
# @param {string} CEPHES_SRC - list of Cephes source files
110+
#/
92111
$(c_targets): %.out: %.c
93112
$(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $(CEPHES_SRC) $< -lm
94113

95-
96-
# Run a benchmark.
114+
#/
115+
# Runs compiled benchmarks.
97116
#
98-
# This target runs a benchmark.
99-
117+
# @example
118+
# make run
119+
#/
100120
run: $(c_targets)
101121
$(QUIET) ./$<
102122

103123
.PHONY: run
104124

105-
106-
# Perform clean-up.
125+
#/
126+
# Removes generated files.
107127
#
108-
# This target removes generated files.
109-
128+
# @example
129+
# make clean
130+
#/
110131
clean:
111132
$(QUIET) -rm -f *.o *.out
112133

lib/node_modules/@stdlib/math/base/special/atan2/benchmark/c/native/Makefile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ c_targets := benchmark.out
8888
# RULES #
8989

9090
#/
91-
# Compiles source files.
91+
# Compiles C source files.
9292
#
93-
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
94-
# @param {string} [CFLAGS] - C compiler options
95-
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
96-
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
97-
# @param {string} [SOURCE_FILES] - list of source files
93+
# @param {string} SOURCE_FILES - list of C source files
94+
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`)
95+
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`)
9896
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
99-
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
97+
# @param {string} [C_COMPILER] - C compiler
98+
# @param {string} [CFLAGS] - C compiler flags
99+
# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code
100100
#
101101
# @example
102102
# make
@@ -112,13 +112,13 @@ all: $(c_targets)
112112
# Compiles C source files.
113113
#
114114
# @private
115-
# @param {string} CC - C compiler (e.g., `gcc`)
116-
# @param {string} CFLAGS - C compiler options
117-
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
118-
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
119-
# @param {string} SOURCE_FILES - list of source files
120-
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
121-
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
115+
# @param {string} SOURCE_FILES - list of C source files
116+
# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`)
117+
# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`)
118+
# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
119+
# @param {string} CC - C compiler
120+
# @param {string} CFLAGS - C compiler flags
121+
# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code
122122
#/
123123
$(c_targets): %.out: %.c
124124
$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)

lib/node_modules/@stdlib/math/base/special/cpolar/benchmark/benchmark.native.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var uniform = require( '@stdlib/random/base/uniform' );
26-
var isArray = require( '@stdlib/assert/is-array' );
26+
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
2727
var Complex128 = require( '@stdlib/complex/float64/ctor' );
2828
var tryRequire = require( '@stdlib/utils/try-require' );
2929
var pkg = require( './../package.json' ).name;
@@ -57,8 +57,8 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5757
}
5858
}
5959
b.toc();
60-
if ( !isArray( y ) ) {
61-
b.fail( 'should return an array' );
60+
if ( !isFloat64Array( y ) ) {
61+
b.fail( 'should return a Float64Array' );
6262
}
6363
b.pass( 'benchmark finished' );
6464
b.end();

lib/node_modules/@stdlib/math/base/special/cpolar/lib/native.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ var addon = require( './../src/addon.node' );
3131
*
3232
* @private
3333
* @param {Complex128} z - complex number
34-
* @returns {Array<number>} absolute value and phase (in radians)
34+
* @returns {Float64Array} absolute value and phase (in radians)
3535
*
3636
* @example
3737
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
3838
*
3939
* var o = cpolar( new Complex128( 5.0, 3.0 ) );
40-
* // returns [ ~5.83, ~0.5404 ]
40+
* // returns <Float64Array>[ ~5.83, ~0.5404 ]
4141
*/
4242
function cpolar( z ) {
43-
var out = new Float64Array( 2 );
44-
addon( out, z );
45-
return [ out[ 0 ], out[ 1 ] ];
43+
var o = new Float64Array( 2 );
44+
addon( z, o );
45+
return o;
4646
}
4747

4848

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"libpath": [],
3838
"dependencies": [
3939
"@stdlib/napi/argv",
40+
"@stdlib/napi/argv-complex128",
41+
"@stdlib/napi/argv-float64array",
42+
"@stdlib/napi/export",
4043
"@stdlib/complex/float64/ctor",
4144
"@stdlib/complex/float64/reim",
4245
"@stdlib/math/base/special/cphase",

lib/node_modules/@stdlib/math/base/special/cpolar/src/addon.c

Lines changed: 8 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
#include "stdlib/math/base/special/cpolar.h"
2020
#include "stdlib/napi/argv.h"
21+
#include "stdlib/napi/argv_complex128.h"
22+
#include "stdlib/napi/argv_float64array.h"
23+
#include "stdlib/napi/export.h"
2124
#include <node_api.h>
2225

2326
/**
@@ -28,111 +31,11 @@
2831
* @return Node-API value
2932
*/
3033
static napi_value addon( napi_env env, napi_callback_info info ) {
31-
napi_status status;
32-
33-
// Get callback arguments:
34-
size_t argc = 2;
35-
napi_value argv[ 2 ];
36-
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
37-
assert( status == napi_ok );
38-
39-
// Check whether we were provided the correct number of arguments:
40-
if ( argc < 2 ) {
41-
status = napi_throw_error( env, NULL, "invalid invocation. Insufficient arguments." );
42-
assert( status == napi_ok );
43-
return NULL;
44-
}
45-
if ( argc > 2 ) {
46-
status = napi_throw_error( env, NULL, "invalid invocation. Too many arguments." );
47-
assert( status == napi_ok );
48-
return NULL;
49-
}
50-
51-
bool res;
52-
status = napi_is_typedarray( env, argv[ 0 ], &res );
53-
assert( status == napi_ok );
54-
if ( res == false ) {
55-
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a Float64Array." );
56-
assert( status == napi_ok );
57-
return NULL;
58-
}
59-
60-
// Get the first element out
61-
napi_typedarray_type vtype0;
62-
size_t len;
63-
void *Out;
64-
status = napi_get_typedarray_info( env, argv[ 0 ], &vtype0, &len, &Out, NULL, NULL );
65-
assert( status == napi_ok );
66-
if ( vtype0 != napi_float64_array ) {
67-
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a Float64Array." );
68-
assert( status == napi_ok );
69-
return NULL;
70-
}
71-
if ( len != 2 ) {
72-
status = napi_throw_range_error( env, NULL, "invalid argument. First argument must have 2 elements." );
73-
assert( status == napi_ok );
74-
return NULL;
75-
}
76-
77-
// Get the real component
78-
napi_value xre;
79-
status = napi_get_named_property( env, argv[ 1 ], "re", &xre );
80-
assert( status == napi_ok );
81-
82-
napi_valuetype xretype;
83-
status = napi_typeof( env, xre, &xretype );
84-
assert( status == napi_ok );
85-
if ( xretype != napi_number ) {
86-
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." );
87-
assert( status == napi_ok );
88-
return NULL;
89-
}
90-
91-
// Get the imaginary component
92-
napi_value xim;
93-
status = napi_get_named_property( env, argv[ 1 ], "im", &xim );
94-
assert( status == napi_ok );
95-
96-
napi_valuetype ximtype;
97-
status = napi_typeof( env, xim, &ximtype );
98-
assert( status == napi_ok );
99-
if ( ximtype != napi_number ) {
100-
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." );
101-
assert( status == napi_ok );
102-
return NULL;
103-
}
104-
105-
double re;
106-
status = napi_get_value_double( env, xre, &re );
107-
assert( status == napi_ok );
108-
109-
double im;
110-
status = napi_get_value_double( env, xim, &im );
111-
assert( status == napi_ok );
112-
113-
double cabs;
114-
double cphase;
115-
stdlib_base_cpolar( stdlib_complex128( re, im ), &cabs, &cphase );
116-
117-
double *op = (double *)Out;
118-
op[ 0 ] = cabs;
119-
op[ 1 ] = cphase;
120-
34+
STDLIB_NAPI_ARGV( env, info, argv, argc, 2 );
35+
STDLIB_NAPI_ARGV_COMPLEX128( env, z, argv, 0 );
36+
STDLIB_NAPI_ARGV_FLOAT64ARRAY( env, o, olen, argv, 1 );
37+
stdlib_base_cpolar( z, &o[ 0 ], &o[ 1 ] );
12138
return NULL;
12239
}
12340

124-
/**
125-
* Initializes a Node-API module.
126-
*
127-
* @param env environment under which the function is invoked
128-
* @param exports exports object
129-
* @return main export
130-
*/
131-
static napi_value init( napi_env env, napi_value exports ) {
132-
napi_value fcn;
133-
napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn );
134-
assert( status == napi_ok );
135-
return fcn;
136-
}
137-
138-
NAPI_MODULE( NODE_GYP_MODULE_NAME, init )
41+
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )

0 commit comments

Comments
 (0)