Skip to content

Commit fdbf73d

Browse files
committed
feat:C implementation of stats/base/dists/weibull/skewness
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
2 parents 63e5dd1 + ef48cd2 commit fdbf73d

File tree

12 files changed

+82
-138
lines changed

12 files changed

+82
-138
lines changed

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,11 @@ The function accepts the following arguments:
187187
```c
188188
double stdlib_base_dists_weibull_skewness( const double k, const double lambda );
189189
```
190-
191190
</section>
192-
193191
<!-- /.usage -->
194192
195193
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
196-
197194
<section class="notes">
198-
199195
</section>
200196
<!-- /.notes -->
201197

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ bench( pkg+':direct', function benchmark( b ) {
7676
}
7777
b.pass( 'benchmark finished' );
7878
b.end();
79-
});
79+
});

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/benchmark/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/benchmark/c/benchmark.c

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Prints the TAP version.
3333
*/
3434
static void print_version( void ) {
35-
printf( "TAP version 13\n" );
35+
printf( "TAP version 13\n" );
3636
}
3737

3838
/**
@@ -42,12 +42,12 @@ static void print_version( void ) {
4242
* @param passing total number of passing tests
4343
*/
4444
static void print_summary( int total, int passing ) {
45-
printf( "#\n" );
46-
printf( "1..%d\n", total ); // TAP plan
47-
printf( "# total %d\n", total );
48-
printf( "# pass %d\n", passing );
49-
printf( "#\n" );
50-
printf( "# ok\n" );
45+
printf( "#\n" );
46+
printf( "1..%d\n", total ); // TAP plan
47+
printf( "# total %d\n", total );
48+
printf( "# pass %d\n", passing );
49+
printf( "#\n" );
50+
printf( "# ok\n" );
5151
}
5252

5353
/**
@@ -56,12 +56,12 @@ static void print_summary( int total, int passing ) {
5656
* @param elapsed elapsed time in seconds
5757
*/
5858
static void print_results( double elapsed ) {
59-
double rate = (double)ITERATIONS / elapsed;
60-
printf( " ---\n" );
61-
printf( " iterations: %d\n", ITERATIONS );
62-
printf( " elapsed: %0.9f\n", elapsed );
63-
printf( " rate: %0.9f\n", rate );
64-
printf( " ...\n" );
59+
double rate = (double)ITERATIONS / elapsed;
60+
printf( " ---\n" );
61+
printf( " iterations: %d\n", ITERATIONS );
62+
printf( " elapsed: %0.9f\n", elapsed );
63+
printf( " rate: %0.9f\n", rate );
64+
printf( " ...\n" );
6565
}
6666

6767
/**
@@ -70,9 +70,9 @@ static void print_results( double elapsed ) {
7070
* @return clock time
7171
*/
7272
static double tic( void ) {
73-
struct timeval now;
74-
gettimeofday( &now, NULL );
75-
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
73+
struct timeval now;
74+
gettimeofday( &now, NULL );
75+
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
7676
}
7777

7878
/**
@@ -83,8 +83,8 @@ static double tic( void ) {
8383
* @return random number
8484
*/
8585
static double random_uniform( const double min, const double max ) {
86-
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
87-
return min + ( v*(max-min) );
86+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
87+
return min + ( v*(max-min) );
8888
}
8989

9090
/**
@@ -93,52 +93,52 @@ static double random_uniform( const double min, const double max ) {
9393
* @return elapsed time in seconds
9494
*/
9595
static double benchmark( void ) {
96-
double elapsed;
97-
double x[ 100 ];
98-
double n[ 100 ];
99-
double skewness;
100-
double y;
101-
double t;
102-
int i;
96+
double elapsed;
97+
double x[ 100 ];
98+
double n[ 100 ];
99+
double skewness;
100+
double y;
101+
double t;
102+
int i;
103103

104-
// Generate random values for x, n, and skewness
105-
for ( i = 0; i < 100; i++ ) {
106-
x[ i ] = random_uniform( 0, 30.0 );
107-
n[ i ] = stdlib_base_ceil(random_uniform( 1, 30.0 ));
108-
skewness = random_uniform( -1.0, 1.0 );
109-
}
104+
// Generate random values for x, n, and skewness
105+
for ( i = 0; i < 100; i++ ) {
106+
x[ i ] = random_uniform( 0, 30.0 );
107+
n[ i ] = stdlib_base_ceil(random_uniform( 1, 30.0 ));
108+
skewness = random_uniform( -1.0, 1.0 );
109+
}
110110

111-
t = tic();
112-
for ( i = 0; i < ITERATIONS; i++ ) {
113-
y = stdlib_base_dists_weibull_skewness( x[ i%100 ], n[ i%100 ], skewness );
114-
if ( y != y ) { // Check if the result is NaN
115-
printf( "should not return NaN\n" );
116-
break;
117-
}
118-
}
119-
elapsed = tic() - t;
120-
if ( y != y ) {
121-
printf( "should not return NaN\n" );
122-
}
123-
return elapsed;
111+
t = tic();
112+
for ( i = 0; i < ITERATIONS; i++ ) {
113+
y = stdlib_base_dists_weibull_skewness( x[ i%100 ], n[ i%100 ], skewness );
114+
if ( y != y ) { // Check if the result is NaN
115+
printf( "should not return NaN\n" );
116+
break;
117+
}
118+
}
119+
elapsed = tic() - t;
120+
if ( y != y ) {
121+
printf( "should not return NaN\n" );
122+
}
123+
return elapsed;
124124
}
125125

126126
/**
127127
* Main execution sequence.
128128
*/
129129
int main( void ) {
130-
double elapsed;
131-
int i;
130+
double elapsed;
131+
int i;
132132

133-
// Use the current time to seed the random number generator:
134-
srand( time( NULL ) );
133+
// Use the current time to seed the random number generator:
134+
srand( time( NULL ) );
135135

136-
print_version();
137-
for ( i = 0; i < REPEATS; i++ ) {
138-
printf( "# c::%s\n", NAME );
139-
elapsed = benchmark();
140-
print_results( elapsed );
141-
printf( "ok %d benchmark finished\n", i+1 );
142-
}
143-
print_summary( REPEATS, REPEATS );
136+
print_version();
137+
for ( i = 0; i < REPEATS; i++ ) {
138+
printf( "# c::%s\n", NAME );
139+
elapsed = benchmark();
140+
print_results( elapsed );
141+
printf( "ok %d benchmark finished\n", i+1 );
142+
}
143+
print_summary( REPEATS, REPEATS );
144144
}

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@
167167
], # end actions
168168
}, # end target copy_addon
169169
], # end targets
170-
}
170+
}

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/examples/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean
Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +0,0 @@
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-
#include "stdlib/stats/base/dists/weibull/skewness/pdf.h"
20-
#include "stdlib/math/base/special/ceil.h"
21-
#include <stdlib.h>
22-
#include <stdio.h>
23-
24-
static double random_uniform( const double min, const double max ) {
25-
double v = (double)rand() / ((double)RAND_MAX + 1.0);
26-
return min + ( v * (max - min) );
27-
}
28-
29-
int main( void ) {
30-
double n;
31-
double x;
32-
double skewness;
33-
double y;
34-
int i;
35-
36-
for ( i = 0; i < 25; i++ ) {
37-
// Random x value (observations)
38-
x = random_uniform( 0, 30.0 );
39-
40-
// Random n value (shape parameter)
41-
n = stdlib_base_ceil( random_uniform( 1, 30.0 ) );
42-
43-
// Random skewness value (skewness parameter for Weibull distribution)
44-
skewness = random_uniform( -1.0, 1.0 );
45-
46-
// Calculate the PDF for the Weibull skewness distribution
47-
y = stdlib_base_dists_weibull_skewness_pdf( x, n, skewness );
48-
49-
// Print the result
50-
printf( "x: %lf, n: %lf, skewness: %lf, PDF(x; n, skewness): %lf\n", x, n, skewness, y );
51-
}
52-
53-
return 0;
54-
}

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/include.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
'<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
5151
],
5252
}, # end variables
53-
}
53+
}

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/manifest.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
{
3030
"task": "build",
3131
"wasm": false,
32-
"src": ["./src/main.c"],
33-
"include": ["./include"],
34-
"libraries": [],
32+
"src": ["./src/main.c"],
33+
"include": ["./include"],
34+
"libraries": [],
3535
"libpath": [],
3636
"dependencies": [
3737
"@stdlib/math/base/assert/is-positive-integer",
@@ -79,3 +79,4 @@
7979
}
8080
]
8181
}
82+

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ clean-addon:
6767
#/
6868
clean: clean-addon
6969

70-
.PHONY: clean
70+
.PHONY: clean

0 commit comments

Comments
 (0)