Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Nov 17, 2024
1 parent bc569d3 commit 166c5fe
Show file tree
Hide file tree
Showing 18 changed files with 125 additions and 77 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ A total of 5 people contributed to this release. Thank you to the following cont

<details>

- [`72bf083`](https://github.com/stdlib-js/stdlib/commit/72bf083eb1bbc829eebbbff32f73fc2a202b2570) - **refactor:** update benchmarks and test fixtures in `math/base/special/ahavercosf` [(#3118)](https://github.com/stdlib-js/stdlib/pull/3118) _(by Gunj Joshi)_
- [`163a3e7`](https://github.com/stdlib-js/stdlib/commit/163a3e7fa2c7429f88b2dd69df42572f9ff0af9d) - **refactor:** update benchmark, add `f` suffixes, missing spaces in `math/base/special/gcdf` [(#3121)](https://github.com/stdlib-js/stdlib/pull/3121) _(by Gunj Joshi, Athan Reines)_
- [`3c5c933`](https://github.com/stdlib-js/stdlib/commit/3c5c933c86f7243e8872dcf3cb7548d0399b1b35) - **refactor:** update benchmarks and test fixtures in `math/base/special/ahaversinf` [(#3119)](https://github.com/stdlib-js/stdlib/pull/3119) _(by Gunj Joshi)_
- [`8a03f83`](https://github.com/stdlib-js/stdlib/commit/8a03f833d9808c17418225664d7250b94fb0e1b5) - **refactor:** use constant package in `math/base/special/fmodf` (#3120) [(#3120)](https://github.com/stdlib-js/stdlib/pull/3120) _(by Gunj Joshi)_
Expand Down
9 changes: 5 additions & 4 deletions base/special/ahavercosf/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var pkg = require( './../package.json' ).name;
var ahavercosf = require( './../lib' );
Expand All @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = randu( 100, 0.0, 1.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = randu();
y = ahavercosf( x );
y = ahavercosf( x[ i % x.length ] );
if ( isnanf( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
7 changes: 4 additions & 3 deletions base/special/ahavercosf/benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

x = randu( 100, 0.0, 1.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = randu();
y = ahavercosf( x );
y = ahavercosf( x[ i % x.length ] );
if ( isnanf( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
81 changes: 60 additions & 21 deletions base/special/ahavercosf/benchmark/c/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2018 The Stdlib Authors.
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,14 +16,15 @@
# limitations under the License.
#/


# VARIABLES #

ifndef VERBOSE
QUIET := @
else
QUIET :=
endif

# Determine the OS:
# Determine the OS ([1][1], [2][2]).
#
# [1]: https://en.wikipedia.org/wiki/Uname#Examples
# [2]: http://stackoverflow.com/a/27776822/2225624
Expand All @@ -36,6 +37,10 @@ ifneq (, $(findstring MSYS,$(OS)))
else
ifneq (, $(findstring CYGWIN,$(OS)))
OS := WINNT
else
ifneq (, $(findstring Windows_NT,$(OS)))
OS := WINNT
endif
endif
endif
endif
Expand All @@ -54,7 +59,7 @@ CFLAGS ?= \
-Wall \
-pedantic

# Determine whether to generate [position independent code][1]:
# Determine whether to generate position independent code ([1][1], [2][2]).
#
# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
Expand All @@ -64,43 +69,77 @@ else
fPIC ?= -fPIC
endif

# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
INCLUDE ?=

# List of source files:
SOURCE_FILES ?=

# List of libraries (e.g., `-lopenblas -lpthread`):
LIBRARIES ?=

# List of library paths (e.g., `-L /foo/bar -L /beep/boop`):
LIBPATH ?=

# List of C targets:
c_targets := benchmark.out


# TARGETS #
# RULES #

# Default target.
#/
# Compiles source files.
#
# This target is the default target.

# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
# @param {string} [CFLAGS] - C compiler options
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
# @param {string} [SOURCE_FILES] - list of source files
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
#
# @example
# make
#
# @example
# make all
#/
all: $(c_targets)

.PHONY: all


# Compile C source.
#/
# Compiles C source files.
#
# This target compiles C source files.

# @private
# @param {string} CC - C compiler (e.g., `gcc`)
# @param {string} CFLAGS - C compiler options
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
# @param {string} SOURCE_FILES - list of source files
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
#/
$(c_targets): %.out: %.c
$(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm

$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)

# Run a benchmark.
#/
# Runs compiled benchmarks.
#
# This target runs a benchmark.

# @example
# make run
#/
run: $(c_targets)
$(QUIET) ./$<

.PHONY: run


# Perform clean-up.
#/
# Removes generated files.
#
# This target removes generated files.

# @example
# make clean
#/
clean:
$(QUIET) -rm -f *.o *.out

Expand Down
13 changes: 8 additions & 5 deletions base/special/ahavercosf/benchmark/c/benchmark.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,15 +90,18 @@ static float rand_float( void ) {
*/
static double benchmark( void ) {
double elapsed;
float x;
float y;
float x[ 100 ];
double t;
float y;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = rand_float();
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = rand_float();
y = 2.0f * acosf( sqrtf( x ) );
y = 2.0f * acosf( sqrtf( x[ i % 100 ] ) );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
11 changes: 7 additions & 4 deletions base/special/ahavercosf/benchmark/c/native/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,18 @@ static float rand_float( void ) {
*/
static double benchmark( void ) {
double elapsed;
float x;
float y;
float x[ 100 ];
double t;
float y;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = rand_float();
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = rand_float();
y = stdlib_base_ahavercosf( x );
y = stdlib_base_ahavercosf( x[ i % 100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
4 changes: 2 additions & 2 deletions base/special/ahavercosf/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{{alias}}( x )
Computes the inverse half-value versed cosine of a
single-precision floating-point number.
Computes the inverse half-value versed cosine of a single-
precision floating-point number.

The inverse half-value versed cosine is defined as `2*acos(sqrt(x))`.

Expand Down
2 changes: 1 addition & 1 deletion base/special/ahavercosf/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2019 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion base/special/ahavercosf/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2019 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif

/**
* Compute the inverse half-value versed cosine of a single-precision floating-point number.
* Computes the inverse half-value versed cosine of a single-precision floating-point number.
*/
float stdlib_base_ahavercosf( const float x );

Expand Down
2 changes: 1 addition & 1 deletion base/special/ahavercosf/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion base/special/ahavercosf/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
* // returns NaN
*/
function ahavercosf( x ) {
return float64ToFloat32( float64ToFloat32( 2.0 ) * acosf( sqrtf( x ) ) );
return float64ToFloat32( 2.0 * acosf( sqrtf( x ) ) );
}


Expand Down
2 changes: 1 addition & 1 deletion base/special/ahavercosf/lib/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
// MAIN //

/**
* Compute the inverse half-value versed cosine of a single-precision floating-point number.
* Computes the inverse half-value versed cosine of a single-precision floating-point number.
*
* @private
* @param {number} x - input value
Expand Down
4 changes: 2 additions & 2 deletions base/special/ahavercosf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "stdlib/math/base/special/sqrtf.h"

/**
* Compute the inverse half value versed cosine of a single-precision floating-point number.
* Computes the inverse half value versed cosine of a single-precision floating-point number.
*
* @param x input value
* @return output value
* @return output value
*
* @example
* float out = stdlib_base_ahavercosf( 0.0f );
Expand Down
4 changes: 2 additions & 2 deletions base/special/ahavercosf/test/fixtures/julia/runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# @license Apache-2.0
#
# Copyright (c) 2018 The Stdlib Authors.
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,5 +66,5 @@ x = range( 0.0, stop = 1.0, length = 2003 );
gen( x, "data.json" );

# Generate fixture data for small positive values:
x = range( 1e-200, stop = 1e-208, length = 2003 );
x = range( 1e-20, stop = 1e-28, length = 2003 );
gen( x, "small_positive.json" );

Large diffs are not rendered by default.

Loading

0 comments on commit 166c5fe

Please sign in to comment.