From 7e6825485b371a2218a8e867a28408657570acbb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 3 Jul 2024 09:31:43 +0530 Subject: [PATCH 1/8] feat: add blas/base/diagonal-type-str2enum --- .../base/diagonal-type-str2enum/README.md | 119 ++++++++++++++++++ .../benchmark/benchmark.js | 54 ++++++++ .../base/diagonal-type-str2enum/docs/repl.txt | 26 ++++ .../docs/types/index.d.ts | 40 ++++++ .../diagonal-type-str2enum/docs/types/test.ts | 39 ++++++ .../diagonal-type-str2enum/examples/index.js | 29 +++++ .../base/diagonal-type-str2enum/lib/index.js | 40 ++++++ .../base/diagonal-type-str2enum/lib/main.js | 55 ++++++++ .../base/diagonal-type-str2enum/package.json | 67 ++++++++++ .../base/diagonal-type-str2enum/test/test.js | 66 ++++++++++ 10 files changed, 535 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md new file mode 100644 index 000000000000..98f398079fc2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md @@ -0,0 +1,119 @@ + + +# str2enum + +> Return the enumeration constant associated with a BLAS diagonal type. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +``` + +#### str2enum( operation ) + +Return the enumeration constant associated with a BLAS diagonal-type. + +```javascript +var v = str2enum( 'unit' ); +// returns +``` + +If unable to resolve an enumeration constant, the function returns `null`. + +```javascript +var v = str2enum( 'beep' ); +// returns null +``` + +
+ + + + + +
+ +## Notes + +- Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. + +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); + +var v = str2enum( 'unit' ); +// returns + +v = str2enum( 'non-unit' ); +// returns +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/benchmark/benchmark.js new file mode 100644 index 000000000000..a5f36f392a5c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/benchmark/benchmark.js @@ -0,0 +1,54 @@ +/** +* @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 pkg = require( './../package.json' ).name; +var str2enum = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + 'unit', + 'non-unit' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = str2enum( 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt new file mode 100644 index 000000000000..6dceb7f5fb71 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt @@ -0,0 +1,26 @@ + +{{alias}}( operation ) + Returns the enumeration constant associated with a BLAS diagonal type. + + Downstream consumers of this function should *not* rely on specific integer + values (e.g., `UNIT == 0`). Instead, the function should be used in an + opaque manner. + + Parameters + ---------- + operation: string + Diagonal type. + + Returns + ------- + out: integer|null + Enumeration constant. + + Examples + -------- + > var out = {{alias}}( 'unit' ) + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts new file mode 100644 index 000000000000..1e1a7981555f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts @@ -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 diagonal type. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. +* +* @param operation - diagonal type +* @returns enumeration constant +* +* @example +* var v = str2enum( 'unit' ); +* // returns +*/ +declare function str2enum( operation: string ): number | null; + + +// EXPORTS // + +export = str2enum; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/test.ts new file mode 100644 index 000000000000..08a2f61aa48e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/test.ts @@ -0,0 +1,39 @@ +/* +* @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 str2enum = require( './index' ); + + +// TESTS // + +// The function returns a number or null... +{ + str2enum( 'unit' ); // $ExpectType number | null +} + +// The compiler throws an error if not provided a string... +{ + str2enum( 10 ); // $ExpectError + str2enum( true ); // $ExpectError + str2enum( false ); // $ExpectError + str2enum( null ); // $ExpectError + str2enum( undefined ); // $ExpectError + str2enum( [] ); // $ExpectError + str2enum( {} ); // $ExpectError + str2enum( ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/examples/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/examples/index.js new file mode 100644 index 000000000000..3107263c8a86 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/examples/index.js @@ -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 str2enum = require( './../lib' ); + +var v = str2enum( 'unit' ); +console.log( v ); +// => + +v = str2enum( 'non-unit' ); +console.log( v ); +// => diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/index.js new file mode 100644 index 000000000000..8c8be1876e4c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/index.js @@ -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 BLAS diagonal type. +* +* @module @stdlib/blas/base/diagonal-type-str2enum +* +* @example +* var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +* +* var v = str2enum( 'unit' ); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js new file mode 100644 index 000000000000..795e9ee92e34 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js @@ -0,0 +1,55 @@ +/** +* @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 enumeration = require( '@stdlib/blas/base/diagonal-types' ).enum; + + +// VARIABLES // + +var ENUM = enumeration(); + + +// MAIN // + +/** +* Returns the enumeration constant associated with a BLAS diagonal type. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. +* +* @param {string} operation - diagonal type +* @returns {(integer|null)} integer value or null +* +* @example +* var v = str2enum( 'unit' ); +* // returns +*/ +function str2enum( operation ) { + var v = ENUM[ operation ]; + return ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain +} + + +// EXPORTS // + +module.exports = str2enum; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/package.json b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/package.json new file mode 100644 index 000000000000..9e4208e776f8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/blas/base/diagonal-type-str2enum", + "version": "0.0.0", + "description": "Return the enumeration constant associated with a BLAS diagonal type.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "diagonal", + "type", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/test/test.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/test/test.js new file mode 100644 index 000000000000..84f480b381f9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/test/test.js @@ -0,0 +1,66 @@ +/** +* @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 tape = require( 'tape' ); +var enum2str = require( '@stdlib/blas/base/diagonal-type-enum2str' ); +var str2enum = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'unit', + 'non-unit' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof str2enum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the enumeration constant associated with a string', function test( t ) { + var i; + for ( i = 0; i < VALUES.length; i++ ) { + t.strictEqual( enum2str( str2enum( VALUES[ i ] ) ), VALUES[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve an enumeration constant', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'foo', + 'bar' + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( str2enum( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +}); From 07e7d6a29a2c0de309775356e6d4e6b95a0512eb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 3 Jul 2024 09:33:04 +0530 Subject: [PATCH 2/8] feat: add blas/base/diagonal-type-enum2str --- .../base/diagonal-type-enum2str/README.md | 121 ++++++++++++++++++ .../benchmark/benchmark.js | 55 ++++++++ .../base/diagonal-type-enum2str/docs/repl.txt | 23 ++++ .../docs/types/index.d.ts | 41 ++++++ .../diagonal-type-enum2str/docs/types/test.ts | 39 ++++++ .../diagonal-type-enum2str/examples/index.js | 30 +++++ .../base/diagonal-type-enum2str/lib/index.js | 44 +++++++ .../base/diagonal-type-enum2str/lib/main.js | 59 +++++++++ .../base/diagonal-type-enum2str/package.json | 67 ++++++++++ .../base/diagonal-type-enum2str/test/test.js | 65 ++++++++++ 10 files changed, 544 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md new file mode 100644 index 000000000000..1ff8dbcba94d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md @@ -0,0 +1,121 @@ + + +# enum2str + +> Return the BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var enum2str = require( '@stdlib/blas/base/diagonal-type-enum2str' ); +``` + +#### enum2str( operation ) + +Returns the BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. + +```javascript +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); + +var v = str2enum( 'unit' ); +// returns + +var s = enum2str( v ); +// returns 'unit' +``` + +If unable to resolve a operation string, the function returns `null`. + +```javascript +var v = enum2str( -999999999 ); +// returns null +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var enum2str = require( '@stdlib/blas/base/diagonal-type-enum2str' ); + +var str = enum2str( str2enum( 'unit' ) ); +// returns 'unit' + +str = enum2str( str2enum( 'non-unit' ) ); +// returns 'non-unit' +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/benchmark/benchmark.js new file mode 100644 index 000000000000..ac0a6c9f367b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/benchmark/benchmark.js @@ -0,0 +1,55 @@ +/** +* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var pkg = require( './../package.json' ).name; +var enum2str = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + str2enum( 'unit' ), + str2enum( 'non-unit' ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = enum2str( values[ i%values.length ] ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt new file mode 100644 index 000000000000..7c86d539d14e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt @@ -0,0 +1,23 @@ + +{{alias}}( operation ) + Returns the BLAS diagonal type string associated with a BLAS diagonal + type enumeration constant. + + Parameters + ---------- + operation: integer + Operation enumeration constant. + + Returns + ------- + out: string|null + Operation string. + + Examples + -------- + > var out = {{alias}}( {{alias:@stdlib/blas/base/diagonal-type-str2enum}}( 'unit' ) ) + 'unit' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts new file mode 100644 index 000000000000..663f40acdf38 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts @@ -0,0 +1,41 @@ +/* +* @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 BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. +* +* @param operation - enumeration constant +* @returns operation string +* +* @example +* var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +* +* var v = str2enum( 'unit' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'unit' +*/ +declare function enum2str( operation: number ): string | null; + + +// EXPORTS // + +export = enum2str; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/test.ts new file mode 100644 index 000000000000..65833e5930c3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/test.ts @@ -0,0 +1,39 @@ +/* +* @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 enum2str = require( './index' ); + + +// TESTS // + +// The function returns a string or null... +{ + enum2str( 0 ); // $ExpectType string | null +} + +// The compiler throws an error if not provided a number... +{ + enum2str( '10' ); // $ExpectError + enum2str( true ); // $ExpectError + enum2str( false ); // $ExpectError + enum2str( null ); // $ExpectError + enum2str( undefined ); // $ExpectError + enum2str( [] ); // $ExpectError + enum2str( {} ); // $ExpectError + enum2str( ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/examples/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/examples/index.js new file mode 100644 index 000000000000..aa1ed7a18eb7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/examples/index.js @@ -0,0 +1,30 @@ +/** +* @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 str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var enum2str = require( './../lib' ); + +var str = enum2str( str2enum( 'unit' ) ); +console.log( str ); +// => 'unit' + +str = enum2str( str2enum( 'non-unit' ) ); +console.log( str ); +// => 'non-unit' diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/index.js new file mode 100644 index 000000000000..2b1774931155 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/index.js @@ -0,0 +1,44 @@ +/** +* @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 BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. +* +* @module @stdlib/blas/base/diagonal-type-enum2str +* +* @example +* var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +* var enum2str = require( '@stdlib/blas/base/diagonal-type-enum2str' ); +* +* var v = str2enum( 'unit' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'unit' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js new file mode 100644 index 000000000000..da2a4f4d0e03 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js @@ -0,0 +1,59 @@ +/** +* @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 objectInverse = require( '@stdlib/utils/object-inverse' ); +var enumeration = require( '@stdlib/blas/base/diagonal-types' ).enum; + + +// VARIABLES // + +var hash = objectInverse( enumeration(), { + 'duplicates': false +}); + + +// MAIN // + +/** +* Returns the BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. +* +* @param {integer} operation - operation enumeration constant +* @returns {(string|null)} operation string or null +* +* @example +* var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +* +* var v = str2enum( 'unit' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'unit' +*/ +function enum2str( operation ) { + var v = hash[ operation ]; + return ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain +} + + +// EXPORTS // + +module.exports = enum2str; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/package.json b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/package.json new file mode 100644 index 000000000000..95e6d5ef9731 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/blas/base/diagonal-type-enum2str", + "version": "0.0.0", + "description": "Return the BLAS diagonal type string associated with a BLAS diagonal type enumeration constant.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "diagonal", + "type", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js new file mode 100644 index 000000000000..c24402c20564 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js @@ -0,0 +1,65 @@ +/** +* @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 tape = require( 'tape' ); +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var enum2str = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'non-unit', + 'unit' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof enum2str, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the operation string associated with a BLAS diagonal type enumeration constant', function test( t ) { + var i; + for ( i = 0; i < VALUES.length; i++ ) { + t.strictEqual( enum2str( str2enum( VALUES[ i ] ) ), VALUES[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve a operation string', function test( t ) { + var values; + var i; + + values = [ + -9999999, + -999999999, + -99999999999 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( enum2str( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +}); From 1588d81678d363220949ccf60a59cbabeae1f34a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 3 Jul 2024 09:37:32 +0530 Subject: [PATCH 3/8] feat: add blas/base/diagonal-type-resolve-str --- .../base/diagonal-type-resolve-str/README.md | 121 ++++++++++++++++++ .../benchmark/benchmark.js | 80 ++++++++++++ .../diagonal-type-resolve-str/docs/repl.txt | 25 ++++ .../docs/types/index.d.ts | 38 ++++++ .../docs/types/test.ts | 28 ++++ .../examples/index.js | 30 +++++ .../diagonal-type-resolve-str/lib/index.js | 41 ++++++ .../diagonal-type-resolve-str/lib/main.js | 55 ++++++++ .../diagonal-type-resolve-str/package.json | 67 ++++++++++ .../diagonal-type-resolve-str/test/test.js | 74 +++++++++++ 10 files changed, 559 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md new file mode 100644 index 000000000000..008e9f2e829f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md @@ -0,0 +1,121 @@ + + +# resolve + +> Return the diagonal type string associated with a supported BLAS diagonal type value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-str' ); +``` + +#### resolve( operation ) + +Returns the diagonal type string associated with a BLAS diagonal type value. + +```javascript +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); + +var v = resolve( 'unit' ); +// returns 'unit' + +v = resolve( str2enum( 'unit' ) ); +// returns 'unit' +``` + +If unable to resolve a diagonal type string, the function returns `null`. + +```javascript +var v = resolve( 'beep' ); +// returns null +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-str' ); + +var v = resolve( str2enum( 'unit' ) ); +// returns 'unit' + +v = resolve( str2enum( 'non-unit' ) ); +// returns 'non-unit' +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/benchmark/benchmark.js new file mode 100644 index 000000000000..c6b8be8d66fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/benchmark/benchmark.js @@ -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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var str2enum = require( '@stdlib/blas/base/diagonal-type-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 = [ + 'unit', + 'non-unit' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = resolve( values[ i%values.length ] ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::integer', function benchmark( b ) { + var values; + var out; + var i; + + values = [ + str2enum( 'unit' ), + str2enum( 'non-unit' ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = resolve( values[ i%values.length ] ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt new file mode 100644 index 000000000000..b50306702741 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt @@ -0,0 +1,25 @@ + +{{alias}}( operation ) + Returns the diagonal type string associated with a supported BLAS + diagonal type value. + + Parameters + ---------- + operation: any + Operation value. + + Returns + ------- + out: string|null + Operation string. + + Examples + -------- + > var out = {{alias}}( 'unit' ) + 'unit' + > out = {{alias}}( {{alias:@stdlib/blas/base/diagonal-type-str2enum}}( 'unit' ) ) + 'unit' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts new file mode 100644 index 000000000000..3c803ce25882 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts @@ -0,0 +1,38 @@ +/* +* @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 diagonal type string associated with a BLAS diagonal type value. +* +* @param operation - operation value +* @returns diagonal type string +* +* @example +* var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +* +* var v = resolve( str2enum( 'unit' ) ); +* // returns 'unit' +*/ +declare function resolve( operation: any ): string | null; + + +// EXPORTS // + +export = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/test.ts new file mode 100644 index 000000000000..6aecf1e0ce7a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/test.ts @@ -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 string or null... +{ + resolve( 0 ); // $ExpectType string | null + resolve( 'unit' ); // $ExpectType string | null +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/examples/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/examples/index.js new file mode 100644 index 000000000000..1335af238562 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/examples/index.js @@ -0,0 +1,30 @@ +/** +* @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 str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var resolve = require( './../lib' ); + +var v = resolve( str2enum( 'unit' ) ); +console.log( v ); +// => 'unit' + +v = resolve( str2enum( 'non-unit' ) ); +console.log( v ); +// => 'non-unit' diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/index.js new file mode 100644 index 000000000000..2e2c7bf6687c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/index.js @@ -0,0 +1,41 @@ +/** +* @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 diagonal type string associated with a supported BLAS diagonal type value. +* +* @module @stdlib/blas/base/diagonal-type-resolve-str +* +* @example +* var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +* var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-str' ); +* +* var v = resolve( str2enum( 'unit' ) ); +* // returns 'unit' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js new file mode 100644 index 000000000000..dfb914b7a3de --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js @@ -0,0 +1,55 @@ +/** +* @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 enum2str = require( '@stdlib/blas/base/diagonal-type-enum2str' ); +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); + + +// MAIN // + +/** +* Returns the diagonal type string associated with a supported BLAS diagonal type value. +* +* @param {*} operation - operation value +* @returns {(string|null)} diagonal type string or null +* +* @example +* var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +* +* var v = resolve( str2enum( 'unit' ) ); +* // returns 'unit' +*/ +function resolve( operation ) { + var t = ( typeof operation ); + if ( t === 'string' ) { + return ( str2enum( operation ) === null ) ? null : operation; + } + if ( t === 'number' ) { + return enum2str( operation ); + } + return null; +} + + +// EXPORTS // + +module.exports = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/package.json b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/package.json new file mode 100644 index 000000000000..1a28bd32ce89 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/blas/base/diagonal-type-resolve-str", + "version": "0.0.0", + "description": "Return the diagonal type string associated with a supported BLAS diagonal type value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "diagonal", + "type", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/test/test.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/test/test.js new file mode 100644 index 000000000000..0612aa7c2b48 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/test/test.js @@ -0,0 +1,74 @@ +/** +* @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 tape = require( 'tape' ); +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var resolve = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'non-unit', + 'unit' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof resolve, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the diagonal type string associated with a BLAS diagonal type value', function test( t ) { + var v; + var i; + for ( i = 0; i < VALUES.length; i++ ) { + v = str2enum( VALUES[ i ] ); + t.strictEqual( resolve( VALUES[ i ] ), VALUES[ i ], 'returns expected value' ); + t.strictEqual( resolve( v ), VALUES[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve a diagonal type string', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'foo', + 'bar', + -99999999, + -9999999999, + -9999999999999, + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( resolve( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +}); From 21e078bd157a3f8b296ac0498bbf86b0874d2f33 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 3 Jul 2024 09:42:02 +0530 Subject: [PATCH 4/8] feat: add blas/base/diagonal-type-resolve-enum --- .../base/diagonal-type-resolve-enum/README.md | 124 ++++++++++++++++++ .../benchmark/benchmark.js | 80 +++++++++++ .../diagonal-type-resolve-enum/docs/repl.txt | 29 ++++ .../docs/types/index.d.ts | 40 ++++++ .../docs/types/test.ts | 28 ++++ .../examples/index.js | 29 ++++ .../diagonal-type-resolve-enum/lib/index.js | 40 ++++++ .../diagonal-type-resolve-enum/lib/main.js | 57 ++++++++ .../diagonal-type-resolve-enum/package.json | 67 ++++++++++ .../diagonal-type-resolve-enum/test/test.js | 74 +++++++++++ 10 files changed, 568 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md new file mode 100644 index 000000000000..77ab10cac668 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md @@ -0,0 +1,124 @@ + + +# resolve + +> Return the enumeration constant associated with a supported BLAS diagonal type value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-enum' ); +``` + +#### resolve( operation ) + +Returns the enumeration constant associated with a BLAS diagonal type value. + +```javascript +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); + +var v = resolve( 'non-unit' ); +// returns + +v = resolve( str2enum( 'non-unit' ) ); +// returns +``` + +If unable to resolve an enumeration constant, the function returns `null`. + +```javascript +var v = resolve( 'beep' ); +// returns null +``` + +
+ + + + + +
+ +## Notes + +- Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. + +
+ + + + + +
+ +## Examples + + + +```javascript +var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-enum' ); + +var v = resolve( 'non-unit' ); +// returns + +v = resolve( 'unit' ); +// returns +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/benchmark/benchmark.js new file mode 100644 index 000000000000..e0aff4b8bd3e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/benchmark/benchmark.js @@ -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/diagonal-type-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 = [ + 'non-unit', + 'unit' + ]; + + 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( 'non-unit' ), + str2enum( 'unit' ) + ]; + + 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt new file mode 100644 index 000000000000..3783b81a9676 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt @@ -0,0 +1,29 @@ + +{{alias}}( operation ) + Returns the enumeration constant associated with a supported BLAS diagonal + type value. + + Downstream consumers of this function should *not* rely on specific integer + values (e.g., `UNIT == 0`). Instead, the function should be used in an + opaque manner. + + Parameters + ---------- + operation: any + Operation value. + + Returns + ------- + out: integer|null + Enumeration constant. + + Examples + -------- + > var out = {{alias}}( 'non-unit' ) + + > out = {{alias}}( {{alias:@stdlib/blas/base/diagonal-type-str2enum}}( 'non-unit' ) ) + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts new file mode 100644 index 000000000000..3ab58c24efc5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts @@ -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 diagonal type value. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. +* +* @param operation - operation value +* @returns enumeration constant +* +* @example +* var v = resolve( 'non-unit' ); +* // returns +*/ +declare function resolve( operation: any ): number | null; + + +// EXPORTS // + +export = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/test.ts new file mode 100644 index 000000000000..f21cfd3a7aa5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/test.ts @@ -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( 'non-unit' ); // $ExpectType number | null +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/examples/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/examples/index.js new file mode 100644 index 000000000000..37d6c43369db --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/examples/index.js @@ -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( 'non-unit' ); +console.log( v ); +// => + +v = resolve( 'unit' ); +console.log( v ); +// => diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/index.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/index.js new file mode 100644 index 000000000000..50f83068aa8f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/index.js @@ -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 diagonal type value. +* +* @module @stdlib/blas/base/diagonal-type-resolve-enum +* +* @example +* var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-enum' ); +* +* var v = resolve( 'non-unit' ); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js new file mode 100644 index 000000000000..d5ffebb2dd65 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js @@ -0,0 +1,57 @@ +/** +* @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 enum2str = require( '@stdlib/blas/base/diagonal-type-enum2str' ); +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); + + +// MAIN // + +/** +* Returns the enumeration constant associated with a supported BLAS diagonal type value. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. +* +* @param {*} operation - operation value +* @returns {(integer|null)} enumeration constant or null +* +* @example +* var v = resolve( 'non-unit' ); +* // returns +*/ +function resolve( operation ) { + var t = ( typeof operation ); + if ( t === 'number' ) { + return ( enum2str( operation ) ) ? operation : null; + } + if ( t === 'string' ) { + return str2enum( operation ); + } + return null; +} + + +// EXPORTS // + +module.exports = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/package.json b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/package.json new file mode 100644 index 000000000000..6439ebfa6210 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/blas/base/diagonal-type-resolve-enum", + "version": "0.0.0", + "description": "Return the enumeration constant associated with a supported BLAS diagonal type value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "diagonal", + "type", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/test/test.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/test/test.js new file mode 100644 index 000000000000..0a519faa4744 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/test/test.js @@ -0,0 +1,74 @@ +/** +* @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 tape = require( 'tape' ); +var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); +var resolve = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'unit', + 'non-unit' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof resolve, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the enumeration constant associated with a BLAS diagonal type value', function test( t ) { + var v; + var i; + for ( i = 0; i < VALUES.length; i++ ) { + v = str2enum( VALUES[ i ] ); + t.strictEqual( resolve( VALUES[ i ] ), v, 'returns expected value' ); + t.strictEqual( resolve( v ), v, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve an enumeration constant', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'foo', + 'bar', + -99999999, + -9999999999, + -9999999999999, + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( resolve( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +}); From 9edfab34621cd6a73cfefd9727899ab6666e2d32 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 15:53:46 -0700 Subject: [PATCH 5/8] docs: rename parameter and update descriptions --- .../blas/base/diagonal-type-enum2str/README.md | 4 ++-- .../blas/base/diagonal-type-enum2str/docs/repl.txt | 12 ++++++------ .../diagonal-type-enum2str/docs/types/index.d.ts | 6 +++--- .../blas/base/diagonal-type-enum2str/lib/main.js | 8 ++++---- .../blas/base/diagonal-type-enum2str/test/test.js | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md index 1ff8dbcba94d..9afb7880d263 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/README.md @@ -40,7 +40,7 @@ limitations under the License. var enum2str = require( '@stdlib/blas/base/diagonal-type-enum2str' ); ``` -#### enum2str( operation ) +#### enum2str( value ) Returns the BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. @@ -54,7 +54,7 @@ var s = enum2str( v ); // returns 'unit' ``` -If unable to resolve a operation string, the function returns `null`. +If unable to resolve a diagonal type string, the function returns `null`. ```javascript var v = enum2str( -999999999 ); diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt index 7c86d539d14e..3cc380c40ce5 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/repl.txt @@ -1,17 +1,17 @@ -{{alias}}( operation ) - Returns the BLAS diagonal type string associated with a BLAS diagonal - type enumeration constant. +{{alias}}( value ) + Returns the BLAS diagonal type string associated with a BLAS diagonal type + enumeration constant. Parameters ---------- - operation: integer - Operation enumeration constant. + value: integer + Diagonal type enumeration constant. Returns ------- out: string|null - Operation string. + Diagonal type string. Examples -------- diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts index 663f40acdf38..19e95fb05b8e 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/docs/types/index.d.ts @@ -21,8 +21,8 @@ /** * Returns the BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. * -* @param operation - enumeration constant -* @returns operation string +* @param value - enumeration constant +* @returns diagonal type string * * @example * var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); @@ -33,7 +33,7 @@ * var s = enum2str( v ); * // returns 'unit' */ -declare function enum2str( operation: number ): string | null; +declare function enum2str( value: number ): string | null; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js index da2a4f4d0e03..c09fb4c59433 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/lib/main.js @@ -36,8 +36,8 @@ var hash = objectInverse( enumeration(), { /** * Returns the BLAS diagonal type string associated with a BLAS diagonal type enumeration constant. * -* @param {integer} operation - operation enumeration constant -* @returns {(string|null)} operation string or null +* @param {integer} value - diagonal type enumeration constant +* @returns {(string|null)} diagonal type string or null * * @example * var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); @@ -48,8 +48,8 @@ var hash = objectInverse( enumeration(), { * var s = enum2str( v ); * // returns 'unit' */ -function enum2str( operation ) { - var v = hash[ operation ]; +function enum2str( value ) { + var v = hash[ value ]; return ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain } diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js index c24402c20564..43e4e363a3a6 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-enum2str/test/test.js @@ -41,7 +41,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns the operation string associated with a BLAS diagonal type enumeration constant', function test( t ) { +tape( 'the function returns the diagonal type string associated with a BLAS diagonal type enumeration constant', function test( t ) { var i; for ( i = 0; i < VALUES.length; i++ ) { t.strictEqual( enum2str( str2enum( VALUES[ i ] ) ), VALUES[ i ], 'returns expected value' ); @@ -49,7 +49,7 @@ tape( 'the function returns the operation string associated with a BLAS diagonal t.end(); }); -tape( 'the function returns `null` if unable to resolve a operation string', function test( t ) { +tape( 'the function returns `null` if unable to resolve a diagonal type string', function test( t ) { var values; var i; From 6640279721df3a8746fa88fea9fee534c7c73999 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 16:13:00 -0700 Subject: [PATCH 6/8] docs: rename parameter and update descriptions --- .../blas/base/diagonal-type-resolve-enum/README.md | 2 +- .../blas/base/diagonal-type-resolve-enum/docs/repl.txt | 6 +++--- .../diagonal-type-resolve-enum/docs/types/index.d.ts | 4 ++-- .../blas/base/diagonal-type-resolve-enum/lib/main.js | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md index 77ab10cac668..f7d1fec57d62 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/README.md @@ -40,7 +40,7 @@ limitations under the License. var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-enum' ); ``` -#### resolve( operation ) +#### resolve( value ) Returns the enumeration constant associated with a BLAS diagonal type value. diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt index 3783b81a9676..869711e41274 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( operation ) +{{alias}}( value ) Returns the enumeration constant associated with a supported BLAS diagonal type value. @@ -9,8 +9,8 @@ Parameters ---------- - operation: any - Operation value. + value: any + Diagonal type value. Returns ------- diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts index 3ab58c24efc5..772bc86ea3f3 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/docs/types/index.d.ts @@ -25,14 +25,14 @@ * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. * -* @param operation - operation value +* @param value - diagonal type value * @returns enumeration constant * * @example * var v = resolve( 'non-unit' ); * // returns */ -declare function resolve( operation: any ): number | null; +declare function resolve( value: any ): number | null; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js index d5ffebb2dd65..43343ed4087f 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-enum/lib/main.js @@ -33,20 +33,20 @@ var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. * -* @param {*} operation - operation value +* @param {*} value - diagonal type value * @returns {(integer|null)} enumeration constant or null * * @example * var v = resolve( 'non-unit' ); * // returns */ -function resolve( operation ) { - var t = ( typeof operation ); +function resolve( value ) { + var t = ( typeof value ); if ( t === 'number' ) { - return ( enum2str( operation ) ) ? operation : null; + return ( enum2str( value ) ) ? value : null; } if ( t === 'string' ) { - return str2enum( operation ); + return str2enum( value ); } return null; } From 2b2778d4f6a482710d53683a0174d67e71c25857 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 16:15:01 -0700 Subject: [PATCH 7/8] docs: rename parameter and update descriptions --- .../blas/base/diagonal-type-resolve-str/README.md | 2 +- .../base/diagonal-type-resolve-str/docs/repl.txt | 12 ++++++------ .../diagonal-type-resolve-str/docs/types/index.d.ts | 4 ++-- .../blas/base/diagonal-type-resolve-str/lib/main.js | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md index 008e9f2e829f..8d1f0fdfc3c4 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/README.md @@ -40,7 +40,7 @@ limitations under the License. var resolve = require( '@stdlib/blas/base/diagonal-type-resolve-str' ); ``` -#### resolve( operation ) +#### resolve( value ) Returns the diagonal type string associated with a BLAS diagonal type value. diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt index b50306702741..1a69978271d1 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/repl.txt @@ -1,17 +1,17 @@ -{{alias}}( operation ) - Returns the diagonal type string associated with a supported BLAS - diagonal type value. +{{alias}}( value ) + Returns the diagonal type string associated with a supported BLAS diagonal + type value. Parameters ---------- - operation: any - Operation value. + value: any + Diagonal type value. Returns ------- out: string|null - Operation string. + Diagonal type string. Examples -------- diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts index 3c803ce25882..0ec594d62ae0 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/docs/types/index.d.ts @@ -21,7 +21,7 @@ /** * Returns the diagonal type string associated with a BLAS diagonal type value. * -* @param operation - operation value +* @param value - diagonal type value * @returns diagonal type string * * @example @@ -30,7 +30,7 @@ * var v = resolve( str2enum( 'unit' ) ); * // returns 'unit' */ -declare function resolve( operation: any ): string | null; +declare function resolve( value: any ): string | null; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js index dfb914b7a3de..ac58402873a3 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-resolve-str/lib/main.js @@ -29,7 +29,7 @@ var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); /** * Returns the diagonal type string associated with a supported BLAS diagonal type value. * -* @param {*} operation - operation value +* @param {*} value - diagonal type value * @returns {(string|null)} diagonal type string or null * * @example @@ -38,13 +38,13 @@ var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); * var v = resolve( str2enum( 'unit' ) ); * // returns 'unit' */ -function resolve( operation ) { - var t = ( typeof operation ); +function resolve( value ) { + var t = ( typeof value ); if ( t === 'string' ) { - return ( str2enum( operation ) === null ) ? null : operation; + return ( str2enum( value ) === null ) ? null : value; } if ( t === 'number' ) { - return enum2str( operation ); + return enum2str( value ); } return null; } From 7c55b17c7736aeffa1f407c5b74ae9735fd26c39 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 16:17:06 -0700 Subject: [PATCH 8/8] docs: rename parameter --- .../@stdlib/blas/base/diagonal-type-str2enum/README.md | 2 +- .../@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt | 4 ++-- .../blas/base/diagonal-type-str2enum/docs/types/index.d.ts | 4 ++-- .../@stdlib/blas/base/diagonal-type-str2enum/lib/main.js | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md index 98f398079fc2..d571bd76d43c 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/README.md @@ -40,7 +40,7 @@ limitations under the License. var str2enum = require( '@stdlib/blas/base/diagonal-type-str2enum' ); ``` -#### str2enum( operation ) +#### str2enum( diagonal ) Return the enumeration constant associated with a BLAS diagonal-type. diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt index 6dceb7f5fb71..50ca896470c3 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( operation ) +{{alias}}( diagonal ) Returns the enumeration constant associated with a BLAS diagonal type. Downstream consumers of this function should *not* rely on specific integer @@ -8,7 +8,7 @@ Parameters ---------- - operation: string + diagonal: string Diagonal type. Returns diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts index 1e1a7981555f..09f0bf7e8fb7 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/docs/types/index.d.ts @@ -25,14 +25,14 @@ * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. * -* @param operation - diagonal type +* @param diagonal - diagonal type * @returns enumeration constant * * @example * var v = str2enum( 'unit' ); * // returns */ -declare function str2enum( operation: string ): number | null; +declare function str2enum( diagonal: string ): number | null; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js index 795e9ee92e34..14a0a3878f6b 100644 --- a/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/diagonal-type-str2enum/lib/main.js @@ -37,15 +37,15 @@ var ENUM = enumeration(); * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UNIT == 0`). Instead, the function should be used in an opaque manner. * -* @param {string} operation - diagonal type +* @param {string} diagonal - diagonal type * @returns {(integer|null)} integer value or null * * @example * var v = str2enum( 'unit' ); * // returns */ -function str2enum( operation ) { - var v = ENUM[ operation ]; +function str2enum( diagonal ) { + var v = ENUM[ diagonal ]; return ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain }