Skip to content

Commit 8751dce

Browse files
committed
Auto-generated commit
1 parent 9f23af6 commit 8751dce

25 files changed

+1803
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-04-11)
7+
## Unreleased (2025-05-18)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`9b48575`](https://github.com/stdlib-js/stdlib/commit/9b48575a2670874e64b076f79ebd9989b43db5a0) - add C implementation for `math/base/special/heavisidef` [(#7022)](https://github.com/stdlib-js/stdlib/pull/7022)
1314
- [`a2133de`](https://github.com/stdlib-js/stdlib/commit/a2133de85c6de60892a54b387dbf7bd1ad58e0c8) - add `math/base/special/heavisidef` [(#3374)](https://github.com/stdlib-js/stdlib/pull/3374)
1415

1516
</section>
@@ -22,6 +23,7 @@
2223

2324
<details>
2425

26+
- [`9b48575`](https://github.com/stdlib-js/stdlib/commit/9b48575a2670874e64b076f79ebd9989b43db5a0) - **feat:** add C implementation for `math/base/special/heavisidef` [(#7022)](https://github.com/stdlib-js/stdlib/pull/7022) _(by Karan Anand, stdlib-bot)_
2527
- [`0395909`](https://github.com/stdlib-js/stdlib/commit/03959095fb9ffbe34ca9603b27c5204ce82d8c89) - **docs:** replace manual `for` loop in examples [(#6638)](https://github.com/stdlib-js/stdlib/pull/6638) _(by Harsh)_
2628
- [`630ddb7`](https://github.com/stdlib-js/stdlib/commit/630ddb777824b5f6e501fda6dadf4ce41dccb964) - **test:** replace equal with strictEqual _(by Karan Anand)_
2729
- [`a2133de`](https://github.com/stdlib-js/stdlib/commit/a2133de85c6de60892a54b387dbf7bd1ad58e0c8) - **feat:** add `math/base/special/heavisidef` [(#3374)](https://github.com/stdlib-js/stdlib/pull/3374) _(by Vivek Maurya, Athan Reines, stdlib-bot)_

CONTRIBUTORS

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,18 @@ Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
5151
EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
5252
Frank Kovacs <fran70kk@gmail.com>
5353
GK Bishnoi <gkishan1kyt@gmail.com>
54+
GURU PRASAD SHARMA <168292003+GURUPRASADSHARMA@users.noreply.github.com>
5455
Gaurav <gaurav70380@gmail.com>
5556
Gautam sharma <gautamkrishnasharma1@gmail.com>
57+
Girish Garg <garggirish2020@gmail.com>
5658
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
5759
Gunj Joshi <gunjjoshi8372@gmail.com>
5860
Gururaj Gurram <gururajgurram1512@gmail.com>
5961
Haroon Rasheed <51189276+haroon26@users.noreply.github.com>
60-
Harsh <149176984+hrshya@users.noreply.github.com>
62+
Harsh <harshyadav6078@gmail.com>
6163
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
6264
Harshita Kalani <harshitakalani02@gmail.com>
65+
Hemang Choudhary <coehemang@gmail.com>
6366
Hemant M Mehta <92446645+hemantmm@users.noreply.github.com>
6467
Hridyanshu <124202756+HRIDYANSHU054@users.noreply.github.com>
6568
Jaimin Godhani <112328542+Jai0401@users.noreply.github.com>
@@ -85,6 +88,7 @@ Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
8588
Krishnam Agarwal <83017176+888krishnam@users.noreply.github.com>
8689
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
8790
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
91+
Lalit Narayan Yadav <162928571+LalitNarayanYadav@users.noreply.github.com>
8892
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
8993
MANI <77221000+Eternity0207@users.noreply.github.com>
9094
Mahfuza Humayra Mohona <mhmohona@gmail.com>
@@ -105,6 +109,7 @@ Naveen Kumar <stupiddint@gmail.com>
105109
Neeraj Pathak <neerajrpathak710@gmail.com>
106110
NirvedMishra <139633597+NirvedMishra@users.noreply.github.com>
107111
Nishant Shinde <97207366+nishant-s7@users.noreply.github.com>
112+
Nishant singh <38534128+Nishantsingh11@users.noreply.github.com>
108113
Nishchay Rajput <121144841+NishchayRajput@users.noreply.github.com>
109114
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
110115
Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com>
@@ -169,6 +174,7 @@ Utkarsh <http://utkarsh11105@gmail.com>
169174
Utkarsh Raj <rajutkarsh2505@gmail.com>
170175
UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
171176
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
177+
Vara Rahul Rajana <123227543+rajanarahul93@users.noreply.github.com>
172178
Varad Gupta <varadgupta21@gmail.com>
173179
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
174180
Vivek Maurya <vm8118134@gmail.com>
@@ -177,12 +183,15 @@ Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
177183
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
178184
Yugal Kaushik <yugalkaushik14@gmail.com>
179185
Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
186+
devshree-bhati <147095250+devshree-bhati@users.noreply.github.com>
180187
ditsu <170345142+ditsus@users.noreply.github.com>
181188
ekambains <bainsinbusiness@gmail.com>
182189
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
190+
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
183191
lohithganni <116790357+lohithganni@users.noreply.github.com>
184192
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
185193
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>
186194
rahulrangers <127782777+rahulrangers@users.noreply.github.com>
187195
rainn <88160429+AmCodesLame@users.noreply.github.com>
188196
rei2hu <reimu@reimu.ws>
197+
zhanggy <geodaoyu@foxmail.com>

README.md

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ var heavisidef = require( '@stdlib/math-base-special-heavisidef' );
188188
var opts = {
189189
'dtype': 'float32'
190190
};
191-
var x = uniform( 101, -10.0, 10.0, opts );
191+
var x = uniform( 100, -10.0, 10.0, opts );
192192

193193
logEachMap( 'H(%0.4f) = %0.4f', x, heavisidef );
194194
```
@@ -197,6 +197,104 @@ logEachMap( 'H(%0.4f) = %0.4f', x, heavisidef );
197197

198198
<!-- /.examples -->
199199

200+
<!-- C interface documentation. -->
201+
202+
* * *
203+
204+
<section class="c">
205+
206+
## C APIs
207+
208+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
209+
210+
<section class="intro">
211+
212+
</section>
213+
214+
<!-- /.intro -->
215+
216+
<!-- C usage documentation. -->
217+
218+
<section class="usage">
219+
220+
### Usage
221+
222+
```c
223+
#include "stdlib/math/base/special/heavisidef.h"
224+
```
225+
226+
#### stdlib_base_heavisidef( x, continuity )
227+
228+
Evaluates the [Heaviside function][heaviside-function] for a single-precision floating-point number.
229+
230+
```c
231+
float y = stdlib_base_heavisidef( 0.0f, STDLIB_BASE_HEAVISIDEF_CONTINUITY_HALF_MAXIMUM );
232+
// returns 0.5f
233+
234+
y = stdlib_base_heavisidef( 0.0f, STDLIB_BASE_HEAVISIDEF_CONTINUITY_LEFT_CONTINUOUS );
235+
// returns 0.0f
236+
```
237+
238+
The function accepts the following arguments:
239+
240+
- **x**: `[in] float` input value.
241+
- **continuity**: `[in] STDLIB_BASE_HEAVISIDEF_CONTINUITY` continuity option.
242+
243+
The `continuity` parameter may be one of the following values:
244+
245+
- `STDLIB_BASE_HEAVISIDEF_CONTINUITY_HALF_MAXIMUM`: if `x == 0`, the function returns `0.5`.
246+
- `STDLIB_BASE_HEAVISIDEF_CONTINUITY_LEFT_CONTINUOUS`: if `x == 0`, the function returns `0.0`.
247+
- `STDLIB_BASE_HEAVISIDEF_CONTINUITY_RIGHT_CONTINUOUS`: if `x == 0`, the function returns `1.0`.
248+
- `STDLIB_BASE_HEAVISIDEF_CONTINUITY_DISCONTINUOUS`: if `x == 0`, the function returns `NaN`.
249+
250+
If provided a `continuity` argument which is not one of the enumeration constants listed above, the function returns `NaN` for `x == 0`, behaving like the discontinuous case.
251+
252+
```c
253+
float stdlib_base_heavisidef( const float x, const STDLIB_BASE_HEAVISIDEF_CONTINUITY continuity );
254+
```
255+
256+
</section>
257+
258+
<!-- /.usage -->
259+
260+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
261+
262+
<section class="notes">
263+
264+
</section>
265+
266+
<!-- /.notes -->
267+
268+
<!-- C API usage examples. -->
269+
270+
<section class="examples">
271+
272+
### Examples
273+
274+
```c
275+
#include "stdlib/math/base/special/heavisidef.h"
276+
#include <stdio.h>
277+
278+
int main( void ) {
279+
const float x[] = { -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
280+
281+
float y;
282+
int i;
283+
for ( i = 0; i < 10; i++ ) {
284+
y = stdlib_base_heavisidef( x[ i ], STDLIB_BASE_HEAVISIDEF_CONTINUITY_HALF_MAXIMUM );
285+
printf( "H(%f) = %f\n", x[ i ], y );
286+
}
287+
}
288+
```
289+
290+
</section>
291+
292+
<!-- /.examples -->
293+
294+
</section>
295+
296+
<!-- /.c -->
297+
200298
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
201299

202300
<section class="related">

benchmark/benchmark.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37-
x = uniform( 100, -50.0, 50.0 );
37+
x = uniform( 100, -50.0, 50.0, {
38+
'dtype': 'float32'
39+
});
3840

3941
b.tic();
4042
for ( i = 0; i < b.iterations; i++ ) {
41-
y = heavisidef( x[ i % x.length ] );
43+
y = heavisidef( x[ i%x.length ] );
4244
if ( y > 1.0 ) {
4345
b.fail( 'should not return a value greater than 1' );
4446
}
@@ -56,11 +58,13 @@ bench( pkg+'::left-continuous', function benchmark( b ) {
5658
var y;
5759
var i;
5860

59-
x = uniform( 100, -50.0, 50.0 );
61+
x = uniform( 100, -50.0, 50.0, {
62+
'dtype': 'float32'
63+
});
6064

6165
b.tic();
6266
for ( i = 0; i < b.iterations; i++ ) {
63-
y = heavisidef( x[ i % x.length ], 'left-continuous' );
67+
y = heavisidef( x[ i%x.length ], 'left-continuous' );
6468
if ( isnanf( y ) ) {
6569
b.fail( 'should not return NaN' );
6670
}
@@ -78,11 +82,13 @@ bench( pkg+'::right-continuous', function benchmark( b ) {
7882
var y;
7983
var i;
8084

81-
x = uniform( 100, -50.0, 50.0 );
85+
x = uniform( 100, -50.0, 50.0, {
86+
'dtype': 'float32'
87+
});
8288

8389
b.tic();
8490
for ( i = 0; i < b.iterations; i++ ) {
85-
y = heavisidef( x[ i % x.length ], 'right-continuous' );
91+
y = heavisidef( x[ i%x.length ], 'right-continuous' );
8692
if ( isnanf( y ) ) {
8793
b.fail( 'should not return NaN' );
8894
}
@@ -100,11 +106,13 @@ bench( pkg+'::half-maximum', function benchmark( b ) {
100106
var y;
101107
var i;
102108

103-
x = uniform( 100, -50.0, 50.0 );
109+
x = uniform( 100, -50.0, 50.0, {
110+
'dtype': 'float32'
111+
});
104112

105113
b.tic();
106114
for ( i = 0; i < b.iterations; i++ ) {
107-
y = heavisidef( x[ i % x.length ], 'half-maximum' );
115+
y = heavisidef( x[ i%x.length ], 'half-maximum' );
108116
if ( isnanf( y ) ) {
109117
b.fail( 'should not return NaN' );
110118
}

benchmark/benchmark.native.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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 uniform = require( '@stdlib/random-array-uniform' );
26+
var isnanf = require( '@stdlib/math-base-assert-is-nanf' );
27+
var tryRequire = require( '@stdlib/utils-try-require' );
28+
var pkg = require( './../package.json' ).name;
29+
30+
31+
// VARIABLES //
32+
33+
var heavisidef = tryRequire( resolve( __dirname, './../lib/native.js' ) );
34+
var opts = {
35+
'skip': ( heavisidef instanceof Error )
36+
};
37+
38+
39+
// MAIN //
40+
41+
bench( pkg+'::native', opts, function benchmark( b ) {
42+
var x;
43+
var y;
44+
var i;
45+
46+
x = uniform( 100, -50.0, 50.0, {
47+
'dtype': 'float32'
48+
});
49+
50+
b.tic();
51+
for ( i = 0; i < b.iterations; i++ ) {
52+
y = heavisidef( x[ i%x.length ] );
53+
if ( isnanf( y ) ) {
54+
b.fail( 'should not return NaN' );
55+
}
56+
}
57+
b.toc();
58+
if ( isnanf( y ) ) {
59+
b.fail( 'should not return NaN' );
60+
}
61+
b.pass( 'benchmark finished' );
62+
b.end();
63+
});

0 commit comments

Comments
 (0)