You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,13 @@
4
4
5
5
<section class="release" id="unreleased">
6
6
7
-
## Unreleased (2026-09-16)
7
+
## Unreleased (2026-09-18)
8
8
9
9
<section class="features">
10
10
11
11
### Features
12
12
13
+
- [`13c6723`](https://github.com/stdlib-js/stdlib/commit/13c6723b3f9f5cb9aa3169eadaeb88e03be5e23c) - add float16 dtype support to `ndarray/min-dtype` [(#15290)](https://github.com/stdlib-js/stdlib/pull/15290)
13
14
- [`abd365a`](https://github.com/stdlib-js/stdlib/commit/abd365a80596e407afc42fe806b2c113857423d4) - add float16 dtype support to `ndarray/filter-map` [(#15234)](https://github.com/stdlib-js/stdlib/pull/15234)
14
15
- [`551a13c`](https://github.com/stdlib-js/stdlib/commit/551a13c30bc3e5d0079e2163a759a037481b58ff) - add float16 dtype support to `ndarray/for-each` [(#15236)](https://github.com/stdlib-js/stdlib/pull/15236)
15
16
- [`4ba080a`](https://github.com/stdlib-js/stdlib/commit/4ba080a0f00815a1e00c81a0a063724b4cedc268) - add float16 dtype support to `ndarray/nans-like` [(#15252)](https://github.com/stdlib-js/stdlib/pull/15252)
@@ -109,6 +110,7 @@ A total of 4 issues were closed in this release:
109
110
110
111
<details>
111
112
113
+
- [`13c6723`](https://github.com/stdlib-js/stdlib/commit/13c6723b3f9f5cb9aa3169eadaeb88e03be5e23c) - **feat:** add float16 dtype support to `ndarray/min-dtype` [(#15290)](https://github.com/stdlib-js/stdlib/pull/15290) _(by Samarth Kolarkar)_
112
114
- [`abd365a`](https://github.com/stdlib-js/stdlib/commit/abd365a80596e407afc42fe806b2c113857423d4) - **feat:** add float16 dtype support to `ndarray/filter-map` [(#15234)](https://github.com/stdlib-js/stdlib/pull/15234) _(by Samarth Kolarkar)_
113
115
- [`551a13c`](https://github.com/stdlib-js/stdlib/commit/551a13c30bc3e5d0079e2163a759a037481b58ff) - **feat:** add float16 dtype support to `ndarray/for-each` [(#15236)](https://github.com/stdlib-js/stdlib/pull/15236) _(by Samarth Kolarkar)_
114
116
- [`4ba080a`](https://github.com/stdlib-js/stdlib/commit/4ba080a0f00815a1e00c81a0a063724b4cedc268) - **feat:** add float16 dtype support to `ndarray/nans-like` [(#15252)](https://github.com/stdlib-js/stdlib/pull/15252) _(by Samarth Kolarkar)_
// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`...
73
+
// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing in a smaller precision...
61
74
if(
62
-
value>-FLOAT32_SMALLEST_SUBNORMAL&&
63
-
value<FLOAT32_SMALLEST_SUBNORMAL
75
+
value>-FLOAT16_SMALLEST_SUBNORMAL&&
76
+
value<FLOAT16_SMALLEST_SUBNORMAL
64
77
){
65
-
return'float64';
78
+
if(
79
+
value>-FLOAT32_SMALLEST_SUBNORMAL&&
80
+
value<FLOAT32_SMALLEST_SUBNORMAL
81
+
){
82
+
return'float64';
83
+
}
84
+
return'float32';
85
+
}
86
+
if(value>=-FLOAT16_MAX&&value<=FLOAT16_MAX){
87
+
return'float16';
66
88
}
67
89
// Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)...
68
90
return'float32';
@@ -79,7 +101,7 @@ function minFloatDataType( value ) {
79
101
*
80
102
* @example
81
103
* var dt = minDataType( 3.141592653589793 );
82
-
* // returns 'float32'
104
+
* // returns 'float16'
83
105
*
84
106
* @example
85
107
* var dt = minDataType( 3 );
@@ -99,11 +121,11 @@ function minDataType( value ) {
99
121
return'generic';
100
122
}
101
123
if(value!==value||value===PINF||value===NINF){
102
-
return'float32';
124
+
return'float16';
103
125
}
104
126
if(isInteger(value)){
105
127
if(value===0&&isNegativeZero(value)){
106
-
return'float32';
128
+
return'float16';
107
129
}
108
130
if(value<0){
109
131
if(value>=INT8_MIN){
@@ -128,12 +150,21 @@ function minDataType( value ) {
128
150
}
129
151
return'float64';
130
152
}
131
-
// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`...
153
+
// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing in a smaller precision...
132
154
if(
133
-
value>-FLOAT32_SMALLEST_SUBNORMAL&&
134
-
value<FLOAT32_SMALLEST_SUBNORMAL
155
+
value>-FLOAT16_SMALLEST_SUBNORMAL&&
156
+
value<FLOAT16_SMALLEST_SUBNORMAL
135
157
){
136
-
return'float64';
158
+
if(
159
+
value>-FLOAT32_SMALLEST_SUBNORMAL&&
160
+
value<FLOAT32_SMALLEST_SUBNORMAL
161
+
){
162
+
return'float64';
163
+
}
164
+
return'float32';
165
+
}
166
+
if(value>=-FLOAT16_MAX&&value<=FLOAT16_MAX){
167
+
return'float16';
137
168
}
138
169
// Any number which reaches this point is less than the maximum single-precision floating-point number, given that floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)...
@@ -36,7 +36,7 @@ tape( 'main export is a function', function test( t ) {
36
36
t.end();
37
37
});
38
38
39
-
tape('the function returns the minimum ndarray data type of the closest "kind" necessary for storing a provided scalar value',functiontest(t){
39
+
tape('the function returns the minimum ndarray data type of the closest "kind" necessary for storing a provided real scalar value',functiontest(t){
40
40
varexpected;
41
41
varactual;
42
42
varvalues;
@@ -57,8 +57,14 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
57
57
-4294967297,
58
58
3.14,
59
59
-3.14,
60
+
70000.5,
61
+
-70000.5,
62
+
1.0e20,// >10**5
63
+
-1.0e20,
60
64
1.0e40,// >10**38
61
65
-1.0e40,
66
+
-1.0e-10,// <10**-7
67
+
1.0e-10,
62
68
-1.0e-46,// <10**-45
63
69
1.0e-46,
64
70
PINF,
@@ -67,7 +73,57 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
67
73
{},
68
74
true,
69
75
false,
70
-
[],
76
+
[]
77
+
];
78
+
expected=[
79
+
'float16',
80
+
'uint8',
81
+
'uint8',
82
+
'float16',
83
+
'uint8',
84
+
'int8',
85
+
'uint16',
86
+
'int16',
87
+
'uint32',
88
+
'int32',
89
+
'float64',
90
+
'float64',
91
+
'float16',
92
+
'float16',
93
+
'float32',
94
+
'float32',
95
+
'float64',
96
+
'float64',
97
+
'float64',
98
+
'float64',
99
+
'float32',
100
+
'float32',
101
+
'float64',
102
+
'float64',
103
+
'float16',
104
+
'float16',
105
+
'generic',
106
+
'generic',
107
+
'bool',
108
+
'bool',
109
+
'generic'
110
+
];
111
+
for(i=0;i<values.length;i++){
112
+
actual=minDataType(values[i]);
113
+
t.strictEqual(actual,expected[i],'returns expected value when provided '+values[i]);
114
+
}
115
+
t.end();
116
+
});
117
+
118
+
tape('the function returns the minimum ndarray data type of the closest "kind" necessary for storing a provided complex number or other value',functiontest(t){
119
+
varexpected;
120
+
varactual;
121
+
varvalues;
122
+
vari;
123
+
124
+
values=[
125
+
newComplex64(3.0,5.0),
126
+
newComplex128(3.0,5.0),
71
127
newComplex64(1.0,1.0),
72
128
newComplex64(NaN,NaN),
73
129
newComplex64(PINF,PINF),
@@ -92,6 +148,22 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
92
148
newComplex128(1.0e40,1.0),
93
149
newComplex128(1.0,-1.0e40),
94
150
newComplex128(1.0,1.0e40),
151
+
newComplex128(-1.0e10,1.0),
152
+
newComplex128(1.0e10,1.0),
153
+
newComplex128(1.0,-1.0e10),
154
+
newComplex128(1.0,1.0e10),
155
+
newComplex128(-1.0e-10,1.0),
156
+
newComplex128(1.0e-10,1.0),
157
+
newComplex128(1.0,-1.0e-10),
158
+
newComplex128(1.0,1.0e-10),
159
+
newComplex128(-70000.5,1.0),
160
+
newComplex128(70000.5,1.0),
161
+
newComplex128(1.0,-70000.5),
162
+
newComplex128(1.0,70000.5),
163
+
newComplex128(-30000.0,1.0),
164
+
newComplex128(30000.0,1.0),
165
+
newComplex128(1.0,-30000.0),
166
+
newComplex128(1.0,30000.0),
95
167
96
168
{
97
169
're': 3.0,
@@ -152,34 +224,17 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
152
224
{
153
225
're': 3.0,
154
226
'im': 3.14
227
+
},
228
+
{
229
+
're': 70000.5,
230
+
'im': 5.0
231
+
},
232
+
{
233
+
're': 3.0,
234
+
'im': 70000.5
155
235
}
156
236
];
157
237
expected=[
158
-
'float32',
159
-
'uint8',
160
-
'uint8',
161
-
'float32',
162
-
'uint8',
163
-
'int8',
164
-
'uint16',
165
-
'int16',
166
-
'uint32',
167
-
'int32',
168
-
'float64',
169
-
'float64',
170
-
'float32',
171
-
'float32',
172
-
'float64',
173
-
'float64',
174
-
'float64',
175
-
'float64',
176
-
'float32',
177
-
'float32',
178
-
'generic',
179
-
'generic',
180
-
'bool',
181
-
'bool',
182
-
'generic',
183
238
'complex64',
184
239
'complex64',
185
240
'complex64',
@@ -196,6 +251,10 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
196
251
'complex64',
197
252
'complex64',
198
253
'complex64',
254
+
'complex64',
255
+
'complex64',
256
+
'complex128',
257
+
'complex128',
199
258
'complex128',
200
259
'complex128',
201
260
'complex128',
@@ -204,6 +263,20 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
204
263
'complex128',
205
264
'complex128',
206
265
'complex128',
266
+
'complex128',
267
+
'complex128',
268
+
'complex64',
269
+
'complex64',
270
+
'complex64',
271
+
'complex64',
272
+
'complex64',
273
+
'complex64',
274
+
'complex64',
275
+
'complex64',
276
+
'complex64',
277
+
'complex64',
278
+
'complex64',
279
+
'complex64',
207
280
208
281
'complex64',
209
282
'complex128',
@@ -219,6 +292,8 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
0 commit comments