Skip to content

Commit 3a9fb60

Browse files
committed
Auto-generated commit
1 parent ec1dfba commit 3a9fb60

File tree

21 files changed

+1376
-17
lines changed

21 files changed

+1376
-17
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ indent_style = tab
121121
[*.{md,md.txt}]
122122
indent_style = space
123123
indent_size = 4
124-
trim_trailing_whitespace = false
124+
trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim.
125125
126126
# Set properties for `usage.txt` files:
127127
[usage.txt]

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,63 @@
22

33
> Package changelog.
44
5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2024-12-20)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`daf43b2`](https://github.com/stdlib-js/stdlib/commit/daf43b2052a0ad89fa4c72caee6d7caedcc4cc38) - add C implementation for `stats/base/dists/triangular/mode` [(#4008)](https://github.com/stdlib-js/stdlib/pull/4008)
14+
15+
</section>
16+
17+
<!-- /.features -->
18+
19+
<section class="issues">
20+
21+
### Closed Issues
22+
23+
This release closes the following issue:
24+
25+
[#3819](https://github.com/stdlib-js/stdlib/issues/3819)
26+
27+
</section>
28+
29+
<!-- /.issues -->
30+
31+
<section class="commits">
32+
33+
### Commits
34+
35+
<details>
36+
37+
- [`daf43b2`](https://github.com/stdlib-js/stdlib/commit/daf43b2052a0ad89fa4c72caee6d7caedcc4cc38) - **feat:** add C implementation for `stats/base/dists/triangular/mode` [(#4008)](https://github.com/stdlib-js/stdlib/pull/4008) _(by JoyBoy, Philipp Burckhardt)_
38+
39+
</details>
40+
41+
</section>
42+
43+
<!-- /.commits -->
44+
45+
<section class="contributors">
46+
47+
### Contributors
48+
49+
A total of 2 people contributed to this release. Thank you to the following contributors:
50+
51+
- JoyBoy
52+
- Philipp Burckhardt
53+
54+
</section>
55+
56+
<!-- /.contributors -->
57+
58+
</section>
59+
60+
<!-- /.release -->
61+
562
<section class="release" id="v0.2.2">
663

764
## 0.2.2 (2024-07-27)

CONTRIBUTORS

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#
33
# Contributors listed in alphabetical order.
44

5+
Aadish Jain <jain.aadishj@gmail.com>
56
Aayush Khanna <aayushiitbhu23@gmail.com>
67
Abhijit Raut <abhijitmraut8010@gmail.com>
78
Adarsh Palaskar <adarshpalaskar99@gmail.com>
89
Aditya Sapra <adityaework@gmail.com>
910
Ahmed Atwa <Ahmedatwa866@yahoo.com>
1011
Ahmed Kashkoush <ahmedkashkoush464@gmail.com>
12+
Ahmed Khaled <kahmd1444@gmail.com>
1113
Aleksandr <112382387+alextes90@users.noreply.github.com>
1214
Ali Salesi <ali_sal1381@yahoo.com>
1315
Aman Bhansali <bhansali.1@iitj.ac.in>
@@ -24,6 +26,7 @@ Dan Rose <danoftheroses@gmail.com>
2426
Daniel Killenberger <daniel.killenberger@gmail.com>
2527
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
2628
Debashis Maharana <debashismaharana7854@gmail.com>
29+
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
2730
Dominic Lim <46486515+domlimm@users.noreply.github.com>
2831
Dominik Moritz <domoritz@gmail.com>
2932
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
@@ -46,11 +49,10 @@ Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
4649
Joris Labie <joris.labie1@gmail.com>
4750
Justin Dennison <justin1dennison@gmail.com>
4851
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
49-
Khaldon <kahmd1444@gmail.com>
5052
Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
5153
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
5254
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
53-
Lovelin <100030865+lovelindhoni@users.noreply.github.com>
55+
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
5456
Manik Sharma <maniksharma.rke@gmail.com>
5557
Manvith M <148960168+manvith2003@users.noreply.github.com>
5658
Marcus Fantham <mfantham@users.noreply.github.com>
@@ -61,6 +63,7 @@ Mohammad Kaif <mdkaifprofession@gmail.com>
6163
Momtchil Momtchev <momtchil@momtchev.com>
6264
Muhammad Haris <harriskhan047@outlook.com>
6365
Naresh Jagadeesan <naresh.naresh000@gmail.com>
66+
Naveen Kumar <stupiddint@gmail.com>
6467
Neeraj Pathak <neerajrpathak710@gmail.com>
6568
Nishant Shinde <97207366+nishant-s7@users.noreply.github.com>
6669
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
@@ -71,10 +74,10 @@ Ori Miles <97595296+orimiles5@users.noreply.github.com>
7174
Philipp Burckhardt <pburckhardt@outlook.com>
7275
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
7376
Pranav Goswami <goswami.4@iitj.ac.in>
74-
Praneki <97080887+PraneGIT@users.noreply.github.com>
75-
Pratik <97464067+Pratik772846@users.noreply.github.com>
77+
Pranjal Jha <97080887+PraneGIT@users.noreply.github.com>
78+
Pratik Singh <97464067+Pratik772846@users.noreply.github.com>
7679
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
77-
Priyansh <88396544+itsspriyansh@users.noreply.github.com>
80+
Priyansh Prajapati <88396544+itsspriyansh@users.noreply.github.com>
7881
Priyanshu Agarwal <113460573+AgPriyanshu18@users.noreply.github.com>
7982
Pushpendra Chandravanshi <pushpendrachandravanshi4@gmail.com>
8083
Raunak Kumar Gupta <raunakmodanwal321@gmail.com>
@@ -93,7 +96,7 @@ Sarthak Paandey <145528240+SarthakPaandey@users.noreply.github.com>
9396
Saurabh Singh <saurabhsraghuvanshi@gmail.com>
9497
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
9598
Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
96-
Shivam <11shivam00@gmail.com>
99+
Shivam Ahir <11shivam00@gmail.com>
97100
Shraddheya Shendre <shendreshraddheya@gmail.com>
98101
Shubh Mehta <93862397+Shubh942@users.noreply.github.com>
99102
Shubham Mishra <shubh622005@gmail.com>
@@ -112,10 +115,10 @@ UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
112115
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
113116
Varad Gupta <varadgupta21@gmail.com>
114117
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
118+
Vivek maurya <155618190+vivekmaurya001@users.noreply.github.com>
115119
Xiaochuan Ye <tap91624@gmail.com>
116120
Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
117121
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
118-
naveen <stupiddint@gmail.com>
119122
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
120123
rainn <88160429+AmCodesLame@users.noreply.github.com>
121124
rei2hu <reimu@reimu.ws>

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,100 @@ for ( i = 0; i < 10; i++ ) {
172172

173173
<!-- /.examples -->
174174

175+
<!-- C interface documentation. -->
176+
177+
* * *
178+
179+
<section class="c">
180+
181+
## C APIs
182+
183+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
184+
185+
<section class="intro">
186+
187+
</section>
188+
189+
<!-- /.intro -->
190+
191+
<!-- C usage documentation. -->
192+
193+
<section class="usage">
194+
195+
### Usage
196+
197+
```c
198+
#include "stdlib/stats/base/dists/triangular/mode.h"
199+
```
200+
201+
#### stdlib_base_dists_triangular_mode( a, b, c )
202+
203+
Returns the [mode][mode] of a [triangular][triangular-distribution] distribution.
204+
205+
```c
206+
double out = stdlib_base_dists_triangular_mode( 0.0, 1.0, 0.5 );
207+
// returns 0.5
208+
```
209+
210+
The function accepts the following arguments:
211+
212+
- **a**: `[in] double` minimum support.
213+
- **b**: `[in] double` maximum support.
214+
- **c**: `[in] double` mode.
215+
216+
```c
217+
double stdlib_base_dists_triangular_mode( const double a, const double b, const double c );
218+
```
219+
220+
</section>
221+
222+
<!-- /.usage -->
223+
224+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
225+
226+
<section class="notes">
227+
228+
</section>
229+
230+
<!-- /.notes -->
231+
232+
<!-- C API usage examples. -->
233+
234+
<section class="examples">
235+
236+
### Examples
237+
238+
```c
239+
#include "stdlib/stats/base/dists/triangular/mode.h"
240+
#include <stdlib.h>
241+
#include <stdio.h>
242+
243+
static double random_uniform( const double min, const double max ) {
244+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
245+
return min + ( v*(max-min) );
246+
}
247+
248+
int main( void ) {
249+
double a;
250+
double b;
251+
double c;
252+
double y;
253+
int i;
254+
255+
for ( i = 0; i < 25; i++ ) {
256+
a = random_uniform( 0.0, 10.0 );
257+
b = random_uniform( 0.0, 10.0 ) + a;
258+
c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
259+
y = stdlib_base_dists_triangular_mode( a, b, c );
260+
printf( "a: %lf, b: %lf, c: %lf, M(X;a,b,c): %lf\n", a, b, c, y );
261+
}
262+
}
263+
```
264+
265+
</section>
266+
267+
<!-- /.examples -->
268+
175269
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
176270

177271
<section class="references">

benchmark/benchmark.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,36 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24+
var Float64Array = require( '@stdlib/array-float64' );
2425
var randu = require( '@stdlib/random-base-randu' );
2526
var isnan = require( '@stdlib/math-base-assert-is-nan' );
26-
var EPS = require( '@stdlib/constants-float64-eps' );
2727
var pkg = require( './../package.json' ).name;
2828
var mode = require( './../lib' );
2929

3030

3131
// MAIN //
3232

3333
bench( pkg, function benchmark( b ) {
34-
var min;
35-
var max;
34+
var bnd;
35+
var len;
36+
var a;
3637
var c;
3738
var y;
3839
var i;
3940

41+
len = 100;
42+
a = new Float64Array( len );
43+
bnd = new Float64Array( len );
44+
c = new Float64Array( len );
45+
for ( i = 0; i < len; i++ ) {
46+
a[ i ] = randu() * 20.0;
47+
bnd[ i ] = ( randu() * 20.0 ) + a[ i ];
48+
c[ i ] = ( randu() * ( bnd[i] - a[i] ) ) + a[i];
49+
}
50+
4051
b.tic();
4152
for ( i = 0; i < b.iterations; i++ ) {
42-
min = ( randu()*10.0 );
43-
max = ( randu()*10.0 ) + min + EPS;
44-
c = ( ( max - min ) * randu() ) + min;
45-
y = mode( min, max, c );
53+
y = mode( a[i % len], bnd[i % len], c[i % len] );
4654
if ( isnan( y ) ) {
4755
b.fail( 'should not return NaN' );
4856
}

benchmark/benchmark.native.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench-harness' );
25+
var Float64Array = require( '@stdlib/array-float64' );
26+
var randu = require( '@stdlib/random-base-randu' );
27+
var isnan = require( '@stdlib/math-base-assert-is-nan' );
28+
var tryRequire = require( '@stdlib/utils-try-require' );
29+
var pkg = require( './../package.json' ).name;
30+
31+
32+
// VARIABLES //
33+
34+
var mode = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( mode instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var bnd;
44+
var len;
45+
var a;
46+
var c;
47+
var y;
48+
var i;
49+
50+
len = 100;
51+
a = new Float64Array( len );
52+
bnd = new Float64Array( len );
53+
c = new Float64Array( len );
54+
for ( i = 0; i < len; i++ ) {
55+
a[ i ] = ( randu() * 20.0 ); // Lower bound
56+
bnd[ i ] = ( randu() * 20.0 ) + a[ i ]; // Upper bound
57+
c[ i ] = ( randu() * ( bnd[i] - a[i] ) ) + a[i]; // Mode
58+
}
59+
60+
b.tic();
61+
for ( i = 0; i < b.iterations; i++ ) {
62+
y = mode( a[ i % len ], bnd[ i % len ], c[ i % len ] );
63+
if ( isnan( y ) ) {
64+
b.fail( 'should not return NaN' );
65+
}
66+
}
67+
b.toc();
68+
if ( isnan( y ) ) {
69+
b.fail( 'should not return NaN' );
70+
}
71+
b.pass( 'benchmark finished' );
72+
b.end();
73+
});

0 commit comments

Comments
 (0)