Skip to content

Commit 7584303

Browse files
committed
feat: add blas/base/matrix-orientations
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent fbd6358 commit 7584303

File tree

14 files changed

+716
-0
lines changed

14 files changed

+716
-0
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
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+
# Matrix Orientations
22+
23+
> BLAS matrix orientations.
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 orientations = require( '@stdlib/blas/base/matrix-orientations' );
41+
```
42+
43+
#### orientations()
44+
45+
Returns a list of BLAS matrix orientations.
46+
47+
```javascript
48+
var out = orientations();
49+
// e.g., returns [ 'rows', 'columns' ]
50+
```
51+
52+
The output array contains the following types:
53+
54+
- `rows`: data is stored along matrix rows.
55+
- `columns`: data is stored along matrix columns.
56+
57+
</section>
58+
59+
<!-- /.usage -->
60+
61+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
62+
63+
<section class="notes">
64+
65+
</section>
66+
67+
<!-- /.notes -->
68+
69+
<!-- Package usage examples. -->
70+
71+
<section class="examples">
72+
73+
## Examples
74+
75+
<!-- eslint no-undef: "error" -->
76+
77+
```javascript
78+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
79+
var orientations = require( '@stdlib/blas/base/matrix-orientations' );
80+
81+
var isMatrixOrientation = contains( orientations() );
82+
83+
var bool = isMatrixOrientation( 'rows' );
84+
// returns true
85+
86+
bool = isMatrixOrientation( 'columns' );
87+
// returns true
88+
89+
bool = isMatrixOrientation( 'beep' );
90+
// returns false
91+
```
92+
93+
</section>
94+
95+
<!-- /.examples -->
96+
97+
<!-- C interface documentation. -->
98+
99+
* * *
100+
101+
<section class="c">
102+
103+
## C APIs
104+
105+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
106+
107+
<section class="intro">
108+
109+
</section>
110+
111+
<!-- /.intro -->
112+
113+
<!-- C usage documentation. -->
114+
115+
<section class="usage">
116+
117+
### Usage
118+
119+
```c
120+
#include "stdlib/blas/base/matrix_orientations.h"
121+
```
122+
123+
#### STDLIB_BLAS_MATRIX_ORIENTATION
124+
125+
An enumeration of BLAS matrix orientations with the following fields:
126+
127+
- **STDLIB_BLAS_ROWS**: data is stored along matrix rows.
128+
- **STDLIB_BLAS_COLUMNS**: data is stored along matrix columns.
129+
130+
```c
131+
#include "stdlib/blas/base/matrix_orientations.h"
132+
133+
const enum STDLIB_BLAS_MATRIX_ORIENTATION v = STDLIB_BLAS_ROWS;
134+
```
135+
136+
</section>
137+
138+
<!-- /.usage -->
139+
140+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
141+
142+
<section class="notes">
143+
144+
### Notes
145+
146+
- Enumeration constants should be considered opaque values, and one should **not** rely on specific integer values.
147+
148+
</section>
149+
150+
<!-- /.notes -->
151+
152+
<!-- C API usage examples. -->
153+
154+
<section class="examples">
155+
156+
</section>
157+
158+
<!-- /.examples -->
159+
160+
</section>
161+
162+
<!-- /.c -->
163+
164+
<!-- 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. -->
165+
166+
<section class="references">
167+
168+
</section>
169+
170+
<!-- /.references -->
171+
172+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
173+
174+
<section class="related">
175+
176+
</section>
177+
178+
<!-- /.related -->
179+
180+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
181+
182+
<section class="links">
183+
184+
</section>
185+
186+
<!-- /.links -->
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
25+
var pkg = require( './../package.json' ).name;
26+
var orientations = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var out;
33+
var i;
34+
35+
b.tic();
36+
for ( i = 0; i < b.iterations; i++ ) {
37+
out = orientations();
38+
if ( out.length < 2 ) {
39+
b.fail( 'should return an array' );
40+
}
41+
}
42+
b.toc();
43+
if ( !isStringArray( out ) ) {
44+
b.fail( 'should return an array of strings' );
45+
}
46+
b.pass( 'benchmark finished' );
47+
b.end();
48+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
{{alias}}()
3+
Returns a list of matrix orientations.
4+
5+
The output array contains the following matrix orientations:
6+
7+
- rows: data is stored along rows.
8+
- columns: data is stored along columns.
9+
10+
Returns
11+
-------
12+
out: Array<string>
13+
List of matrix orientations.
14+
15+
Examples
16+
--------
17+
> var out = {{alias}}()
18+
[ 'rows', 'columns' ]
19+
20+
See Also
21+
--------
22+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Returns a list of matrix orientations.
23+
*
24+
* @returns list of matrix orientations
25+
*
26+
* @example
27+
* var list = orientations();
28+
* // e.g., returns [ 'rows', 'columns' ]
29+
*/
30+
declare function orientations(): Array<string>;
31+
32+
33+
// EXPORTS //
34+
35+
export = orientations;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
import orientations = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array of strings...
25+
{
26+
orientations(); // $ExpectType string[]
27+
}
28+
29+
// The compiler throws an error if the function is provided any arguments...
30+
{
31+
orientations( 9 ); // $ExpectError
32+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
22+
var orientations = require( './../lib' );
23+
24+
var isMatrixOrientation = contains( orientations() );
25+
26+
var bool = isMatrixOrientation( 'rows' );
27+
console.log( bool );
28+
// => true
29+
30+
bool = isMatrixOrientation( 'columns' );
31+
console.log( bool );
32+
// => true
33+
34+
bool = isMatrixOrientation( 'beep' );
35+
console.log( bool );
36+
// => false
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
#ifndef STDLIB_BLAS_BASE_MATRIX_ORIENTATIONS_H
20+
#define STDLIB_BLAS_BASE_MATRIX_ORIENTATIONS_H
21+
22+
/**
23+
* Enumeration of matrix orientations.
24+
*/
25+
enum STDLIB_BLAS_MATRIX_ORIENTATION {
26+
// Row matrix:
27+
STDLIB_BLAS_ROWS = 241,
28+
29+
// Column matrix:
30+
STDLIB_BLAS_COLUMNS = 242,
31+
};
32+
33+
#endif // !STDLIB_BLAS_BASE_MATRIX_ORIENTATIONS_H

0 commit comments

Comments
 (0)