-
-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
blas/base/matrix-triangle-resolve-enum
PR-URL: #2497 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
- Loading branch information
1 parent
50316e4
commit defe484
Showing
10 changed files
with
565 additions
and
0 deletions.
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
lib/node_modules/@stdlib/blas/base/matrix-triangle-resolve-enum/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<!-- | ||
@license Apache-2.0 | ||
Copyright (c) 2024 The Stdlib Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
# resolve | ||
|
||
> Return the enumeration constant associated with a supported BLAS matrix triangle value. | ||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | ||
|
||
<section class="intro"> | ||
|
||
</section> | ||
|
||
<!-- /.intro --> | ||
|
||
<!-- Package usage documentation. --> | ||
|
||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var resolve = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); | ||
``` | ||
|
||
#### resolve( value ) | ||
|
||
Returns the enumeration constant associated with a BLAS matrix triangle value. | ||
|
||
```javascript | ||
var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); | ||
|
||
var v = resolve( 'lower' ); | ||
// returns <number> | ||
|
||
v = resolve( str2enum( 'lower' ) ); | ||
// returns <number> | ||
``` | ||
|
||
If unable to resolve an enumeration constant, the function returns `null`. | ||
|
||
```javascript | ||
var v = resolve( 'beep' ); | ||
// returns null | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="notes"> | ||
|
||
## Notes | ||
|
||
- Downstream consumers of this function should **not** rely on specific integer values (e.g., `UPPER == 0`). Instead, the function should be used in an opaque manner. | ||
|
||
</section> | ||
|
||
<!-- /.notes --> | ||
|
||
<!-- Package usage examples. --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var resolve = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); | ||
|
||
var v = resolve( 'lower' ); | ||
// returns <number> | ||
|
||
v = resolve( 'upper' ); | ||
// returns <number> | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- 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. --> | ||
|
||
<section class="references"> | ||
|
||
</section> | ||
|
||
<!-- /.references --> | ||
|
||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
|
||
<section class="related"> | ||
|
||
</section> | ||
|
||
<!-- /.related --> | ||
|
||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="links"> | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
80 changes: 80 additions & 0 deletions
80
lib/node_modules/@stdlib/blas/base/matrix-triangle-resolve-enum/benchmark/benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; | ||
var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); | ||
var pkg = require( './../package.json' ).name; | ||
var resolve = require( './../lib' ); | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg+'::string', function benchmark( b ) { | ||
var values; | ||
var out; | ||
var i; | ||
|
||
values = [ | ||
'lower', | ||
'upper' | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
out = resolve( values[ i%values.length ] ); | ||
if ( typeof out !== 'number' ) { | ||
b.fail( 'should return a number' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isInteger( out ) ) { | ||
b.fail( 'should return an integer' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::integer', function benchmark( b ) { | ||
var values; | ||
var out; | ||
var i; | ||
|
||
values = [ | ||
str2enum( 'lower' ), | ||
str2enum( 'upper' ) | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
out = resolve( values[ i%values.length ] ); | ||
if ( typeof out !== 'number' ) { | ||
b.fail( 'should return a number' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isInteger( out ) ) { | ||
b.fail( 'should return an integer' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
28 changes: 28 additions & 0 deletions
28
lib/node_modules/@stdlib/blas/base/matrix-triangle-resolve-enum/docs/repl.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
{{alias}}( value ) | ||
Returns the enumeration constant associated with a supported BLAS matrix | ||
triangle value. | ||
|
||
Downstream consumers of this function should *not* rely on specific integer | ||
values (e.g., `UPPER == 0`). Instead, the function should be used in an | ||
opaque manner. | ||
|
||
Parameters | ||
---------- | ||
value: any | ||
Matrix triangle value. | ||
|
||
Returns | ||
------- | ||
out: integer|null | ||
Enumeration constant. | ||
|
||
Examples | ||
-------- | ||
> var out = {{alias}}( 'lower' ) | ||
<number> | ||
> out = {{alias}}( {{alias:@stdlib/blas/base/matrix-triangle-str2enum}}( 'lower' ) ) | ||
<number> | ||
|
||
See Also | ||
-------- |
40 changes: 40 additions & 0 deletions
40
lib/node_modules/@stdlib/blas/base/matrix-triangle-resolve-enum/docs/types/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// TypeScript Version: 4.1 | ||
|
||
/** | ||
* Returns the enumeration constant associated with a BLAS matrix triangle value. | ||
* | ||
* ## Notes | ||
* | ||
* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UPPER == 0`). Instead, the function should be used in an opaque manner. | ||
* | ||
* @param value - matrix triangle value | ||
* @returns enumeration constant | ||
* | ||
* @example | ||
* var v = resolve( 'lower' ); | ||
* // returns <number> | ||
*/ | ||
declare function resolve( value: any ): number | null; | ||
|
||
|
||
// EXPORTS // | ||
|
||
export = resolve; |
28 changes: 28 additions & 0 deletions
28
lib/node_modules/@stdlib/blas/base/matrix-triangle-resolve-enum/docs/types/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import resolve = require( './index' ); | ||
|
||
|
||
// TESTS // | ||
|
||
// The function returns a number or null... | ||
{ | ||
resolve( 0 ); // $ExpectType number | null | ||
resolve( 'lower' ); // $ExpectType number | null | ||
} |
29 changes: 29 additions & 0 deletions
29
lib/node_modules/@stdlib/blas/base/matrix-triangle-resolve-enum/examples/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var resolve = require( './../lib' ); | ||
|
||
var v = resolve( 'lower' ); | ||
console.log( v ); | ||
// => <number> | ||
|
||
v = resolve( 'upper' ); | ||
console.log( v ); | ||
// => <number> |
40 changes: 40 additions & 0 deletions
40
lib/node_modules/@stdlib/blas/base/matrix-triangle-resolve-enum/lib/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Return the enumeration constant associated with a supported BLAS matrix triangle value. | ||
* | ||
* @module @stdlib/blas/base/matrix-triangle-resolve-enum | ||
* | ||
* @example | ||
* var resolve = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); | ||
* | ||
* var v = resolve( 'lower' ); | ||
* // returns <number> | ||
*/ | ||
|
||
// MODULES // | ||
|
||
var main = require( './main.js' ); | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = main; |
Oops, something went wrong.
defe484
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report
The above coverage report was generated for the changes in this push.