Skip to content

Commit 5dbd442

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
--- 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: passed - 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 0e28d1f + 54148e1 commit 5dbd442

File tree

30 files changed

+536
-274
lines changed

30 files changed

+536
-274
lines changed

lib/node_modules/@stdlib/blas/ext/base/srev/README.md

Lines changed: 129 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ limitations under the License.
3030
var srev = require( '@stdlib/blas/ext/base/srev' );
3131
```
3232

33-
#### srev( N, x, stride )
33+
#### srev( N, x, strideX )
3434

35-
Reverses a single-precision floating-point strided array `x` in-place.
35+
Reverses a single-precision floating-point strided array in-place.
3636

3737
```javascript
3838
var Float32Array = require( '@stdlib/array/float32' );
@@ -47,9 +47,9 @@ The function has the following parameters:
4747

4848
- **N**: number of indexed elements.
4949
- **x**: input [`Float32Array`][@stdlib/array/float32].
50-
- **stride**: index increment.
50+
- **strideX**: stride length.
5151

52-
The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to reverse every other element
52+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to reverse every other element:
5353

5454
```javascript
5555
var Float32Array = require( '@stdlib/array/float32' );
@@ -76,9 +76,9 @@ srev( 3, x1, 2 );
7676
// x0 => <Float32Array>[ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ]
7777
```
7878

79-
#### srev.ndarray( N, x, stride, offset )
79+
#### srev.ndarray( N, x, strideX, offsetX )
8080

81-
Reverses a single-precision floating-point strided array `x` in-place using alternative indexing semantics.
81+
Reverses a single-precision floating-point strided array in-place using alternative indexing semantics.
8282

8383
```javascript
8484
var Float32Array = require( '@stdlib/array/float32' );
@@ -91,9 +91,9 @@ srev.ndarray( x.length, x, 1, 0 );
9191

9292
The function has the following additional parameters:
9393

94-
- **offset**: starting index.
94+
- **offsetX**: starting index.
9595

96-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array
96+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array:
9797

9898
```javascript
9999
var Float32Array = require( '@stdlib/array/float32' );
@@ -126,13 +126,12 @@ srev.ndarray( 3, x, 1, x.length-3 );
126126
<!-- eslint no-undef: "error" -->
127127

128128
```javascript
129-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
130-
var filledarrayBy = require( '@stdlib/array/filled-by' );
129+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
131130
var srev = require( '@stdlib/blas/ext/base/srev' );
132131

133-
var rand = discreteUniform( -100, 100 );
134-
135-
var x = filledarrayBy( 10, 'float32', rand );
132+
var x = discreteUniform( 10, -100, 100, {
133+
'dtype': 'float32'
134+
});
136135
console.log( x );
137136

138137
srev( x.length, x, 1 );
@@ -143,6 +142,123 @@ console.log( x );
143142

144143
<!-- /.examples -->
145144

145+
<!-- C interface documentation. -->
146+
147+
* * *
148+
149+
<section class="c">
150+
151+
## C APIs
152+
153+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
154+
155+
<section class="intro">
156+
157+
</section>
158+
159+
<!-- /.intro -->
160+
161+
<!-- C usage documentation. -->
162+
163+
<section class="usage">
164+
165+
### Usage
166+
167+
```c
168+
#include "stdlib/blas/ext/base/srev.h"
169+
```
170+
171+
#### stdlib_strided_srev( N, \*X, strideX )
172+
173+
Reverses a single-precision floating-point strided array in-place.
174+
175+
```c
176+
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
177+
178+
stdlib_strided_srev( 4, x, 1 );
179+
```
180+
181+
The function accepts the following arguments:
182+
183+
- **N**: `[in] CBLAS_INT` number of indexed elements.
184+
- **X**: `[inout] float*` input array.
185+
- **strideX**: `[in] CBLAS_INT` stride length.
186+
187+
```c
188+
void stdlib_strided_srev( const CBLAS_INT N, float *X, const CBLAS_INT strideX );
189+
```
190+
191+
#### stdlib_strided_srev_ndarray( N, \*X, strideX, offsetX )
192+
193+
Reverses a single-precision floating-point strided array in-place using alternative indexing semantics.
194+
195+
```c
196+
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
197+
198+
stdlib_strided_srev_ndarray( 4, x, 1, 0 );
199+
```
200+
201+
The function accepts the following arguments:
202+
203+
- **N**: `[in] CBLAS_INT` number of indexed elements.
204+
- **X**: `[inout] float*` input array.
205+
- **strideX**: `[in] CBLAS_INT` stride length.
206+
- **offsetX**: `[in] CBLAS_INT` starting index.
207+
208+
```c
209+
void stdlib_strided_srev_ndarray( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
210+
```
211+
212+
</section>
213+
214+
<!-- /.usage -->
215+
216+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
217+
218+
<section class="notes">
219+
220+
</section>
221+
222+
<!-- /.notes -->
223+
224+
<!-- C API usage examples. -->
225+
226+
<section class="examples">
227+
228+
### Examples
229+
230+
```c
231+
#include "stdlib/blas/ext/base/srev.h"
232+
#include <stdio.h>
233+
234+
int main( void ) {
235+
// Create a strided array:
236+
float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };
237+
238+
// Specify the number of elements:
239+
const int N = 8;
240+
241+
// Specify a stride:
242+
const int strideX = 1;
243+
244+
// Reverse the array:
245+
stdlib_strided_srev( N, x, strideX );
246+
247+
// Print the result:
248+
for ( int i = 0; i < 8; i++ ) {
249+
printf( "x[ %i ] = %f\n", i, x[ i ] );
250+
}
251+
}
252+
```
253+
254+
</section>
255+
256+
<!-- /.examples -->
257+
258+
</section>
259+
260+
<!-- /.c -->
261+
146262
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
147263
148264
<section class="related">

lib/node_modules/@stdlib/blas/ext/base/srev/benchmark/benchmark.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var uniform = require( '@stdlib/random/base/uniform' ).factory;
25-
var filledarrayBy = require( '@stdlib/array/filled-by' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2625
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2726
var pow = require( '@stdlib/math/base/special/pow' );
2827
var pkg = require( './../package.json' ).name;
@@ -31,7 +30,9 @@ var srev = require( './../lib/srev.js' );
3130

3231
// VARIABLES //
3332

34-
var rand = uniform( -10.0, 10.0 );
33+
var options = {
34+
'dtype': 'float32'
35+
};
3536

3637

3738
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 );
4445
* @returns {Function} benchmark function
4546
*/
4647
function createBenchmark( len ) {
47-
var x = filledarrayBy( len, 'float32', rand );
48+
var x = uniform( len, -100, 100, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

lib/node_modules/@stdlib/blas/ext/base/srev/benchmark/benchmark.native.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var uniform = require( '@stdlib/random/base/uniform' ).factory;
26-
var filledarrayBy = require( '@stdlib/array/filled-by' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2726
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2827
var pow = require( '@stdlib/math/base/special/pow' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -36,7 +35,9 @@ var srev = tryRequire( resolve( __dirname, './../lib/srev.native.js' ) );
3635
var opts = {
3736
'skip': ( srev instanceof Error )
3837
};
39-
var rand = uniform( -10.0, 10.0 );
38+
var options = {
39+
'dtype': 'float32'
40+
};
4041

4142

4243
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 );
4950
* @returns {Function} benchmark function
5051
*/
5152
function createBenchmark( len ) {
52-
var x = filledarrayBy( len, 'float32', rand );
53+
var x = uniform( len, -100, 100, options );
5354
return benchmark;
5455

5556
function benchmark( b ) {

lib/node_modules/@stdlib/blas/ext/base/srev/benchmark/benchmark.ndarray.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var uniform = require( '@stdlib/random/base/uniform' ).factory;
25-
var filledarrayBy = require( '@stdlib/array/filled-by' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2625
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2726
var pow = require( '@stdlib/math/base/special/pow' );
2827
var pkg = require( './../package.json' ).name;
@@ -31,7 +30,9 @@ var srev = require( './../lib/ndarray.js' );
3130

3231
// VARIABLES //
3332

34-
var rand = uniform( -10.0, 10.0 );
33+
var options = {
34+
'dtype': 'float32'
35+
};
3536

3637

3738
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 );
4445
* @returns {Function} benchmark function
4546
*/
4647
function createBenchmark( len ) {
47-
var x = filledarrayBy( len, 'float32', rand );
48+
var x = uniform( len, -100, 100, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

lib/node_modules/@stdlib/blas/ext/base/srev/benchmark/benchmark.ndarray.native.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var uniform = require( '@stdlib/random/base/uniform' ).factory;
26-
var filledarrayBy = require( '@stdlib/array/filled-by' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2726
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2827
var pow = require( '@stdlib/math/base/special/pow' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -36,7 +35,9 @@ var srev = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
3635
var opts = {
3736
'skip': ( srev instanceof Error )
3837
};
39-
var rand = uniform( -10.0, 10.0 );
38+
var options = {
39+
'dtype': 'float32'
40+
};
4041

4142

4243
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 );
4950
* @returns {Function} benchmark function
5051
*/
5152
function createBenchmark( len ) {
52-
var x = filledarrayBy( len, 'float32', rand );
53+
var x = uniform( len, -100, 100, options );
5354
return benchmark;
5455

5556
function benchmark( b ) {

lib/node_modules/@stdlib/blas/ext/base/srev/benchmark/c/benchmark.length.c

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static float rand_float( void ) {
9494
* @param len array length
9595
* @return elapsed time in seconds
9696
*/
97-
static double benchmark( int iterations, int len ) {
97+
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
9999
float x[ len ];
100100
double t;
@@ -105,7 +105,38 @@ static double benchmark( int iterations, int len ) {
105105
}
106106
t = tic();
107107
for ( i = 0; i < iterations; i++ ) {
108-
c_srev( len, x, 1 );
108+
stdlib_strided_srev( len, x, 1 );
109+
if ( x[ 0 ] != x[ 0 ] ) {
110+
printf( "should not return NaN\n" );
111+
break;
112+
}
113+
}
114+
elapsed = tic() - t;
115+
if ( x[ 0 ] != x[ 0 ] ) {
116+
printf( "should not return NaN\n" );
117+
}
118+
return elapsed;
119+
}
120+
121+
/**
122+
* Runs a benchmark.
123+
*
124+
* @param iterations number of iterations
125+
* @param len array length
126+
* @return elapsed time in seconds
127+
*/
128+
static double benchmark2( int iterations, int len ) {
129+
double elapsed;
130+
float x[ len ];
131+
double t;
132+
int i;
133+
134+
for ( i = 0; i < len; i++ ) {
135+
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
136+
}
137+
t = tic();
138+
for ( i = 0; i < iterations; i++ ) {
139+
stdlib_strided_srev_ndarray( len, x, 1, 0 );
109140
if ( x[ 0 ] != x[ 0 ] ) {
110141
printf( "should not return NaN\n" );
111142
break;
@@ -140,7 +171,18 @@ int main( void ) {
140171
for ( j = 0; j < REPEATS; j++ ) {
141172
count += 1;
142173
printf( "# c::%s:len=%d\n", NAME, len );
143-
elapsed = benchmark( iter, len );
174+
elapsed = benchmark1( iter, len );
175+
print_results( iter, elapsed );
176+
printf( "ok %d benchmark finished\n", count );
177+
}
178+
}
179+
for ( i = MIN; i <= MAX; i++ ) {
180+
len = pow( 10, i );
181+
iter = ITERATIONS / pow( 10, i-1 );
182+
for ( j = 0; j < REPEATS; j++ ) {
183+
count += 1;
184+
printf( "# c::%s:ndarray:len=%d\n", NAME, len );
185+
elapsed = benchmark2( iter, len );
144186
print_results( iter, elapsed );
145187
printf( "ok %d benchmark finished\n", count );
146188
}

0 commit comments

Comments
 (0)