Skip to content

Commit 10c1214

Browse files
committed
Auto-generated commit
1 parent b2174c7 commit 10c1214

13 files changed

Lines changed: 3182 additions & 0 deletions

File tree

‎CHANGELOG.md‎

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

1111
### Features
1212

13+
- [`076901c`](https://github.com/stdlib-js/stdlib/commit/076901c672593ebd8c51ea92d80257164ff473e7) - add `Int8Matrix` to namespace
14+
- [`3d3964d`](https://github.com/stdlib-js/stdlib/commit/3d3964d2989150c60a947c8e79fb1303b47ca57a) - add `ndarray/matrix/int8`
1315
- [`3feb10e`](https://github.com/stdlib-js/stdlib/commit/3feb10e049fe73e8266d330bd3db05f347386b16) - update `ndarray/matrix` TypeScript declarations [(#16392)](https://github.com/stdlib-js/stdlib/pull/16392)
1416
- [`925ccb5`](https://github.com/stdlib-js/stdlib/commit/925ccb5f7f70f2de33d753bca8195bf6eda56acb) - add `Uint16Matrix` to namespace
1517
- [`620f4d8`](https://github.com/stdlib-js/stdlib/commit/620f4d87c96842943e7583bfe6928228fb0a9a79) - add `ndarray/matrix/uint16`
@@ -155,6 +157,8 @@ A total of 5 issues were closed in this release:
155157

156158
<details>
157159

160+
- [`076901c`](https://github.com/stdlib-js/stdlib/commit/076901c672593ebd8c51ea92d80257164ff473e7) - **feat:** add `Int8Matrix` to namespace _(by Athan Reines)_
161+
- [`3d3964d`](https://github.com/stdlib-js/stdlib/commit/3d3964d2989150c60a947c8e79fb1303b47ca57a) - **feat:** add `ndarray/matrix/int8` _(by Athan Reines)_
158162
- [`7cf9cbb`](https://github.com/stdlib-js/stdlib/commit/7cf9cbb58cd7ba3416fb243be57d7779d57c7770) - **docs:** update namespace table of contents [(#16395)](https://github.com/stdlib-js/stdlib/pull/16395) _(by stdlib-bot)_
159163
- [`3feb10e`](https://github.com/stdlib-js/stdlib/commit/3feb10e049fe73e8266d330bd3db05f347386b16) - **feat:** update `ndarray/matrix` TypeScript declarations [(#16392)](https://github.com/stdlib-js/stdlib/pull/16392) _(by stdlib-bot)_
160164
- [`925ccb5`](https://github.com/stdlib-js/stdlib/commit/925ccb5f7f70f2de33d753bca8195bf6eda56acb) - **feat:** add `Uint16Matrix` to namespace _(by Athan Reines)_

‎matrix/int8/README.md‎

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
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+
# Int8Matrix
22+
23+
> Create an 8-bit signed integer matrix (i.e., a two-dimensional [ndarray][@stdlib/ndarray/ctor]).
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 Int8Matrix = require( '@stdlib/ndarray/matrix/int8' );
41+
```
42+
43+
#### Int8Matrix( \[options] )
44+
45+
Returns a two-dimensional 8-bit signed integer [ndarray][@stdlib/ndarray/ctor].
46+
47+
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
49+
50+
var arr = new Int8Matrix();
51+
// returns <ndarray>
52+
53+
var len = getShape( arr );
54+
// returns [ 0, 0 ]
55+
```
56+
57+
The function accepts the following options:
58+
59+
- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`.
60+
- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`.
61+
- **submode**: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). If provided fewer modes than dimensions, an [`ndarray`][@stdlib/ndarray/ctor]) instance recycles modes using modulo arithmetic. Default: `[ options.mode ]`.
62+
- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`.
63+
64+
#### Int8Matrix( shape\[, options] )
65+
66+
Returns a two-dimensional 8-bit signed integer [ndarray][@stdlib/ndarray/ctor] having a specified shape.
67+
68+
```javascript
69+
var getShape = require( '@stdlib/ndarray/shape' );
70+
71+
var arr = new Int8Matrix( [ 3, 3 ] );
72+
// returns <ndarray>
73+
74+
var sh = getShape( arr );
75+
// returns [ 3, 3 ]
76+
```
77+
78+
The function accepts the following arguments:
79+
80+
- **shape**: array shape. Must contain exactly two elements.
81+
- **options**: function options. See above.
82+
83+
#### Int8Matrix( M, N\[, options] )
84+
85+
Returns a two-dimensional 8-bit signed integer [ndarray][@stdlib/ndarray/ctor] having a specified shape.
86+
87+
```javascript
88+
var getShape = require( '@stdlib/ndarray/shape' );
89+
90+
var arr = new Int8Matrix( 3, 3 );
91+
// returns <ndarray>
92+
93+
var sh = getShape( arr );
94+
// returns [ 3, 3 ]
95+
```
96+
97+
The function accepts the following arguments:
98+
99+
- **M**: number of rows.
100+
- **N**: number of columns.
101+
- **options**: function options. See above.
102+
103+
#### Int8Matrix( obj\[, options] )
104+
105+
Creates a two-dimensional 8-bit signed integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable.
106+
107+
```javascript
108+
var getShape = require( '@stdlib/ndarray/shape' );
109+
110+
var arr = new Int8Matrix( [ [ 1, 2 ], [ 3, 4 ] ] );
111+
// returns <ndarray>
112+
113+
var sh = getShape( arr );
114+
// returns [ 2, 2 ]
115+
```
116+
117+
The function accepts the following arguments:
118+
119+
- **obj**: array-like object or iterable from which to generate an [ndarray][@stdlib/ndarray/ctor]. If an array-like object, the value must be a nested array (i.e., an array-like object of array-like objects), where each nested array must have the same number of elements. If an iterable, the iterable must return array-like objects, each of which must have the same number of elements.
120+
- **options**: function options. See above.
121+
122+
#### Int8Matrix( buffer\[, byteOffset\[, shape]]\[, options] )
123+
124+
Returns a two-dimensional 8-bit signed integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer].
125+
126+
```javascript
127+
var ArrayBuffer = require( '@stdlib/array/buffer' );
128+
var getShape = require( '@stdlib/ndarray/shape' );
129+
130+
var buf = new ArrayBuffer( 64 );
131+
132+
var arr1 = new Int8Matrix( buf );
133+
// returns <ndarray>
134+
135+
var sh1 = getShape( arr1 );
136+
// returns [ 1, 64 ]
137+
138+
var arr2 = new Int8Matrix( buf, 16 );
139+
// returns <ndarray>
140+
141+
var sh2 = getShape( arr2 );
142+
// returns [ 1, 48 ]
143+
144+
var arr3 = new Int8Matrix( buf, 16, [ 2, 1 ] );
145+
// returns <ndarray>
146+
147+
var sh3 = getShape( arr3 );
148+
// returns [ 2, 1 ]
149+
```
150+
151+
The function accepts the following arguments:
152+
153+
- **buffer**: underlying [`ArrayBuffer`][@stdlib/array/buffer].
154+
- **byteOffset**: integer byte offset specifying the location of the first indexed element. Default: `0`.
155+
- **shape**: array shape. Must contain exactly two elements.
156+
- **options**: function options. See above.
157+
158+
#### Int8Matrix( buffer\[, byteOffset\[, M, N]]\[, options] )
159+
160+
Returns a two-dimensional 8-bit signed integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer].
161+
162+
```javascript
163+
var ArrayBuffer = require( '@stdlib/array/buffer' );
164+
var getShape = require( '@stdlib/ndarray/shape' );
165+
166+
var buf = new ArrayBuffer( 64 );
167+
168+
var arr = new Int8Matrix( buf, 16, 2, 1 );
169+
// returns <ndarray>
170+
171+
var sh = getShape( arr );
172+
// returns [ 2, 1 ]
173+
```
174+
175+
The function accepts the following arguments:
176+
177+
- **buffer**: underlying [`ArrayBuffer`][@stdlib/array/buffer].
178+
- **byteOffset**: integer byte offset specifying the location of the first indexed element. Default: `0`.
179+
- **M**: number of rows.
180+
- **N**: number of columns.
181+
- **options**: function options. See above.
182+
183+
</section>
184+
185+
<!-- /.usage -->
186+
187+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
188+
189+
<section class="notes">
190+
191+
## Notes
192+
193+
- Nested arrays are flattened in lexicographic order, such that, for an input nested array `obj`, `obj[i][j]` corresponds to the element `mat.get(i, j)` in the returned two-dimensional ndarray. In other words, an input nested array is assumed to be comprised of rows. Similarly, if `obj` is an iterable, each array returned by the iterable is assumed to correspond to a matrix row.
194+
- If provided an `ArrayBuffer` without corresponding shape arguments, the leading dimension of the returned ndarray always has a size of one.
195+
196+
</section>
197+
198+
<!-- /.notes -->
199+
200+
<!-- Package usage examples. -->
201+
202+
<section class="examples">
203+
204+
## Examples
205+
206+
<!-- eslint no-undef: "error" -->
207+
208+
```javascript
209+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
210+
var sum = require( '@stdlib/blas/ext/sum' );
211+
var map = require( '@stdlib/ndarray/map' );
212+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
213+
var Int8Matrix = require( '@stdlib/ndarray/matrix/int8' );
214+
215+
// Create a matrix containing random values:
216+
var x = new Int8Matrix([
217+
discreteUniform( 10, 0, 100 ),
218+
discreteUniform( 10, 0, 20 )
219+
]);
220+
221+
// Compute the sum along the columns:
222+
var v = sum( x, {
223+
'dims': [ -1 ]
224+
});
225+
console.log( ndarray2array( v ) );
226+
227+
// Define a function which applies a threshold to individual values:
228+
function threshold( v ) {
229+
return ( v > 10 ) ? v : 0;
230+
}
231+
232+
// Apply threshold:
233+
var y = map( x, threshold );
234+
235+
// Recompute the sum along the columns:
236+
v = sum( y, {
237+
'dims': [ -1 ]
238+
});
239+
console.log( ndarray2array( v ) );
240+
```
241+
242+
</section>
243+
244+
<!-- /.examples -->
245+
246+
<!-- 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. -->
247+
248+
<section class="references">
249+
250+
</section>
251+
252+
<!-- /.references -->
253+
254+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
255+
256+
<section class="related">
257+
258+
</section>
259+
260+
<!-- /.related -->
261+
262+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
263+
264+
<section class="links">
265+
266+
[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer
267+
268+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
269+
270+
</section>
271+
272+
<!-- /.links -->

‎matrix/int8/benchmark/benchmark.js‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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 pkg = require( './../package.json' ).name;
26+
var Int8Matrix = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var arr;
33+
var i;
34+
b.tic();
35+
for ( i = 0; i < b.iterations; i++ ) {
36+
arr = new Int8Matrix( 0, 0 );
37+
if ( arr.length !== 0 ) {
38+
b.fail( 'should have length 0' );
39+
}
40+
}
41+
b.toc();
42+
if ( !isndarrayLike( arr ) ) {
43+
b.fail( 'should return an ndarray' );
44+
}
45+
b.pass( 'benchmark finished' );
46+
b.end();
47+
});

0 commit comments

Comments
 (0)