Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Mar 13, 2024
1 parent 5c2d533 commit 2e47c6d
Show file tree
Hide file tree
Showing 22 changed files with 221 additions and 277 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ shrinkwrap = false

# Disable automatically "saving" dependencies on install:
save = false

# Generate provenance metadata:
provenance = true
29 changes: 23 additions & 6 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@
#
# Contributors listed in alphabetical order.

Aditya Sapra <110766802+adityacodes30@users.noreply.github.com>
Adarsh Palaskar <adarshpalaskar99@gmail.com>
Aditya Sapra <adityaework@gmail.com>
AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com>
Ali Salesi <ali_sal1381@yahoo.com>
Aman Bhansali <bhansali.1@iitj.ac.in>
Amit Jimiwal <amitjimiwal45@gmail.com>
Anudeep Sanapala <anudeep0306@gmail.com>
Athan Reines <kgryte@gmail.com>
Brendan Graetz <bguiz@users.noreply.github.com>
Bruno Fenzl <brunofenzl@gmail.com>
Chinmay J <86140365+JawHawk@users.noreply.github.com>
Chinmay Joshi <86140365+JawHawk@users.noreply.github.com>
Christopher Dambamuromo <chridam@gmail.com>
Dan Rose <danoftheroses@gmail.com>
Daniel Killenberger <daniel.killenberger@gmail.com>
Dominik Moritz <domoritz@gmail.com>
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
Frank Kovacs <fran70kk@gmail.com>
GUNJ JOSHI <gunjjoshi8372@gmail.com>
Golden <103646877+AuenKr@users.noreply.github.com>
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
Gunj Joshi <gunjjoshi8372@gmail.com>
Harshita Kalani <harshitakalani02@gmail.com>
Jaimin Godhani <112328542+Jai0401@users.noreply.github.com>
James Gelok <jdgelok@gmail.com>
Jaysukh Makvana <jaysukhmakvana2004@gmail.com>
Jithin KS <jithinks112@gmail.com>
Expand All @@ -28,6 +33,8 @@ Joris Labie <joris.labie1@gmail.com>
Justin Dennison <justin1dennison@gmail.com>
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
Khaldon <kahmd1444@gmail.com>
Lovelin <100030865+lovelindhoni@users.noreply.github.com>
Manik Sharma <maniksharma.rke@gmail.com>
Marcus Fantham <mfantham@users.noreply.github.com>
Matt Cochrane <matthew.cochrane.eng@gmail.com>
Mihir Pandit <129577900+MSP20086@users.noreply.github.com>
Expand All @@ -36,22 +43,32 @@ Momtchil Momtchev <momtchil@momtchev.com>
Naresh Jagadeesan <naresh.naresh000@gmail.com>
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
Philipp Burckhardt <pburckhardt@outlook.com>
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
Pranav Goswami <goswami.4@iitj.ac.in>
Praneki <97080887+PraneGIT@users.noreply.github.com>
Pratik <97464067+Pratik772846@users.noreply.github.com>
Priyansh <88396544+itsspriyansh@users.noreply.github.com>
Raunak Kumar Gupta <raunakmodanwal321@gmail.com>
Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com>
Ricky Reusser <rsreusser@gmail.com>
Robert Gislason <gztown2216@yahoo.com>
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
Rutam <138517416+performant23@users.noreply.github.com>
Ryan Seal <splrk@users.noreply.github.com>
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
Shraddheya Shendre <shendreshraddheya@gmail.com>
Shubham <shubh622005@gmail.com>
Shubham Mishra <shubh622005@gmail.com>
Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Spandan Barve <114365550+marsian83@users.noreply.github.com>
Spandan Barve <contact@marsian.dev>
Stephannie Jiménez Gacha <steff456@hotmail.com>
Utkarsh <http://utkarsh11105@gmail.com>
Utkarsh Raj <rajutkarsh2505@gmail.com>
Varad Gupta <varadgupta21@gmail.com>
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
nishant-s7 <97207366+nishant-s7@users.noreply.github.com>
orimiles5 <97595296+orimiles5@users.noreply.github.com>
rei2hu <reimu@reimu.ws>
36 changes: 8 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,30 @@ The function has the following parameters:
- **x**: input [`Float64Array`][@stdlib/array/float64].
- **stride**: index increment.

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

```javascript
var Float64Array = require( '@stdlib/array-float64' );
var floor = require( '@stdlib/math-base-special-floor' );

var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
var N = floor( x.length / 2 );

drev( N, x, 2 );
drev( 4, x, 2 );
// x => <Float64Array>[ -1.0, 1.0, 4.0, -5.0, 3.0, 0.0, -2.0, -3.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

```javascript
var Float64Array = require( '@stdlib/array-float64' );
var floor = require( '@stdlib/math-base-special-floor' );

// Initial array...
var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );

// Create an offset view...
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var N = floor( x0.length/2 );

// Reverse every other element...
drev( N, x1, 2 );
drev( 3, x1, 2 );
// x0 => <Float64Array>[ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ]
```

Expand All @@ -130,7 +126,7 @@ The function has the following additional parameters:

- **offset**: starting index.

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 `x`
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

```javascript
var Float64Array = require( '@stdlib/array-float64' );
Expand All @@ -149,7 +145,7 @@ drev.ndarray( 3, x, 1, x.length-3 );

## Notes

- If `N <= 0`, both functions return `x` unchanged.
- If `N <= 0`, both functions return the strided array unchanged.
- Where possible, one should "reverse" a strided array by negating its stride, which is an `O(1)` operation, in contrast to performing an in-place reversal, which is `O(N)`. However, in certain circumstances, this is not tenable, particularly when interfacing with libraries which assume and/or expect a specific memory layout (e.g., strided array elements arranged in memory in ascending order). In general, when working with strided arrays, only perform an in-place reversal when strictly necessary.

</section>
Expand All @@ -163,27 +159,11 @@ drev.ndarray( 3, x, 1, x.length-3 );
<!-- eslint no-undef: "error" -->

```javascript
var round = require( '@stdlib/math-base-special-round' );
var randu = require( '@stdlib/random-base-randu' );
var Float64Array = require( '@stdlib/array-float64' );
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var drev = require( '@stdlib/blas-ext-base-drev' );

var rand;
var sign;
var x;
var i;

x = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
rand = round( randu()*100.0 );
sign = randu();
if ( sign < 0.5 ) {
sign = -1.0;
} else {
sign = 1.0;
}
x[ i ] = sign * rand;
}
var x = filledarrayBy( 10, 'float64', discreteUniform( -100.0, 100.0 ) );
console.log( x );

drev( x.length, x, 1 );
Expand Down
17 changes: 8 additions & 9 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
// MODULES //

var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-base-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var pkg = require( './../package.json' ).name;
var drev = require( './../lib/drev.js' );


// VARIABLES //

var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //

/**
Expand All @@ -39,13 +44,7 @@ var drev = require( './../lib/drev.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var i;

x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
return benchmark;

function benchmark( b ) {
Expand Down
13 changes: 4 additions & 9 deletions benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-base-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var tryRequire = require( '@stdlib/utils-try-require' );
var pkg = require( './../package.json' ).name;

Expand All @@ -36,6 +36,7 @@ var drev = tryRequire( resolve( __dirname, './../lib/drev.native.js' ) );
var opts = {
'skip': ( drev instanceof Error )
};
var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //
Expand All @@ -48,13 +49,7 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var i;

x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
return benchmark;

function benchmark( b ) {
Expand Down
17 changes: 8 additions & 9 deletions benchmark/benchmark.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
// MODULES //

var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-base-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var pkg = require( './../package.json' ).name;
var drev = require( './../lib/ndarray.js' );


// VARIABLES //

var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //

/**
Expand All @@ -39,13 +44,7 @@ var drev = require( './../lib/ndarray.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var i;

x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
return benchmark;

function benchmark( b ) {
Expand Down
13 changes: 4 additions & 9 deletions benchmark/benchmark.ndarray.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-base-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var tryRequire = require( '@stdlib/utils-try-require' );
var pkg = require( './../package.json' ).name;

Expand All @@ -36,6 +36,7 @@ var drev = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( drev instanceof Error )
};
var rand = uniform( -10.0, 10.0 );


// FUNCTIONS //
Expand All @@ -48,13 +49,7 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var i;

x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = filledarrayBy( len, 'float64', rand );
return benchmark;

function benchmark( b ) {
Expand Down
20 changes: 9 additions & 11 deletions docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{{alias}}( N, x, stride )
Reverses a double-precision floating-point strided array in-place.

The `N` and `stride` parameters determine which elements in `x` are accessed
at runtime.
The `N` and stride parameters determine which elements in the strided array
are accessed at runtime.

Indexing is relative to the first index. To introduce an offset, use typed
array views.
Expand All @@ -24,7 +24,7 @@
Returns
-------
x: Float64Array
Input array `x`.
Input array.

Examples
--------
Expand All @@ -33,21 +33,20 @@
> {{alias}}( x.length, x, 1 )
<Float64Array>[ -3.0, -1.0, 4.0, -5.0, 3.0, 1.0, -2.0 ]

// Using `N` and `stride` parameters:
// Using `N` and stride parameters:
> x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}( N, x, 2 )
> {{alias}}( 3, x, 2 )
<Float64Array>[ 4.0, 1.0, 3.0, -5.0, -2.0, -1.0, -3.0 ]

// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
> {{alias}}( N, x1, 2 )
> {{alias}}( 3, x1, 2 )
<Float64Array>[ -6.0, 3.0, -4.0, 5.0, -2.0 ]
> x0
<Float64Array>[ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ]


{{alias}}.ndarray( N, x, stride, offset )
Reverses a double-precision floating-point strided array in-place using
alternative indexing semantics.
Expand All @@ -73,7 +72,7 @@
Returns
-------
x: Float64Array
Input array `x`.
Input array.

Examples
--------
Expand All @@ -84,8 +83,7 @@

// Using an index offset:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}.ndarray( N, x, 2, 1 )
> {{alias}}.ndarray( 3, x, 2, 1 )
<Float64Array>[ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ]

See Also
Expand Down
Loading

0 comments on commit 2e47c6d

Please sign in to comment.