Skip to content

Commit b3e2f2d

Browse files
committed
Auto-generated commit
1 parent fcd9549 commit b3e2f2d

File tree

12 files changed

+913
-1
lines changed

12 files changed

+913
-1
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-09-30)
7+
## Unreleased (2025-10-02)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`92b9d26`](https://github.com/stdlib-js/stdlib/commit/92b9d26a38360ed2b4b7a8f1fe21b31efc9192c8) - add `ndarray/to-reversed` [(#8149)](https://github.com/stdlib-js/stdlib/pull/8149)
1314
- [`53374b7`](https://github.com/stdlib-js/stdlib/commit/53374b70682123e2b0dab22b6f642a544bf31513) - add `ndarray/reverse` [(#8148)](https://github.com/stdlib-js/stdlib/pull/8148)
1415
- [`29cde0f`](https://github.com/stdlib-js/stdlib/commit/29cde0f6f44f4a6a4a70ff59b4ca2d2aab0ab4aa) - add `ndarray/shift` [(#8147)](https://github.com/stdlib-js/stdlib/pull/8147)
1516
- [`6760298`](https://github.com/stdlib-js/stdlib/commit/6760298d2f7e38a975e2f27b24edb0d258c9c218) - add `ndarray/pop` [(#8145)](https://github.com/stdlib-js/stdlib/pull/8145)
@@ -600,6 +601,7 @@ A total of 26 issues were closed in this release:
600601

601602
<details>
602603

604+
- [`92b9d26`](https://github.com/stdlib-js/stdlib/commit/92b9d26a38360ed2b4b7a8f1fe21b31efc9192c8) - **feat:** add `ndarray/to-reversed` [(#8149)](https://github.com/stdlib-js/stdlib/pull/8149) _(by Muhammad Haris, Athan Reines)_
603605
- [`53374b7`](https://github.com/stdlib-js/stdlib/commit/53374b70682123e2b0dab22b6f642a544bf31513) - **feat:** add `ndarray/reverse` [(#8148)](https://github.com/stdlib-js/stdlib/pull/8148) _(by Muhammad Haris, Athan Reines)_
604606
- [`5d2dca1`](https://github.com/stdlib-js/stdlib/commit/5d2dca1fb86de3ac7e2b15c56ff948a9969d5abb) - **chore:** minor clean-up _(by Philipp Burckhardt)_
605607
- [`29cde0f`](https://github.com/stdlib-js/stdlib/commit/29cde0f6f44f4a6a4a70ff59b4ca2d2aab0ab4aa) - **feat:** add `ndarray/shift` [(#8147)](https://github.com/stdlib-js/stdlib/pull/8147) _(by Muhammad Haris, Athan Reines)_

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
232232
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
233233
jsai28 <54253219+jsai28@users.noreply.github.com>
234234
lohithganni <116790357+lohithganni@users.noreply.github.com>
235+
navyansh007 <91735202+navyansh007@users.noreply.github.com>
235236
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
236237
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>
237238
rahulrangers <127782777+rahulrangers@users.noreply.github.com>

to-reversed/README.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# toReversed
22+
23+
> Return a new [`ndarray`][@stdlib/ndarray/ctor] where the order of elements of an input [`ndarray`][@stdlib/ndarray/ctor] is reversed along each dimension.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro section element. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var toReversed = require( '@stdlib/ndarray/to-reversed' );
41+
```
42+
43+
#### toReversed( x )
44+
45+
Returns a new [`ndarray`][@stdlib/ndarray/ctor] where the order of elements of an input [`ndarray`][@stdlib/ndarray/ctor] is reversed along each dimension.
46+
47+
```javascript
48+
var array = require( '@stdlib/ndarray/array' );
49+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
50+
51+
var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], {
52+
'shape': [ 3, 2 ]
53+
});
54+
// returns <ndarray>
55+
56+
var arr = ndarray2array( x );
57+
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
58+
59+
var y = toReversed( x );
60+
// returns <ndarray>
61+
62+
arr = ndarray2array( y );
63+
// returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ]
64+
```
65+
66+
</section>
67+
68+
<!-- /.usage -->
69+
70+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
71+
72+
<section class="notes">
73+
74+
</section>
75+
76+
<!-- /.notes -->
77+
78+
<!-- Package usage examples. -->
79+
80+
<section class="examples">
81+
82+
## Examples
83+
84+
<!-- eslint no-undef: "error" -->
85+
86+
```javascript
87+
var uniform = require( '@stdlib/random/uniform' );
88+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
89+
var toReversed = require( '@stdlib/ndarray/to-reversed' );
90+
91+
var x = uniform( [ 3, 3, 3 ], -10.0, 10.0 );
92+
console.log( ndarray2array( x ) );
93+
94+
var y = toReversed( x );
95+
console.log( ndarray2array( y ) );
96+
```
97+
98+
</section>
99+
100+
<!-- /.examples -->
101+
102+
<!-- 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. -->
103+
104+
<section class="references">
105+
106+
</section>
107+
108+
<!-- /.references -->
109+
110+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
111+
112+
<section class="related">
113+
114+
</section>
115+
116+
<!-- /.related -->
117+
118+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
119+
120+
<section class="links">
121+
122+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
123+
124+
<!-- <related-links> -->
125+
126+
<!-- </related-links> -->
127+
128+
</section>
129+
130+
<!-- /.links -->

to-reversed/benchmark/benchmark.js

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
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 bench = require( '@stdlib/bench' );
24+
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
25+
var empty = require( './../../empty' );
26+
var pkg = require( './../package.json' ).name;
27+
var toReversed = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg+'::0d', function benchmark( b ) {
33+
var values;
34+
var v;
35+
var i;
36+
37+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
38+
39+
values = [
40+
empty( [], { 'dtype': 'float64' } ),
41+
empty( [], { 'dtype': 'float32' } ),
42+
empty( [], { 'dtype': 'int32' } ),
43+
empty( [], { 'dtype': 'complex128' } ),
44+
empty( [], { 'dtype': 'generic' } )
45+
];
46+
47+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
48+
49+
b.tic();
50+
for ( i = 0; i < b.iterations; i++ ) {
51+
v = toReversed( values[ i%values.length ] );
52+
if ( typeof v !== 'object' ) {
53+
b.fail( 'should return an ndarray' );
54+
}
55+
}
56+
b.toc();
57+
if ( !isndarrayLike( v ) ) {
58+
b.fail( 'should return an ndarray' );
59+
}
60+
b.pass( 'benchmark finished' );
61+
b.end();
62+
});
63+
64+
bench( pkg+'::1d', function benchmark( b ) {
65+
var values;
66+
var v;
67+
var i;
68+
69+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
70+
71+
values = [
72+
empty( [ 2 ], { 'dtype': 'float64' } ),
73+
empty( [ 2 ], { 'dtype': 'float32' } ),
74+
empty( [ 2 ], { 'dtype': 'int32' } ),
75+
empty( [ 2 ], { 'dtype': 'complex128' } ),
76+
empty( [ 2 ], { 'dtype': 'generic' } )
77+
];
78+
79+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
80+
81+
b.tic();
82+
for ( i = 0; i < b.iterations; i++ ) {
83+
v = toReversed( values[ i%values.length ] );
84+
if ( typeof v !== 'object' ) {
85+
b.fail( 'should return an ndarray' );
86+
}
87+
}
88+
b.toc();
89+
if ( !isndarrayLike( v ) ) {
90+
b.fail( 'should return an ndarray' );
91+
}
92+
b.pass( 'benchmark finished' );
93+
b.end();
94+
});
95+
96+
bench( pkg+'::2d', function benchmark( b ) {
97+
var values;
98+
var v;
99+
var i;
100+
101+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
102+
103+
values = [
104+
empty( [ 2, 2 ], { 'dtype': 'float64' } ),
105+
empty( [ 2, 2 ], { 'dtype': 'float32' } ),
106+
empty( [ 2, 2 ], { 'dtype': 'int32' } ),
107+
empty( [ 2, 2 ], { 'dtype': 'complex128' } ),
108+
empty( [ 2, 2 ], { 'dtype': 'generic' } )
109+
];
110+
111+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
112+
113+
b.tic();
114+
for ( i = 0; i < b.iterations; i++ ) {
115+
v = toReversed( values[ i%values.length ] );
116+
if ( typeof v !== 'object' ) {
117+
b.fail( 'should return an ndarray' );
118+
}
119+
}
120+
b.toc();
121+
if ( !isndarrayLike( v ) ) {
122+
b.fail( 'should return an ndarray' );
123+
}
124+
b.pass( 'benchmark finished' );
125+
b.end();
126+
});
127+
128+
bench( pkg+'::3d', function benchmark( b ) {
129+
var values;
130+
var v;
131+
var i;
132+
133+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
134+
135+
values = [
136+
empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ),
137+
empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ),
138+
empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
139+
empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ),
140+
empty( [ 2, 2, 2 ], { 'dtype': 'generic' } )
141+
];
142+
143+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
144+
145+
b.tic();
146+
for ( i = 0; i < b.iterations; i++ ) {
147+
v = toReversed( values[ i%values.length ] );
148+
if ( typeof v !== 'object' ) {
149+
b.fail( 'should return an ndarray' );
150+
}
151+
}
152+
b.toc();
153+
if ( !isndarrayLike( v ) ) {
154+
b.fail( 'should return an ndarray' );
155+
}
156+
b.pass( 'benchmark finished' );
157+
b.end();
158+
});
159+
160+
bench( pkg+'::4d', function benchmark( b ) {
161+
var values;
162+
var v;
163+
var i;
164+
165+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
166+
167+
values = [
168+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
169+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
170+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
171+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
172+
empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } )
173+
];
174+
175+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
176+
177+
b.tic();
178+
for ( i = 0; i < b.iterations; i++ ) {
179+
v = toReversed( values[ i%values.length ] );
180+
if ( typeof v !== 'object' ) {
181+
b.fail( 'should return an ndarray' );
182+
}
183+
}
184+
b.toc();
185+
if ( !isndarrayLike( v ) ) {
186+
b.fail( 'should return an ndarray' );
187+
}
188+
b.pass( 'benchmark finished' );
189+
b.end();
190+
});
191+
192+
bench( pkg+'::5d', function benchmark( b ) {
193+
var values;
194+
var v;
195+
var i;
196+
197+
/* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */
198+
199+
values = [
200+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
201+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
202+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
203+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
204+
empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } )
205+
];
206+
207+
/* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */
208+
209+
b.tic();
210+
for ( i = 0; i < b.iterations; i++ ) {
211+
v = toReversed( values[ i%values.length ] );
212+
if ( typeof v !== 'object' ) {
213+
b.fail( 'should return an ndarray' );
214+
}
215+
}
216+
b.toc();
217+
if ( !isndarrayLike( v ) ) {
218+
b.fail( 'should return an ndarray' );
219+
}
220+
b.pass( 'benchmark finished' );
221+
b.end();
222+
});

0 commit comments

Comments
 (0)