From 1c1cb73489e49e45413d8ef9d8cc96363393a447 Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Tue, 17 Dec 2024 20:09:30 +0530
Subject: [PATCH 01/10] feat: add C implementation for triangular variance
---
.../base/dists/triangular/variance/README.md | 98 ++++++++++
.../variance/benchmark/benchmark.js | 18 +-
.../variance/benchmark/benchmark.native.js | 64 +++++++
.../triangular/variance/benchmark/c/Makefile | 146 +++++++++++++++
.../variance/benchmark/c/benchmark.c | 142 +++++++++++++++
.../dists/triangular/variance/binding.gyp | 170 ++++++++++++++++++
.../triangular/variance/examples/c/Makefile | 146 +++++++++++++++
.../triangular/variance/examples/c/example.c | 42 +++++
.../dists/triangular/variance/include.gypi | 53 ++++++
.../stats/base/dists/triangular/variance.h | 47 +++++
.../dists/triangular/variance/lib/native.js | 68 +++++++
.../dists/triangular/variance/manifest.json | 76 ++++++++
.../dists/triangular/variance/package.json | 3 +
.../dists/triangular/variance/src/Makefile | 70 ++++++++
.../dists/triangular/variance/src/addon.c | 23 +++
.../base/dists/triangular/variance/src/main.c | 44 +++++
.../triangular/variance/test/test.native.js | 108 +++++++++++
17 files changed, 1313 insertions(+), 5 deletions(-)
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/lib/native.js
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/manifest.json
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/Makefile
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/addon.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/triangular/variance/test/test.native.js
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
index c802a1d9e5c4..1610e5f1645d 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
@@ -141,6 +141,104 @@ for ( i = 0; i < 10; i++ ) {
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/stats/base/dists/triangular/variance.h"
+```
+
+#### stdlib_base_dists_triangular_variance( a, b, c )
+
+Returns the variance of a triangular distribution.
+
+```c
+double out = stdlib_base_dists_triangular_variance( 0.0, 1.0, 0.5 );
+// returns ~0.056
+```
+
+The function accepts the following arguments:
+
+- **a**: `[in] double` minimum support.
+- **b**: `[in] double` maximum support.
+- **c**: `[in] double` mode.
+
+```c
+double stdlib_base_dists_triangular_variance( const double a, const double b, const double c );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/stats/base/dists/triangular/variance.h"
+#include
+#include
+
+static double random_uniform( const double min, const double max ) {
+ double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
+ return min + ( v*(max-min) );
+}
+
+int main( void ) {
+ double a;
+ double b;
+ double c;
+ double y;
+ int i;
+
+ for ( i = 0; i < 25; i++ ) {
+ a = random_uniform( 0.0, 10.0 );
+ b = random_uniform( 0.0, 10.0 ) + a;
+ c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
+ y = stdlib_base_dists_triangular_variance( a, b, c );
+ printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
+ }
+}
+```
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.js
index 806586d035eb..dcebaa3ef732 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.js
@@ -21,9 +21,9 @@
// MODULES //
var bench = require( '@stdlib/bench' );
+var Float64Array = require( '@stdlib/array/float64' );
var randu = require( '@stdlib/random/base/randu' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
-var EPS = require( '@stdlib/constants/float64/eps' );
var pkg = require( './../package.json' ).name;
var variance = require( './../lib' );
@@ -34,15 +34,23 @@ bench( pkg, function benchmark( b ) {
var mode;
var min;
var max;
+ var len;
var y;
var i;
+ len = 100;
+ min = new Float64Array( len );
+ max = new Float64Array( len );
+ mode = new Float64Array( len );
+ for ( i = 0; i < len; i++ ) {
+ min[ i ] = ( randu() * 10.0 );
+ max[ i ] = ( randu() * 10.0 ) + min[ i ];
+ mode[ i ] = min[ i ] + ( randu() * ( max[ i ] - min[ i ] ) );
+ }
+
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- min = ( randu()*10.0 );
- max = ( randu()*10.0 ) + min + EPS;
- mode = ( ( max - min ) * randu() ) + min;
- y = variance( min, max, mode );
+ y = variance( min[ i % len ], max[ i % len ], mode[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
new file mode 100644
index 000000000000..f6d1411bbca0
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
@@ -0,0 +1,64 @@
+/**
+* @license Apache-2.0
+*
+* 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.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var Float64Array = require( '@stdlib/array/float64' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pkg = require( './../package.json' ).name;
+var variance = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg, function benchmark( b ) {
+ var mode;
+ var min;
+ var max;
+ var len;
+ var y;
+ var i;
+
+ len = 100;
+ min = new Float64Array( len );
+ max = new Float64Array( len );
+ mode = new Float64Array( len );
+ for ( i = 0; i < len; i++ ) {
+ min[ i ] = ( randu() * 10.0 );
+ max[ i ] = ( randu() * 10.0 ) + min[ i ];
+ mode[ i ] = min[ i ] + ( randu() * ( max[ i ] - min[ i ] ) );
+ }
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = variance( min[ i % len ], max[ i % len ], mode[ i % len ] );
+ if ( isnan( y ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile
new file mode 100644
index 000000000000..f69e9da2b4d3
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile
@@ -0,0 +1,146 @@
+#/
+# @license Apache-2.0
+#
+# 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#/
+
+# VARIABLES #
+
+ifndef VERBOSE
+ QUIET := @
+else
+ QUIET :=
+endif
+
+# Determine the OS ([1][1], [2][2]).
+#
+# [1]: https://en.wikipedia.org/wiki/Uname#Examples
+# [2]: http://stackoverflow.com/a/27776822/2225624
+OS ?= $(shell uname)
+ifneq (, $(findstring MINGW,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring MSYS,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring CYGWIN,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring Windows_NT,$(OS)))
+ OS := WINNT
+endif
+endif
+endif
+endif
+
+# Define the program used for compiling C source files:
+ifdef C_COMPILER
+ CC := $(C_COMPILER)
+else
+ CC := gcc
+endif
+
+# Define the command-line options when compiling C files:
+CFLAGS ?= \
+ -std=c99 \
+ -O3 \
+ -Wall \
+ -pedantic
+
+# 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
+ifeq ($(OS), WINNT)
+ fPIC ?=
+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
+
+
+# RULES #
+
+#/
+# Compiles source files.
+#
+# @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
+
+#/
+# 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) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)
+
+#/
+# Runs compiled benchmarks.
+#
+# @example
+# make run
+#/
+run: $(c_targets)
+ $(QUIET) ./$<
+
+.PHONY: run
+
+#/
+# Removes generated files.
+#
+# @example
+# make clean
+#/
+clean:
+ $(QUIET) -rm -f *.o *.out
+
+.PHONY: clean
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
new file mode 100644
index 000000000000..3e7f4f08b49b
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
@@ -0,0 +1,142 @@
+/**
+* @license Apache-2.0
+*
+* 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.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "stdlib/stats/base/dists/triangular/variance.h"
+#include
+#include
+#include
+#include
+#include
+
+#define NAME "triangular-variance"
+#define ITERATIONS 1000000
+#define REPEATS 3
+
+/**
+* Prints the TAP version.
+*/
+static void print_version( void ) {
+ printf( "TAP version 13\n" );
+}
+
+/**
+* Prints the TAP summary.
+*
+* @param total total number of tests
+* @param passing total number of passing tests
+*/
+static void print_summary( int total, int passing ) {
+ printf( "#\n" );
+ printf( "1..%d\n", total ); // TAP plan
+ printf( "# total %d\n", total );
+ printf( "# pass %d\n", passing );
+ printf( "#\n" );
+ printf( "# ok\n" );
+}
+
+/**
+* Prints benchmarks results.
+*
+* @param elapsed elapsed time in seconds
+*/
+static void print_results( double elapsed ) {
+ double rate = (double)ITERATIONS / elapsed;
+ printf( " ---\n" );
+ printf( " iterations: %d\n", ITERATIONS );
+ printf( " elapsed: %0.9f\n", elapsed );
+ printf( " rate: %0.9f\n", rate );
+ printf( " ...\n" );
+}
+
+/**
+* Returns a clock time.
+*
+* @return clock time
+*/
+static double tic( void ) {
+ struct timeval now;
+ gettimeofday( &now, NULL );
+ return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
+}
+
+/**
+* Generates a random number on the interval [min,max).
+*
+* @param min minimum value (inclusive)
+* @param max maximum value (exclusive)
+* @return random number
+*/
+static double random_uniform( const double min, const double max ) {
+ double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
+ return min + ( v*(max-min) );
+}
+
+/**
+* Runs a benchmark.
+*
+* @return elapsed time in seconds
+*/
+static double benchmark( void ) {
+ double elapsed;
+ double a[ 100 ];
+ double b[ 100 ];
+ double c[ 100 ];
+ double y;
+ double t;
+ int i;
+
+ for ( i = 0; i < 100; i++ ) {
+ a[ i ] = random_uniform( -20.0, 0.0 );
+ b[ i ] = random_uniform( a[ i ], a[ i ]+40.0 );
+ c[ i ] = random_uniform( a[ i ], b[ i ] );
+ }
+
+ t = tic();
+ for ( i = 0; i < ITERATIONS; i++ ) {
+ y = stdlib_base_dists_triangular_variance( a[ i%100 ], b[ i%100 ], c[ i%100 ] );
+ if ( y != y ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( y != y ) {
+ printf( "should not return NaN\n" );
+ }
+ return elapsed;
+}
+
+/**
+* Main execution sequence.
+*/
+int main( void ) {
+ double elapsed;
+ int i;
+
+ // Use the current time to seed the random number generator:
+ srand( time( NULL ) );
+
+ print_version();
+ for ( i = 0; i < REPEATS; i++ ) {
+ printf( "# c::%s\n", NAME );
+ elapsed = benchmark();
+ print_results( elapsed );
+ printf( "ok %d benchmark finished\n", i+1 );
+ }
+ print_summary( REPEATS, REPEATS );
+}
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp
new file mode 100644
index 000000000000..ec3992233442
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp
@@ -0,0 +1,170 @@
+# @license Apache-2.0
+#
+# 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A `.gyp` file for building a Node.js native add-on.
+#
+# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
+# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
+{
+ # List of files to include in this file:
+ 'includes': [
+ './include.gypi',
+ ],
+
+ # Define variables to be used throughout the configuration for all targets:
+ 'variables': {
+ # Target name should match the add-on export name:
+ 'addon_target_name%': 'addon',
+
+ # Set variables based on the host OS:
+ 'conditions': [
+ [
+ 'OS=="win"',
+ {
+ # Define the object file suffix:
+ 'obj': 'obj',
+ },
+ {
+ # Define the object file suffix:
+ 'obj': 'o',
+ }
+ ], # end condition (OS=="win")
+ ], # end conditions
+ }, # end variables
+
+ # Define compile targets:
+ 'targets': [
+
+ # Target to generate an add-on:
+ {
+ # The target name should match the add-on export name:
+ 'target_name': '<(addon_target_name)',
+
+ # Define dependencies:
+ 'dependencies': [],
+
+ # Define directories which contain relevant include headers:
+ 'include_dirs': [
+ # Local include directory:
+ '<@(include_dirs)',
+ ],
+
+ # List of source files:
+ 'sources': [
+ '<@(src_files)',
+ ],
+
+ # Settings which should be applied when a target's object files are used as linker input:
+ 'link_settings': {
+ # Define libraries:
+ 'libraries': [
+ '<@(libraries)',
+ ],
+
+ # Define library directories:
+ 'library_dirs': [
+ '<@(library_dirs)',
+ ],
+ },
+
+ # C/C++ compiler flags:
+ 'cflags': [
+ # Enable commonly used warning options:
+ '-Wall',
+
+ # Aggressive optimization:
+ '-O3',
+ ],
+
+ # C specific compiler flags:
+ 'cflags_c': [
+ # Specify the C standard to which a program is expected to conform:
+ '-std=c99',
+ ],
+
+ # C++ specific compiler flags:
+ 'cflags_cpp': [
+ # Specify the C++ standard to which a program is expected to conform:
+ '-std=c++11',
+ ],
+
+ # Linker flags:
+ 'ldflags': [],
+
+ # Apply conditions based on the host OS:
+ 'conditions': [
+ [
+ 'OS=="mac"',
+ {
+ # Linker flags:
+ 'ldflags': [
+ '-undefined dynamic_lookup',
+ '-Wl,-no-pie',
+ '-Wl,-search_paths_first',
+ ],
+ },
+ ], # end condition (OS=="mac")
+ [
+ 'OS!="win"',
+ {
+ # C/C++ flags:
+ 'cflags': [
+ # Generate platform-independent code:
+ '-fPIC',
+ ],
+ },
+ ], # end condition (OS!="win")
+ ], # end conditions
+ }, # end target <(addon_target_name)
+
+ # Target to copy a generated add-on to a standard location:
+ {
+ 'target_name': 'copy_addon',
+
+ # Declare that the output of this target is not linked:
+ 'type': 'none',
+
+ # Define dependencies:
+ 'dependencies': [
+ # Require that the add-on be generated before building this target:
+ '<(addon_target_name)',
+ ],
+
+ # Define a list of actions:
+ 'actions': [
+ {
+ 'action_name': 'copy_addon',
+ 'message': 'Copying addon...',
+
+ # Explicitly list the inputs in the command-line invocation below:
+ 'inputs': [],
+
+ # Declare the expected outputs:
+ 'outputs': [
+ '<(addon_output_dir)/<(addon_target_name).node',
+ ],
+
+ # Define the command-line invocation:
+ 'action': [
+ 'cp',
+ '<(PRODUCT_DIR)/<(addon_target_name).node',
+ '<(addon_output_dir)/<(addon_target_name).node',
+ ],
+ },
+ ], # end actions
+ }, # end target copy_addon
+ ], # end targets
+}
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile
new file mode 100644
index 000000000000..6aed70daf167
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile
@@ -0,0 +1,146 @@
+#/
+# @license Apache-2.0
+#
+# 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#/
+
+# VARIABLES #
+
+ifndef VERBOSE
+ QUIET := @
+else
+ QUIET :=
+endif
+
+# Determine the OS ([1][1], [2][2]).
+#
+# [1]: https://en.wikipedia.org/wiki/Uname#Examples
+# [2]: http://stackoverflow.com/a/27776822/2225624
+OS ?= $(shell uname)
+ifneq (, $(findstring MINGW,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring MSYS,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring CYGWIN,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring Windows_NT,$(OS)))
+ OS := WINNT
+endif
+endif
+endif
+endif
+
+# Define the program used for compiling C source files:
+ifdef C_COMPILER
+ CC := $(C_COMPILER)
+else
+ CC := gcc
+endif
+
+# Define the command-line options when compiling C files:
+CFLAGS ?= \
+ -std=c99 \
+ -O3 \
+ -Wall \
+ -pedantic
+
+# 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
+ifeq ($(OS), WINNT)
+ fPIC ?=
+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 := example.out
+
+
+# RULES #
+
+#/
+# Compiles source files.
+#
+# @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
+
+#/
+# 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) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)
+
+#/
+# Runs compiled examples.
+#
+# @example
+# make run
+#/
+run: $(c_targets)
+ $(QUIET) ./$<
+
+.PHONY: run
+
+#/
+# Removes generated files.
+#
+# @example
+# make clean
+#/
+clean:
+ $(QUIET) -rm -f *.o *.out
+
+.PHONY: clean
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
new file mode 100644
index 000000000000..d7cfaf490d98
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
@@ -0,0 +1,42 @@
+/**
+* @license Apache-2.0
+*
+* 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.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "stdlib/stats/base/dists/triangular/variance.h"
+#include
+#include
+
+static double random_uniform( const double min, const double max ) {
+ double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
+ return min + ( v*(max-min) );
+}
+
+int main( void ) {
+ double a;
+ double b;
+ double c;
+ double y;
+ int i;
+
+ for ( i = 0; i < 25; i++ ) {
+ a = random_uniform( 0.0, 10.0 );
+ b = random_uniform( 0.0, 10.0 ) + a;
+ c = a + ( random_uniform( 0.0, 1.0 ) * ( b - a ) );
+ y = stdlib_base_dists_triangular_variance( a, b, c );
+ printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
+ }
+}
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi
new file mode 100644
index 000000000000..575cb043c0bf
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi
@@ -0,0 +1,53 @@
+# @license Apache-2.0
+#
+# 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A GYP include file for building a Node.js native add-on.
+#
+# Main documentation:
+#
+# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
+# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
+{
+ # Define variables to be used throughout the configuration for all targets:
+ 'variables': {
+ # Source directory:
+ 'src_dir': './src',
+
+ # Include directories:
+ 'include_dirs': [
+ '
Date: Wed, 18 Dec 2024 12:07:23 +0530
Subject: [PATCH 02/10] fix: consistency in example and readme with some minor
changes
---
.../base/dists/triangular/variance/benchmark/c/benchmark.c | 6 +++---
.../base/dists/triangular/variance/examples/c/example.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
index 3e7f4f08b49b..d79fbdda3f5e 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
@@ -101,9 +101,9 @@ static double benchmark( void ) {
int i;
for ( i = 0; i < 100; i++ ) {
- a[ i ] = random_uniform( -20.0, 0.0 );
- b[ i ] = random_uniform( a[ i ], a[ i ]+40.0 );
- c[ i ] = random_uniform( a[ i ], b[ i ] );
+ a[ i ] = rand_double() * 20.0; // Lower bound
+ b[ i ] = ( rand_double() * 20.0 ) + a[ i ]; // Upper bound
+ c[ i ] = ( rand_double() * ( b[i] - a[i] ) ) + a[i]; // Mode
}
t = tic();
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
index d7cfaf490d98..23ceb07cd511 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
@@ -35,7 +35,7 @@ int main( void ) {
for ( i = 0; i < 25; i++ ) {
a = random_uniform( 0.0, 10.0 );
b = random_uniform( 0.0, 10.0 ) + a;
- c = a + ( random_uniform( 0.0, 1.0 ) * ( b - a ) );
+ c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
y = stdlib_base_dists_triangular_variance( a, b, c );
printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
}
From 720de120305ec60f0d0f62b7f85bcb8e6b6066fe Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Wed, 18 Dec 2024 12:10:09 +0530
Subject: [PATCH 03/10] chore: added rand_double function
---
.../triangular/variance/benchmark/c/benchmark.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
index d79fbdda3f5e..27773be12837 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
@@ -75,15 +75,13 @@ static double tic( void ) {
}
/**
-* Generates a random number on the interval [min,max).
+* Generates a random number on the interval [0,20).
*
-* @param min minimum value (inclusive)
-* @param max maximum value (exclusive)
-* @return random number
+* @return random number
*/
-static double random_uniform( const double min, const double max ) {
- double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
- return min + ( v*(max-min) );
+static double rand_double( void ) {
+ int r = rand();
+ return 20.0*(double)r / ( (double)RAND_MAX + 1.0 );
}
/**
From 067f2458843ad8314a855bd1dc002280ad3a1618 Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Thu, 19 Dec 2024 11:31:12 +0530
Subject: [PATCH 04/10] fix: added tab indentation in files
---
.../variance/benchmark/c/benchmark.c | 12 ++++----
.../triangular/variance/examples/c/example.c | 28 +++++++++----------
.../base/dists/triangular/variance/src/main.c | 16 +++++------
3 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
index 27773be12837..86bd7dd11a2c 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
@@ -37,8 +37,8 @@ static void print_version( void ) {
/**
* Prints the TAP summary.
*
-* @param total total number of tests
-* @param passing total number of passing tests
+* @param total total number of tests
+* @param passing total number of passing tests
*/
static void print_summary( int total, int passing ) {
printf( "#\n" );
@@ -80,8 +80,8 @@ static double tic( void ) {
* @return random number
*/
static double rand_double( void ) {
- int r = rand();
- return 20.0*(double)r / ( (double)RAND_MAX + 1.0 );
+ int r = rand();
+ return 20.0*(double)r / ( (double)RAND_MAX + 1.0 );
}
/**
@@ -100,8 +100,8 @@ static double benchmark( void ) {
for ( i = 0; i < 100; i++ ) {
a[ i ] = rand_double() * 20.0; // Lower bound
- b[ i ] = ( rand_double() * 20.0 ) + a[ i ]; // Upper bound
- c[ i ] = ( rand_double() * ( b[i] - a[i] ) ) + a[i]; // Mode
+ b[ i ] = ( rand_double() * 20.0 ) + a[ i ]; // Upper bound
+ c[ i ] = ( rand_double() * ( b[i] - a[i] ) ) + a[i]; // Mode
}
t = tic();
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
index 23ceb07cd511..e8446e3ebe02 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
@@ -21,22 +21,22 @@
#include
static double random_uniform( const double min, const double max ) {
- double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
- return min + ( v*(max-min) );
+ double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
+ return min + ( v*(max-min) );
}
int main( void ) {
- double a;
- double b;
- double c;
- double y;
- int i;
+ double a;
+ double b;
+ double c;
+ double y;
+ int i;
- for ( i = 0; i < 25; i++ ) {
- a = random_uniform( 0.0, 10.0 );
- b = random_uniform( 0.0, 10.0 ) + a;
- c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
- y = stdlib_base_dists_triangular_variance( a, b, c );
- printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
- }
+ for ( i = 0; i < 25; i++ ) {
+ a = random_uniform( 0.0, 10.0 );
+ b = random_uniform( 0.0, 10.0 ) + a;
+ c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
+ y = stdlib_base_dists_triangular_variance( a, b, c );
+ printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
+ }
}
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
index 37100b906a17..201909dc8200 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
@@ -22,23 +22,23 @@
/**
* Returns the variance of a triangular distribution.
*
-* @param a minimum support
-* @param b maximum support
-* @param c mode
-* @return variance
+* @param a minimum support
+* @param b maximum support
+* @param c mode
+* @return variance
*
* @example
* double y = stdlib_base_dists_triangular_variance( 0.0, 1.0, 0.5 );
* // returns ~0.042
*/
double stdlib_base_dists_triangular_variance( const double a, const double b, const double c ) {
- if (
+ if (
stdlib_base_is_nan( a ) ||
stdlib_base_is_nan( b ) ||
stdlib_base_is_nan( c ) ||
!( a <= c && c <= b )
) {
- return 0.0 / 0.0; // NaN
- }
- return ( ( a*a ) + ( b*b ) + ( c*c ) - ( a*b ) - ( a*c ) - ( b*c ) ) / 18.0;
+ return 0.0 / 0.0; // NaN
+ }
+ return ( ( a*a ) + ( b*b ) + ( c*c ) - ( a*b ) - ( a*c ) - ( b*c ) ) / 18.0;
}
From 1bcb889ee50b48aa54809044b4c77dd1a012b828 Mon Sep 17 00:00:00 2001
From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com>
Date: Fri, 3 Jan 2025 02:42:51 +0000
Subject: [PATCH 05/10] chore: update copyright years
---
.../dists/triangular/variance/benchmark/benchmark.native.js | 2 +-
.../stats/base/dists/triangular/variance/benchmark/c/Makefile | 2 +-
.../base/dists/triangular/variance/benchmark/c/benchmark.c | 2 +-
.../@stdlib/stats/base/dists/triangular/variance/binding.gyp | 2 +-
.../stats/base/dists/triangular/variance/examples/c/Makefile | 2 +-
.../stats/base/dists/triangular/variance/examples/c/example.c | 2 +-
.../@stdlib/stats/base/dists/triangular/variance/include.gypi | 2 +-
.../include/stdlib/stats/base/dists/triangular/variance.h | 2 +-
.../@stdlib/stats/base/dists/triangular/variance/lib/native.js | 2 +-
.../@stdlib/stats/base/dists/triangular/variance/src/Makefile | 2 +-
.../@stdlib/stats/base/dists/triangular/variance/src/addon.c | 2 +-
.../@stdlib/stats/base/dists/triangular/variance/src/main.c | 2 +-
.../stats/base/dists/triangular/variance/test/test.native.js | 2 +-
13 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
index f6d1411bbca0..6b42fba57cc3 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile
index f69e9da2b4d3..a4bd7b38fd74 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/Makefile
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
-# Copyright (c) 2024 The Stdlib Authors.
+# Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
index 86bd7dd11a2c..51c256b3eecf 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp
index ec3992233442..68a1ca11d160 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/binding.gyp
@@ -1,6 +1,6 @@
# @license Apache-2.0
#
-# Copyright (c) 2024 The Stdlib Authors.
+# Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile
index 6aed70daf167..25ced822f96a 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/Makefile
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
-# Copyright (c) 2024 The Stdlib Authors.
+# Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
index e8446e3ebe02..ee5554283813 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi
index 575cb043c0bf..ecfaf82a3279 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include.gypi
@@ -1,6 +1,6 @@
# @license Apache-2.0
#
-# Copyright (c) 2024 The Stdlib Authors.
+# Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
index 6c47748e6260..485f45526293 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/lib/native.js
index d948dd1fc5d4..66507e7b4b64 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/lib/native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/lib/native.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/Makefile
index bcf18aa46655..7733b6180cb4 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/Makefile
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/Makefile
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
-# Copyright (c) 2024 The Stdlib Authors.
+# Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/addon.c
index bd61580acc5a..a0dab4bac404 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/addon.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/addon.c
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
index 201909dc8200..3b25293b27ca 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/test/test.native.js
index 96d347ba4525..3bd7058a0e21 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/test/test.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/test/test.native.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2024 The Stdlib Authors.
+* Copyright (c) 2025 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.
From 2fb3a6fe428f0a1ff671a8a96f67cf08f2309b85 Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Wed, 8 Jan 2025 15:50:07 +0530
Subject: [PATCH 06/10] chore: fixs asked in review
---
.../stdlib/stats/base/dists/triangular/variance.h | 9 ---------
.../stats/base/dists/triangular/variance/src/main.c | 8 ++++----
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
index 485f45526293..235bb90819d6 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
@@ -28,15 +28,6 @@ extern "C" {
/**
* Returns the variance of a triangular distribution.
-*
-* The variance for a triangular distribution is computed as:
-*
-* variance = ( ( a*a ) + ( b*b ) + ( c*c ) - ( a*b ) - ( b*c ) - ( a*c ) ) / 18.0
-*
-* where:
-* - a is the minimum value,
-* - b is the maximum value, and
-* - c is the mode.
*/
double stdlib_base_dists_triangular_variance( const double a, const double b, const double c );
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
index 3b25293b27ca..2b1844fadb7a 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/src/main.c
@@ -22,10 +22,10 @@
/**
* Returns the variance of a triangular distribution.
*
-* @param a minimum support
-* @param b maximum support
-* @param c mode
-* @return variance
+* @param a minimum support
+* @param b maximum support
+* @param c mode
+* @return variance
*
* @example
* double y = stdlib_base_dists_triangular_variance( 0.0, 1.0, 0.5 );
From 6be619eee6f8df902a491bb61726dd7721308a34 Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Wed, 8 Jan 2025 16:04:48 +0530
Subject: [PATCH 07/10] chore: removed unwanted comment
---
.../base/dists/triangular/variance/benchmark/c/benchmark.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
index 51c256b3eecf..9672aa26ceaa 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c
@@ -99,9 +99,9 @@ static double benchmark( void ) {
int i;
for ( i = 0; i < 100; i++ ) {
- a[ i ] = rand_double() * 20.0; // Lower bound
- b[ i ] = ( rand_double() * 20.0 ) + a[ i ]; // Upper bound
- c[ i ] = ( rand_double() * ( b[i] - a[i] ) ) + a[i]; // Mode
+ a[ i ] = rand_double() * 20.0;
+ b[ i ] = ( rand_double() * 20.0 ) + a[ i ];
+ c[ i ] = ( rand_double() * ( b[i] - a[i] ) ) + a[i];
}
t = tic();
From 9f9cf25a0c62e8fbbd5ec9f7f739e7c8525f4d5e Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Thu, 9 Jan 2025 23:05:55 +0530
Subject: [PATCH 08/10] chore: removed unwanted comments
---
.../@stdlib/stats/base/dists/triangular/variance/README.md | 2 +-
.../stats/base/dists/triangular/variance/examples/c/example.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
index 1610e5f1645d..c5e0aa379dfd 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
@@ -224,7 +224,7 @@ int main( void ) {
for ( i = 0; i < 25; i++ ) {
a = random_uniform( 0.0, 10.0 );
b = random_uniform( 0.0, 10.0 ) + a;
- c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
+ c = a + (b - a) * random_uniform( 0.0, 1.0 );
y = stdlib_base_dists_triangular_variance( a, b, c );
printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
index ee5554283813..cdb1a470496e 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c
@@ -35,7 +35,7 @@ int main( void ) {
for ( i = 0; i < 25; i++ ) {
a = random_uniform( 0.0, 10.0 );
b = random_uniform( 0.0, 10.0 ) + a;
- c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
+ c = a + (b - a) * random_uniform( 0.0, 1.0 );
y = stdlib_base_dists_triangular_variance( a, b, c );
printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
}
From cf3dba8deafc46b593e051430bc95a33dec2dcf3 Mon Sep 17 00:00:00 2001
From: Philipp Burckhardt
Date: Fri, 10 Jan 2025 08:59:17 -0500
Subject: [PATCH 09/10] docs: add missing spaces and use full description
---
.../@stdlib/stats/base/dists/triangular/variance/README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
index c5e0aa379dfd..522852e6feb6 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/README.md
@@ -59,7 +59,7 @@ var variance = require( '@stdlib/stats/base/dists/triangular/variance' );
#### variance( a, b, c )
-Returns the [variance][variance] of a [triangular][triangular-distribution] distribution with minimum support `a`, maximum support`b`, and mode `c`.
+Returns the [variance][variance] of a [triangular][triangular-distribution] distribution with minimum support `a`, maximum support `b`, and mode `c`.
```javascript
var v = variance( 0.0, 1.0, 0.8 );
@@ -169,7 +169,7 @@ for ( i = 0; i < 10; i++ ) {
#### stdlib_base_dists_triangular_variance( a, b, c )
-Returns the variance of a triangular distribution.
+Returns the [variance][variance] of a [triangular][triangular-distribution] distribution with minimum support `a`, maximum support `b`, and mode `c`.
```c
double out = stdlib_base_dists_triangular_variance( 0.0, 1.0, 0.5 );
From a217188b1372356aa3b7ae553bb2144847e06876 Mon Sep 17 00:00:00 2001
From: Philipp Burckhardt
Date: Fri, 10 Jan 2025 09:01:17 -0500
Subject: [PATCH 10/10] chore: apply suggestions from code review
Signed-off-by: Philipp Burckhardt
---
.../dists/triangular/variance/benchmark/benchmark.native.js | 2 +-
.../include/stdlib/stats/base/dists/triangular/variance.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
index 6b42fba57cc3..88ab58c393fc 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/benchmark.native.js
@@ -30,7 +30,7 @@ var variance = require( './../lib' );
// MAIN //
-bench( pkg, function benchmark( b ) {
+bench( pkg+'::native', function benchmark( b ) {
var mode;
var min;
var max;
diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
index 235bb90819d6..7382da2a0fd0 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
+++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/variance/include/stdlib/stats/base/dists/triangular/variance.h
@@ -27,7 +27,7 @@ extern "C" {
#endif
/**
-* Returns the variance of a triangular distribution.
+* Returns the variance of a triangular distribution with minimum support `a`, maximum support `b`, and mode `c`.
*/
double stdlib_base_dists_triangular_variance( const double a, const double b, const double c );