Skip to content

Commit 49baac8

Browse files
committed
Auto-generated commit
1 parent 39e2b24 commit 49baac8

File tree

11 files changed

+1289
-1
lines changed

11 files changed

+1289
-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-12-12)
7+
## Unreleased (2025-12-15)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`d360fe5`](https://github.com/stdlib-js/stdlib/commit/d360fe525de98bfac66993c5c54b13fffccab822) - add `ndarray/base/to-reversed-dimension` [(#8852)](https://github.com/stdlib-js/stdlib/pull/8852)
1314
- [`f375981`](https://github.com/stdlib-js/stdlib/commit/f375981dd59f1ce6aa575e48bafa0e7998a7efdd) - add `ndarray/base/to-flippedud` [(#8849)](https://github.com/stdlib-js/stdlib/pull/8849)
1415
- [`1080085`](https://github.com/stdlib-js/stdlib/commit/1080085cbf97a2d217339594fda596759a49386b) - add `ndarray/base/to-flippedlr` [(#8848)](https://github.com/stdlib-js/stdlib/pull/8848)
1516
- [`c034ac5`](https://github.com/stdlib-js/stdlib/commit/c034ac5a8b15ac837619c50efa8db3266c897f8e) - add `ndarray/concat1d` [(#8584)](https://github.com/stdlib-js/stdlib/pull/8584)
@@ -650,6 +651,7 @@ A total of 36 issues were closed in this release:
650651

651652
<details>
652653

654+
- [`d360fe5`](https://github.com/stdlib-js/stdlib/commit/d360fe525de98bfac66993c5c54b13fffccab822) - **feat:** add `ndarray/base/to-reversed-dimension` [(#8852)](https://github.com/stdlib-js/stdlib/pull/8852) _(by Muhammad Haris, Athan Reines)_
653655
- [`01ab290`](https://github.com/stdlib-js/stdlib/commit/01ab29036205f4a0507133c1a4a7fd429bb7bd9e) - **fix:** rename import in `ndarray/base/unary-strided1d-dispatch` to resolve conflict [(#9010)](https://github.com/stdlib-js/stdlib/pull/9010) _(by Muhammad Haris)_
654656
- [`53d181b`](https://github.com/stdlib-js/stdlib/commit/53d181b5581a10bee3ebe924a54f137544d309e4) - **chore:** minor clean-up _(by Philipp Burckhardt)_
655657
- [`f375981`](https://github.com/stdlib-js/stdlib/commit/f375981dd59f1ce6aa575e48bafa0e7998a7efdd) - **feat:** add `ndarray/base/to-flippedud` [(#8849)](https://github.com/stdlib-js/stdlib/pull/8849) _(by Muhammad Haris, Athan Reines)_
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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+
# toReversedDimension
22+
23+
> Return a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
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 toReversedDimension = require( '@stdlib/ndarray/base/to-reversed-dimension' );
41+
```
42+
43+
#### toReversedDimension( x, dim )
44+
45+
Returns a new ndarray where the order of elements of an input ndarray along a specified dimension is reversed.
46+
47+
```javascript
48+
var ndarray = require( '@stdlib/ndarray/ctor' );
49+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
50+
51+
var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
52+
var shape = [ 3, 2 ];
53+
var strides = [ 2, 1 ];
54+
var offset = 0;
55+
56+
var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
57+
// returns <ndarray>
58+
59+
var sh = x.shape;
60+
// returns [ 3, 2 ]
61+
62+
var arr = ndarray2array( x );
63+
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
64+
65+
var y = toReversedDimension( x, 0 );
66+
// returns <ndarray>
67+
68+
sh = y.shape;
69+
// returns [ 3, 2 ]
70+
71+
arr = ndarray2array( y );
72+
// returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
73+
```
74+
75+
The function accepts the following arguments:
76+
77+
- **x**: input ndarray.
78+
- **dim**: index of dimension along which to reverse elements. If provided an integer less than zero, the dimension index is resolved relative to the last dimension, with the last dimension corresponding to the value `-1`.
79+
80+
</section>
81+
82+
<!-- /.usage -->
83+
84+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
85+
86+
<section class="notes">
87+
88+
</section>
89+
90+
<!-- /.notes -->
91+
92+
<!-- Package usage examples. -->
93+
94+
<section class="examples">
95+
96+
## Examples
97+
98+
<!-- eslint no-undef: "error" -->
99+
100+
```javascript
101+
var array = require( '@stdlib/ndarray/array' );
102+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
103+
var zeroTo = require( '@stdlib/array/base/zero-to' );
104+
var toReversedDimension = require( '@stdlib/ndarray/base/to-reversed-dimension' );
105+
106+
// Create a linear ndarray buffer:
107+
var buf = zeroTo( 16 );
108+
109+
// Create a three-dimensional ndarray:
110+
var x = array( buf, {
111+
'shape': [ 2, 4, 2 ]
112+
});
113+
114+
// Reverse the order of first axis:
115+
var y0 = toReversedDimension( x, 0 );
116+
// returns <ndarray>
117+
118+
var a0 = ndarray2array( y0 );
119+
// returns [ [ [ 8, 9 ], [ 10, 11 ], [ 12, 13 ], [ 14, 15 ] ], [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ], [ 6, 7 ] ] ]
120+
121+
// Reverse the order of second axis:
122+
var y1 = toReversedDimension( x, 1 );
123+
// returns <ndarray>
124+
125+
var a1 = ndarray2array( y1 );
126+
// returns [ [ [ 6, 7 ], [ 4, 5 ], [ 2, 3 ], [ 0, 1 ] ], [ [ 14, 15 ], [ 12, 13 ], [ 10, 11 ], [ 8, 9 ] ] ]
127+
128+
// Reverse the order of third axis:
129+
var y2 = toReversedDimension( x, 2 );
130+
// returns <ndarray>
131+
132+
var a2 = ndarray2array( y2 );
133+
// returns [ [ [ 1, 0 ], [ 3, 2 ], [ 5, 4 ], [ 7, 6 ] ], [ [ 9, 8 ], [ 11, 10 ], [ 13, 12 ], [ 15, 14 ] ] ]
134+
```
135+
136+
</section>
137+
138+
<!-- /.examples -->
139+
140+
<!-- 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. -->
141+
142+
<section class="references">
143+
144+
</section>
145+
146+
<!-- /.references -->
147+
148+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
149+
150+
<section class="related">
151+
152+
</section>
153+
154+
<!-- /.related -->
155+
156+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
157+
158+
<section class="links">
159+
160+
</section>
161+
162+
<!-- /.links -->

0 commit comments

Comments
 (0)