Skip to content

Commit d521058

Browse files
committed
Auto-generated commit
1 parent ecf27c3 commit d521058

11 files changed

Lines changed: 905 additions & 0 deletions

File tree

CHANGELOG.md

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

1111
### Features
1212

13+
- [`5bab5d6`](https://github.com/stdlib-js/stdlib/commit/5bab5d6fd4f4354b77acf67065c1921c9f8ccfed) - add `blas/ext/base/ndarray/striu` [(#14102)](https://github.com/stdlib-js/stdlib/pull/14102)
1314
- [`2591722`](https://github.com/stdlib-js/stdlib/commit/25917224ea51893f8c3ba4b3d9f8eea0bb6795a3) - add `dtriu` to namespace
1415
- [`2f72a61`](https://github.com/stdlib-js/stdlib/commit/2f72a61a6dc051964528b67be28329c3905f6d04) - add `cfillEqual` and `gtril2triu` to namespace
1516
- [`2e44e74`](https://github.com/stdlib-js/stdlib/commit/2e44e746a2ba82e39926d773524268fac83142f3) - add `blas/ext/base/ndarray/dtriu` [(#14089)](https://github.com/stdlib-js/stdlib/pull/14089)
@@ -471,6 +472,7 @@ A total of 4 issues were closed in this release:
471472

472473
<details>
473474

475+
- [`5bab5d6`](https://github.com/stdlib-js/stdlib/commit/5bab5d6fd4f4354b77acf67065c1921c9f8ccfed) - **feat:** add `blas/ext/base/ndarray/striu` [(#14102)](https://github.com/stdlib-js/stdlib/pull/14102) _(by Kaustubh Patange)_
474476
- [`2591722`](https://github.com/stdlib-js/stdlib/commit/25917224ea51893f8c3ba4b3d9f8eea0bb6795a3) - **feat:** add `dtriu` to namespace _(by Athan Reines)_
475477
- [`2f72a61`](https://github.com/stdlib-js/stdlib/commit/2f72a61a6dc051964528b67be28329c3905f6d04) - **feat:** add `cfillEqual` and `gtril2triu` to namespace _(by Athan Reines)_
476478
- [`2e44e74`](https://github.com/stdlib-js/stdlib/commit/2e44e746a2ba82e39926d773524268fac83142f3) - **feat:** add `blas/ext/base/ndarray/dtriu` [(#14089)](https://github.com/stdlib-js/stdlib/pull/14089) _(by Kaustubh Patange, Athan Reines)_

ext/base/ndarray/striu/README.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
# striu
22+
23+
> Copy the upper triangular part of a single-precision floating-point matrix `A` to another matrix `B`.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var striu = require( '@stdlib/blas/ext/base/ndarray/striu' );
37+
```
38+
39+
#### striu( arrays )
40+
41+
Copies the upper triangular part of a single-precision floating-point matrix `A` to another matrix `B`.
42+
43+
```javascript
44+
var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' );
45+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
46+
47+
var A = new Float32Matrix( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
48+
var B = new Float32Matrix( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] );
49+
50+
var k = scalar2ndarray( 0, {
51+
'dtype': 'generic'
52+
});
53+
54+
var out = striu( [ A, B, k ] );
55+
// returns <ndarray>[ [ 1.0, 2.0 ], [ 0.0, 4.0 ] ]
56+
57+
var bool = ( out === B );
58+
// returns true
59+
```
60+
61+
The function has the following parameters:
62+
63+
- **arrays**: array-like object containing the following ndarrays:
64+
65+
- a two-dimensional input ndarray corresponding to `A`.
66+
- a two-dimensional output ndarray corresponding to `B`.
67+
- a zero-dimensional ndarray specifying the diagonal below which to ignore. A value equal to zero refers to the main diagonal, greater than zero refers to a diagonal above the main diagonal, and less than zero refers to a diagonal below the main diagonal.
68+
69+
</section>
70+
71+
<!-- /.usage -->
72+
73+
<section class="notes">
74+
75+
## Notes
76+
77+
- Elements outside of the copied region are left unchanged.
78+
79+
</section>
80+
81+
<!-- /.notes -->
82+
83+
<section class="examples">
84+
85+
## Examples
86+
87+
<!-- eslint no-undef: "error" -->
88+
89+
```javascript
90+
var discreteUniform = require( '@stdlib/random/discrete-uniform' );
91+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
92+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
93+
var striu = require( '@stdlib/blas/ext/base/ndarray/striu' );
94+
95+
var opts = {
96+
'dtype': 'float32'
97+
};
98+
99+
var A = discreteUniform( [ 5, 5 ], -50, 50, opts );
100+
console.log( ndarray2array( A ) );
101+
102+
var B = discreteUniform( [ 5, 5 ], -50, 50, opts );
103+
console.log( ndarray2array( B ) );
104+
105+
var k = scalar2ndarray( 0, {
106+
'dtype': 'generic'
107+
});
108+
109+
var out = striu( [ A, B, k ] );
110+
console.log( ndarray2array( out ) );
111+
```
112+
113+
</section>
114+
115+
<!-- /.examples -->
116+
117+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
118+
119+
<section class="related">
120+
121+
</section>
122+
123+
<!-- /.related -->
124+
125+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
126+
127+
<section class="links">
128+
129+
</section>
130+
131+
<!-- /.links -->
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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 uniform = require( '@stdlib/random/uniform' );
25+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var format = require( '@stdlib/string/format' );
28+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
29+
var pkg = require( './../package.json' ).name;
30+
var striu = require( './../lib' );
31+
32+
33+
// VARIABLES //
34+
35+
var options = {
36+
'dtype': 'float32'
37+
};
38+
39+
40+
// FUNCTIONS //
41+
42+
/**
43+
* Creates a benchmark function.
44+
*
45+
* @private
46+
* @param {PositiveInteger} len - array length
47+
* @returns {Function} benchmark function
48+
*/
49+
function createBenchmark( len ) {
50+
var A = uniform( [ len, len ], -100.0, 100.0, options );
51+
var B = uniform( [ len, len ], -100.0, 100.0, options );
52+
53+
var k = scalar2ndarray( 0, {
54+
'dtype': 'generic'
55+
});
56+
57+
return benchmark;
58+
59+
/**
60+
* Benchmark function.
61+
*
62+
* @private
63+
* @param {Benchmark} b - benchmark instance
64+
*/
65+
function benchmark( b ) {
66+
var out;
67+
var i;
68+
69+
b.tic();
70+
for ( i = 0; i < b.iterations; i++ ) {
71+
out = striu( [ A, B, k ] );
72+
if ( typeof out !== 'object' ) {
73+
b.fail( 'should return an ndarray' );
74+
}
75+
}
76+
b.toc();
77+
if ( isnanf( out.get( i%len, i%len ) ) ) {
78+
b.fail( 'should not return NaN' );
79+
}
80+
b.pass( 'benchmark finished' );
81+
b.end();
82+
}
83+
}
84+
85+
86+
// MAIN //
87+
88+
/**
89+
* Main execution sequence.
90+
*
91+
* @private
92+
*/
93+
function main() {
94+
var len;
95+
var min;
96+
var max;
97+
var f;
98+
var i;
99+
100+
min = 1; // 10^min
101+
max = 3; // 10^max
102+
103+
for ( i = min; i <= max; i++ ) {
104+
len = pow( 10, i );
105+
f = createBenchmark( len );
106+
bench( format( '%s:len=%d', pkg, len ), f );
107+
}
108+
}
109+
110+
main();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
{{alias}}( arrays )
3+
Copies the upper triangular part of a single-precision floating-point matrix
4+
`A` to another matrix `B`.
5+
6+
The diagonal parameter `k` specifies the diagonal below which to ignore. A
7+
value of `k = 0` refers to the main diagonal, `k > 0` refers to a diagonal
8+
above the main diagonal, and `k < 0` refers to a diagonal below the main
9+
diagonal.
10+
11+
Parameters
12+
----------
13+
arrays: ArrayLikeObject<ndarray>
14+
Array-like object containing the following ndarrays:
15+
16+
- a two-dimensional input ndarray corresponding to `A`.
17+
- a two-dimensional output ndarray corresponding to `B`.
18+
- a zero-dimensional ndarray specifying the diagonal below which to
19+
ignore.
20+
21+
Returns
22+
-------
23+
out: ndarray
24+
Output ndarray.
25+
26+
Examples
27+
--------
28+
> var abuf = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ];
29+
> var A = new {{alias:@stdlib/ndarray/matrix/float32}}( abuf );
30+
31+
> var bbuf = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ];
32+
> var B = new {{alias:@stdlib/ndarray/matrix/float32}}( bbuf );
33+
34+
> var k = {{alias:@stdlib/ndarray/from-scalar}}( 0, { 'dtype': 'generic' } );
35+
36+
> {{alias}}( [ A, B, k ] );
37+
> B
38+
<ndarray>[ [ 1.0, 2.0 ], [ 0.0, 4.0 ] ]
39+
40+
See Also
41+
--------
42+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { float32ndarray, typedndarray } from '@stdlib/types/ndarray';
24+
25+
/**
26+
* Copies the upper triangular part of a single-precision floating-point matrix `A` to another matrix `B`.
27+
*
28+
* ## Notes
29+
*
30+
* - The function expects the following ndarrays:
31+
*
32+
* - a two-dimensional input ndarray corresponding to `A`.
33+
* - a two-dimensional output ndarray corresponding to `B`.
34+
* - a zero-dimensional ndarray specifying the diagonal below which to ignore.
35+
*
36+
* @param arrays - array-like object containing ndarrays
37+
* @returns output ndarray
38+
*
39+
* @example
40+
* var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' );
41+
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
42+
*
43+
* var A = new Float32Matrix( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
44+
* var B = new Float32Matrix( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] );
45+
*
46+
* var k = scalar2ndarray( 0, {
47+
* 'dtype': 'generic'
48+
* });
49+
*
50+
* var out = striu( [ A, B, k ] );
51+
* // returns <ndarray>[ [ 1.0, 2.0 ], [ 0.0, 4.0 ] ]
52+
*
53+
* var bool = ( out === B );
54+
* // returns true
55+
*/
56+
declare function striu( arrays: [ float32ndarray, float32ndarray, typedndarray<number> ] ): float32ndarray;
57+
58+
59+
// EXPORTS //
60+
61+
export = striu;

0 commit comments

Comments
 (0)