Skip to content

Commit 4117195

Browse files
committed
Auto-generated commit
1 parent 61d990f commit 4117195

12 files changed

Lines changed: 2190 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
### Features
1212

13+
- [`f738a37`](https://github.com/stdlib-js/stdlib/commit/f738a37c1cc32a740c7ecc4cbc7982eca26f67d2) - add `ternaryBlockSize` to namespace
14+
- [`b490370`](https://github.com/stdlib-js/stdlib/commit/b49037059ac498f7e864cb83f0cf59b3feb3b459) - add `ternaryLoopOrder` to namespace
15+
- [`88e4096`](https://github.com/stdlib-js/stdlib/commit/88e4096e8e5941fecc15ef2fd2d5b27e91d69233) - add `ternary` to namespace
16+
- [`5fbedba`](https://github.com/stdlib-js/stdlib/commit/5fbedba2f71e2c6a20c33f0de574d0060536c0f5) - add `ternaryOutputDataType` to namespace
17+
- [`9d38a93`](https://github.com/stdlib-js/stdlib/commit/9d38a9324e99a3a00f733b30a37510e8d1e4b6a4) - add `ndarray/base/ternary-output-dtype`
1318
- [`c6e2443`](https://github.com/stdlib-js/stdlib/commit/c6e24436d222d609c3ea153fd81f31e1d16451bc) - add `ndarray/base/ternary` [(#9566)](https://github.com/stdlib-js/stdlib/pull/9566)
1419
- [`1aff763`](https://github.com/stdlib-js/stdlib/commit/1aff763c61863b7d737a699db89729d2bba0e1bc) - add `ndarray/spread-dimensions` [(#9424)](https://github.com/stdlib-js/stdlib/pull/9424)
1520
- [`3c567b6`](https://github.com/stdlib-js/stdlib/commit/3c567b634cf5e5fa5e31b64f94206db5b4a88133) - update `ndarray/base` TypeScript declarations (#9640) [(#9640)](https://github.com/stdlib-js/stdlib/pull/9640)
@@ -703,6 +708,12 @@ A total of 40 issues were closed in this release:
703708

704709
<details>
705710

711+
- [`fdfdf13`](https://github.com/stdlib-js/stdlib/commit/fdfdf139a4f787dd67d5cdcf94130bf6469c92a2) - **docs:** fix example to ensure valid type promotion _(by Athan Reines)_
712+
- [`f738a37`](https://github.com/stdlib-js/stdlib/commit/f738a37c1cc32a740c7ecc4cbc7982eca26f67d2) - **feat:** add `ternaryBlockSize` to namespace _(by Athan Reines)_
713+
- [`b490370`](https://github.com/stdlib-js/stdlib/commit/b49037059ac498f7e864cb83f0cf59b3feb3b459) - **feat:** add `ternaryLoopOrder` to namespace _(by Athan Reines)_
714+
- [`88e4096`](https://github.com/stdlib-js/stdlib/commit/88e4096e8e5941fecc15ef2fd2d5b27e91d69233) - **feat:** add `ternary` to namespace _(by Athan Reines)_
715+
- [`5fbedba`](https://github.com/stdlib-js/stdlib/commit/5fbedba2f71e2c6a20c33f0de574d0060536c0f5) - **feat:** add `ternaryOutputDataType` to namespace _(by Athan Reines)_
716+
- [`9d38a93`](https://github.com/stdlib-js/stdlib/commit/9d38a9324e99a3a00f733b30a37510e8d1e4b6a4) - **feat:** add `ndarray/base/ternary-output-dtype` _(by Athan Reines)_
706717
- [`6d4630b`](https://github.com/stdlib-js/stdlib/commit/6d4630be9a3d2d65b464ca289db0c8db452466f2) - **docs:** update to support data type objects and be opaque regarding return value _(by Athan Reines)_
707718
- [`4f2cdaa`](https://github.com/stdlib-js/stdlib/commit/4f2cdaafcee4670fb5b1b5f562d445d7367c8404) - **docs:** update to support data type objects and be opaque regarding return value _(by Athan Reines)_
708719
- [`c6e2443`](https://github.com/stdlib-js/stdlib/commit/c6e24436d222d609c3ea153fd81f31e1d16451bc) - **feat:** add `ndarray/base/ternary` [(#9566)](https://github.com/stdlib-js/stdlib/pull/9566) _(by Muhammad Haris, Athan Reines)_

base/lib/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,42 @@ setReadOnly( ns, 'strides2order', require( './../../base/strides2order' ) );
12011201
*/
12021202
setReadOnly( ns, 'sub2ind', require( './../../base/sub2ind' ) );
12031203

1204+
/**
1205+
* @name ternary
1206+
* @memberof ns
1207+
* @readonly
1208+
* @type {Function}
1209+
* @see {@link module:@stdlib/ndarray/base/ternary}
1210+
*/
1211+
setReadOnly( ns, 'ternary', require( './../../base/ternary' ) );
1212+
1213+
/**
1214+
* @name ternaryLoopOrder
1215+
* @memberof ns
1216+
* @readonly
1217+
* @type {Function}
1218+
* @see {@link module:@stdlib/ndarray/base/ternary-loop-interchange-order}
1219+
*/
1220+
setReadOnly( ns, 'ternaryLoopOrder', require( './../../base/ternary-loop-interchange-order' ) );
1221+
1222+
/**
1223+
* @name ternaryOutputDataType
1224+
* @memberof ns
1225+
* @readonly
1226+
* @type {Function}
1227+
* @see {@link module:@stdlib/ndarray/base/ternary-output-dtype}
1228+
*/
1229+
setReadOnly( ns, 'ternaryOutputDataType', require( './../../base/ternary-output-dtype' ) );
1230+
1231+
/**
1232+
* @name ternaryBlockSize
1233+
* @memberof ns
1234+
* @readonly
1235+
* @type {Function}
1236+
* @see {@link module:@stdlib/ndarray/base/ternary-tiling-block-size}
1237+
*/
1238+
setReadOnly( ns, 'ternaryBlockSize', require( './../../base/ternary-tiling-block-size' ) );
1239+
12041240
/**
12051241
* @name ndarray2array
12061242
* @memberof ns
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 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+
# ternaryOutputDataType
22+
23+
> Resolve the output ndarray [data type][@stdlib/ndarray/dtypes] for a ternary function.
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 ternaryOutputDataType = require( '@stdlib/ndarray/base/ternary-output-dtype' );
41+
```
42+
43+
#### ternaryOutputDataType( xdtype, ydtype, zdtype, policy )
44+
45+
Resolves the output ndarray [data type][@stdlib/ndarray/dtypes] for a ternary function according to a [data type policy][@stdlib/ndarray/output-dtype-policies].
46+
47+
```javascript
48+
var dt = ternaryOutputDataType( 'int32', 'float32', 'float32', 'floating_point' );
49+
50+
var s = String( dt );
51+
// returns 'float64'
52+
```
53+
54+
The function supports the following parameters:
55+
56+
- **xdtype**: first input ndarray [data type][@stdlib/ndarray/dtypes].
57+
- **ydtype**: second input ndarray [data type][@stdlib/ndarray/dtypes].
58+
- **zdtype**: third input ndarray [data type][@stdlib/ndarray/dtypes].
59+
- **policy**: output [data type policy][@stdlib/ndarray/output-dtype-policies].
60+
61+
If `policy` is a [data type][@stdlib/ndarray/dtypes], the function always returns the `policy` value (i.e., the third argument).
62+
63+
```javascript
64+
var dt = ternaryOutputDataType( 'float32', 'float32', 'float32', 'float64' );
65+
66+
var s = String( dt );
67+
// returns 'float64'
68+
69+
dt = ternaryOutputDataType( 'int32', 'int8', 'int32', 'float64' );
70+
71+
s = String( dt );
72+
// returns 'float64'
73+
74+
// ...
75+
```
76+
77+
</section>
78+
79+
<!-- /.usage -->
80+
81+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
82+
83+
<section class="notes">
84+
85+
## Notes
86+
87+
- The function **always** applies [type promotion][@stdlib/ndarray/promotion-rules] to the provided data types, except for the following [data type policies][@stdlib/ndarray/output-dtype-policies]:
88+
89+
- `default`
90+
- `default_index`
91+
- `same`
92+
- `<dtype>`
93+
94+
</section>
95+
96+
<!-- /.notes -->
97+
98+
<!-- Package usage examples. -->
99+
100+
<section class="examples">
101+
102+
## Examples
103+
104+
<!-- eslint no-undef: "error" -->
105+
106+
```javascript
107+
var naryFunction = require( '@stdlib/utils/nary-function' );
108+
var unzip = require( '@stdlib/utils/unzip' );
109+
var nCartesianProduct = require( '@stdlib/array/base/n-cartesian-product' );
110+
var dtypes = require( '@stdlib/ndarray/dtypes' );
111+
var logEachMap = require( '@stdlib/console/log-each-map' );
112+
var ternaryOutputDataType = require( '@stdlib/ndarray/base/ternary-output-dtype' );
113+
114+
// Get the list of real-valued floating-point data types:
115+
var dt = dtypes( 'real_floating_point' );
116+
117+
// Define a list of output data type policies:
118+
var policies = [
119+
'default',
120+
'real',
121+
'floating_point',
122+
'complex_floating_point'
123+
];
124+
125+
// Generate dtype-policy Cartesian products:
126+
var args = nCartesianProduct( dt, dt, dt, policies );
127+
128+
// Unzip the argument pair array:
129+
args = unzip( args );
130+
131+
// Resolve output data types:
132+
logEachMap( 'dtypes: (%7s, %7s, %7s). policy: %-24s. output dtype: %s.', args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ], naryFunction( ternaryOutputDataType, 4 ) );
133+
```
134+
135+
</section>
136+
137+
<!-- /.examples -->
138+
139+
<!-- 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. -->
140+
141+
<section class="references">
142+
143+
</section>
144+
145+
<!-- /.references -->
146+
147+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
148+
149+
<section class="related">
150+
151+
</section>
152+
153+
<!-- /.related -->
154+
155+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
156+
157+
<section class="links">
158+
159+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
160+
161+
[@stdlib/ndarray/output-dtype-policies]: https://github.com/stdlib-js/ndarray/tree/main/output-dtype-policies
162+
163+
[@stdlib/ndarray/promotion-rules]: https://github.com/stdlib-js/ndarray/tree/main/promotion-rules
164+
165+
</section>
166+
167+
<!-- /.links -->

0 commit comments

Comments
 (0)