Skip to content

Commit 816cef9

Browse files
committed
Auto-generated commit
1 parent 4999761 commit 816cef9

File tree

12 files changed

+1096
-2
lines changed

12 files changed

+1096
-2
lines changed

CHANGELOG.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-03-13)
7+
## Unreleased (2025-03-14)
88

99
<section class="packages">
1010

@@ -875,6 +875,28 @@ This release closes the following issue:
875875

876876
<!-- /.package -->
877877

878+
<section class="package" id="array-base-symmetric-banded-to-compact-unreleased">
879+
880+
#### [@stdlib/array/base/symmetric-banded/to-compact](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/symmetric-banded/to-compact)
881+
882+
<details>
883+
884+
<section class="features">
885+
886+
##### Features
887+
888+
- [`f9bb0d7`](https://github.com/stdlib-js/stdlib/commit/f9bb0d77a4ce5ad813c371f5d49d2cee7476b775) - add `array/base/symmetric-banded/to-compact`
889+
890+
</section>
891+
892+
<!-- /.features -->
893+
894+
</details>
895+
896+
</section>
897+
898+
<!-- /.package -->
899+
878900
<section class="package" id="array-base-symmetric-filled2d-by-unreleased">
879901

880902
#### [@stdlib/array/base/symmetric/filled2d-by](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/symmetric/filled2d-by)
@@ -1217,6 +1239,7 @@ A total of 13 people contributed to this release. Thank you to the following con
12171239

12181240
<details>
12191241

1242+
- [`f9bb0d7`](https://github.com/stdlib-js/stdlib/commit/f9bb0d77a4ce5ad813c371f5d49d2cee7476b775) - **feat:** add `array/base/symmetric-banded/to-compact` _(by Athan Reines)_
12201243
- [`1bb5ea9`](https://github.com/stdlib-js/stdlib/commit/1bb5ea9e19c1d89b1cb7504d8e369b7fea02e94d) - **test:** add test cases _(by Athan Reines)_
12211244
- [`6f20f70`](https://github.com/stdlib-js/stdlib/commit/6f20f707c3a94f5fb14b55144f52d2c1aa540c9f) - **feat:** add `array/base/banded/filled2d-by` _(by Athan Reines)_
12221245
- [`8e00e52`](https://github.com/stdlib-js/stdlib/commit/8e00e52bed8c7b4fec42c468bd021815a417b988) - **bench:** parameterize `k` _(by Athan Reines)_

CONTRIBUTORS

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Dan Rose <[email protected]>
3333
Daniel Killenberger <[email protected]>
3434
Daniel Yu <[email protected]>
3535
Debashis Maharana <[email protected]>
36+
Deep Trivedi <[email protected]>
3637
Desh Deepak Kant <[email protected]>
3738
3839
Dhanyabad behera <[email protected]>
@@ -99,7 +100,7 @@ Oneday12323 <[email protected]>
99100
Ori Miles <[email protected]>
100101
Philipp Burckhardt <[email protected]>
101102
Prajwal Kulkarni <[email protected]>
102-
Pranav Goswami <[email protected]>
103+
Pranav Goswami <[email protected]>
103104
Pranjal Jha <[email protected]>
104105
Prashant Kumar Yadav <[email protected]>
105106
Pratik Singh <[email protected]>
@@ -119,6 +120,7 @@ Rutam Kathale <[email protected]>
119120
Ruthwik Chikoti <[email protected]>
120121
Ryan Seal <[email protected]>
121122
Rylan Yang <[email protected]>
123+
SHIVAM YADAV <[email protected]>
122124
Sai Srikar Dumpeti <[email protected]>
123125
Sarthak Paandey <[email protected]>
124126
Saurabh Singh <[email protected]>
+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
# toCompact
22+
23+
> Convert a two-dimensional symmetric banded nested array to compact banded storage.
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 toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' );
41+
```
42+
43+
#### toCompact( uplo, arr, k, colexicographic )
44+
45+
Converts a two-dimensional symmetric banded nested array to compact banded storage.
46+
47+
```javascript
48+
var x = [ [ -1, 2, 0 ], [ 2, -2, 4 ], [ 0, 4, -3 ] ];
49+
50+
var out = toCompact( 'upper', x, 1, false );
51+
// returns [ [ 0, 2, 4 ], [ -1, -2, -3 ] ]
52+
```
53+
54+
The function accepts the following arguments:
55+
56+
- **uplo**: specifies whether to reference the upper or lower triangular part of the input array.
57+
- **arr**: input two-dimensional nested array.
58+
- **k**: number of super-/sub-diagonals.
59+
- **colexicographic**: boolean specifying whether to store diagonals in colexicographic access order.
60+
61+
</section>
62+
63+
<!-- /.usage -->
64+
65+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
66+
67+
<section class="notes">
68+
69+
</section>
70+
71+
<!-- /.notes -->
72+
73+
<!-- Package usage examples. -->
74+
75+
<section class="examples">
76+
77+
## Examples
78+
79+
<!-- eslint-disable no-multi-spaces -->
80+
81+
<!-- eslint no-undef: "error" -->
82+
83+
```javascript
84+
var toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' );
85+
86+
// Define a symmetric banded matrix:
87+
var A = [
88+
[ 1, 2, 3, 0, 0 ],
89+
[ 2, 4, 5, 6, 0 ],
90+
[ 3, 5, 7, 8, 9 ],
91+
[ 0, 6, 8, 10, 11 ],
92+
[ 0, 0, 9, 11, 12 ]
93+
];
94+
95+
// Convert the upper triangle to lexicographic compact form:
96+
var AC = toCompact( 'upper', A, 2, false );
97+
/* e.g., returns =>
98+
[
99+
[ 0, 0, 3, 6, 9 ],
100+
[ 0, 2, 5, 8, 11 ],
101+
[ 1, 4, 7, 10, 12 ]
102+
]
103+
*/
104+
105+
// Convert the lower triangle to lexicographic compact form:
106+
AC = toCompact( 'lower', A, 2, false );
107+
/* e.g., returns =>
108+
[
109+
[ 1, 4, 7, 10, 12 ],
110+
[ 2, 5, 8, 11, 0 ],
111+
[ 3, 6, 9, 0, 0 ]
112+
]
113+
*/
114+
115+
// Convert the upper triangle to colexicographic compact form:
116+
AC = toCompact( 'upper', A, 2, true );
117+
/* e.g., returns =>
118+
[
119+
[ 1, 2, 3 ],
120+
[ 4, 5, 6 ],
121+
[ 7, 8, 9 ],
122+
[ 10, 11, 0 ],
123+
[ 12, 0, 0 ]
124+
]
125+
*/
126+
127+
// Convert the lower triangle to colexicographic compact form:
128+
AC = toCompact( 'lower', A, 2, true );
129+
/* e.g., returns =>
130+
[
131+
[ 0, 0, 1 ],
132+
[ 0, 2, 4 ],
133+
[ 3, 5, 7 ],
134+
[ 6, 8, 10 ],
135+
[ 9, 11, 12 ]
136+
]
137+
*/
138+
```
139+
140+
</section>
141+
142+
<!-- /.examples -->
143+
144+
<!-- 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. -->
145+
146+
<section class="references">
147+
148+
</section>
149+
150+
<!-- /.references -->
151+
152+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
153+
154+
<section class="related">
155+
156+
</section>
157+
158+
<!-- /.related -->
159+
160+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
161+
162+
<section class="links">
163+
164+
</section>
165+
166+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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 pow = require( '@stdlib/math/base/special/pow' );
25+
var floor = require( '@stdlib/math/base/special/floor' );
26+
var sqrt = require( '@stdlib/math/base/special/sqrt' );
27+
var isArrayArray = require( '@stdlib/assert/is-array-array' );
28+
var constantFunction = require( '@stdlib/utils/constant-function' );
29+
var filled2dBy = require( './../../../../base/symmetric-banded/filled2d-by' );
30+
var format = require( '@stdlib/string/format' );
31+
var pkg = require( './../package.json' ).name;
32+
var toCompact = require( './../lib' );
33+
34+
35+
// VARIABLES //
36+
37+
var orders = [
38+
true,
39+
false
40+
];
41+
var uplo = [
42+
'upper',
43+
'lower'
44+
];
45+
46+
47+
// FUNCTIONS //
48+
49+
/**
50+
* Creates a benchmark function.
51+
*
52+
* @private
53+
* @param {PositiveInteger} N - array lengths
54+
* @param {string} uplo - specifies whether to reference to upper or lower triangle
55+
* @param {boolean} colexicographic - boolean indicating whether to store diagonals in colexicographic access order
56+
* @param {NonNegativeInteger} k - number of super-/sub-diagonals
57+
* @returns {Function} benchmark function
58+
*/
59+
function createBenchmark( N, uplo, colexicographic, k ) {
60+
var x = filled2dBy( N, k, 0, constantFunction( N ) );
61+
return benchmark;
62+
63+
/**
64+
* Benchmark function.
65+
*
66+
* @private
67+
* @param {Benchmark} b - benchmark instance
68+
*/
69+
function benchmark( b ) {
70+
var out;
71+
var i;
72+
73+
b.tic();
74+
for ( i = 0; i < b.iterations; i++ ) {
75+
out = toCompact( uplo, x, k, colexicographic );
76+
if ( typeof out !== 'object' ) {
77+
b.fail( 'should return an array of arrays' );
78+
}
79+
}
80+
b.toc();
81+
if ( !isArrayArray( out ) ) {
82+
b.fail( 'should return an array of arrays' );
83+
}
84+
b.pass( 'benchmark finished' );
85+
b.end();
86+
}
87+
}
88+
89+
90+
// MAIN //
91+
92+
/**
93+
* Main execution sequence.
94+
*
95+
* @private
96+
*/
97+
function main() {
98+
var min;
99+
var max;
100+
var N;
101+
var f;
102+
var i;
103+
var o;
104+
var u;
105+
var k;
106+
107+
min = 1; // 10^min
108+
max = 6; // 10^max
109+
110+
k = 2;
111+
for ( u = 0; u < uplo.length; u++ ) {
112+
for ( o = 0; o < orders.length; o++ ) {
113+
for ( i = min; i <= max; i++ ) {
114+
N = floor( sqrt( pow( 10, i ) ) );
115+
116+
f = createBenchmark( N, uplo[ u ], orders[ o ], k );
117+
bench( format( '%s:colexicographic=%s,uplo=%s,k=%d,size=%d', pkg, orders[ o ], uplo[ u ], k, N*N ), f );
118+
}
119+
}
120+
}
121+
}
122+
123+
main();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
{{alias}}( uplo, arr, k, colexicographic )
3+
Converts a two-dimensional symmetric banded nested array to compact banded
4+
storage.
5+
6+
Parameters
7+
----------
8+
uplo: string
9+
Specifies whether to reference to the upper or lower triangular part of
10+
the input array. Must be either 'upper' or 'lower'.
11+
12+
arr: Array<Array>
13+
Input array.
14+
15+
k: integer
16+
Number of super-/sub-diagonals.
17+
18+
colexicographic: boolean
19+
Specifies whether to store diagonals in colexicographic access order.
20+
21+
Returns
22+
-------
23+
out: Array
24+
Output array.
25+
26+
Examples
27+
--------
28+
> var x = [ [ -1, 2, 0 ], [ 2, -3, 4 ], [ 0, 4, -5 ] ];
29+
> var out = {{alias}}( 'upper', x, 1, false )
30+
[ [ 0, 2, 4 ], [ -1, -3, -5 ] ]
31+
32+
See Also
33+
--------
34+

0 commit comments

Comments
 (0)