From b088ce640ffcb024df1a7cd606525d4b7fd18ee6 Mon Sep 17 00:00:00 2001 From: Dhruvan Gnanadhandayuthapani Date: Mon, 23 Mar 2026 20:07:57 +0100 Subject: [PATCH] feat: add `blas/base/assert/is-transposed` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../blas/base/assert/is-transposed/README.md | 125 ++++++++++++++++++ .../is-transposed/benchmark/benchmark.js | 60 +++++++++ .../base/assert/is-transposed/docs/repl.txt | 29 ++++ .../is-transposed/docs/types/index.d.ts | 45 +++++++ .../assert/is-transposed/docs/types/test.ts | 34 +++++ .../assert/is-transposed/examples/index.js | 37 ++++++ .../base/assert/is-transposed/lib/index.js | 48 +++++++ .../base/assert/is-transposed/lib/main.js | 51 +++++++ .../base/assert/is-transposed/package.json | 75 +++++++++++ .../base/assert/is-transposed/test/test.js | 82 ++++++++++++ 10 files changed, 586 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/assert/is-transposed/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/README.md b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/README.md new file mode 100644 index 000000000000..846287e2f92c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/README.md @@ -0,0 +1,125 @@ + + +# isTransposed + +> Test whether an input value indicates that a matrix should be transposed. + + + +
+ +Test whether an input value indicates that a matrix should be transposed. + +
+ + + + + +
+ +## Usage + +```javascript +var isTransposed = require( '@stdlib/blas/base/assert/is-transposed' ); +``` + +#### isTransposed( value ) + +Test whether an input value indicates that a matrix should be transposed. + +```javascript +var bool = isTransposed( 'transpose' ); +// returns true + +bool = isTransposed( 'conjugate-transpose' ); +// returns true + +bool = isTransposed( 'no-transpose' ); +// returns false + +bool = isTransposed( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var isTransposed = require( '@stdlib/blas/base/assert/is-transposed' ); + +var bool = isTransposed( 'transpose' ); +// returns true + +bool = isTransposed( 'conjugate-transpose' ); +// returns true + +bool = isTransposed( 'no-transpose' ); +// returns false + +bool = isTransposed( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/benchmark/benchmark.js new file mode 100644 index 000000000000..f265a0e9bbda --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/benchmark/benchmark.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isTransposed = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + 'transpose', + 'conjugate-transpose', + 'no-transpose', + 'foo', + 'bar', + '', + 'beep', + 'boop' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = isTransposed( values[ i%values.length ] ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/repl.txt new file mode 100644 index 000000000000..70e949455999 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/repl.txt @@ -0,0 +1,29 @@ + +{{alias}}( value ) + Test whether an input value indicates that a matrix should be transposed. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value indicates that a matrix should be + transposed. + + Examples + -------- + > var bool = {{alias}}( 'transpose' ) + true + > bool = {{alias}}( 'conjugate-transpose' ) + true + > bool = {{alias}}( 'no-transpose' ) + false + > bool = {{alias}}( 'foo' ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/index.d.ts new file mode 100644 index 000000000000..5296eef4f93e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/index.d.ts @@ -0,0 +1,45 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 + +/** +* Test whether an input value indicates that a matrix should be transposed. +* +* @param value - value to test +* @returns boolean indicating whether an input value indicates that a matrix should be transposed. +* +* @example +* var bool = isTransposed( 'transpose' ); +* // returns true +* +* bool = isTransposed( 'conjugate-transpose' ); +* // returns true +* +* bool = isTransposed( 'no-transpose' ); +* // returns false +* +* bool = isTransposed( 'foo' ); +* // returns false +*/ +declare function isTransposed( value: any ): boolean; + + +// EXPORTS // + +export = isTransposed; diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/test.ts new file mode 100644 index 000000000000..1bd7570aac12 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isTransposed = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isTransposed( 'transpose' ); // $ExpectType boolean + isTransposed( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isTransposed(); // $ExpectError + isTransposed( 'foo', 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/examples/index.js b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/examples/index.js new file mode 100644 index 000000000000..1bf9f98a3831 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isTransposed = require( './../lib' ); + +var bool = isTransposed( 'transpose' ); +console.log( bool ); +// => true + +bool = isTransposed( 'conjugate-transpose' ); +console.log( bool ); +// => true + +bool = isTransposed( 'no-transpose' ); +console.log( bool ); +// => false + +bool = isTransposed( 'foo' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/index.js b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/index.js new file mode 100644 index 000000000000..9d7d549595e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/index.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Test whether an input value indicates that a matrix should be transposed. +* +* @module @stdlib/blas/base/assert/is-transposed +* +* @example +* var isTransposed = require( '@stdlib/blas/base/assert/is-transposed' ); +* var bool = isTransposed( 'transpose' ); +* // returns true +* +* bool = isTransposed( 'conjugate-transpose' ); +* // returns true +* +* bool = isTransposed( 'no-transpose' ); +* // returns false +* +* bool = isTransposed( 'foo' ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/main.js b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/main.js new file mode 100644 index 000000000000..16f39c996482 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/lib/main.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MAIN // + +/** +* Test whether an input value indicates that a matrix should be transposed. +* +* @name isTransposed +* @type {Function} +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether an input value indicates that a matrix should be transposed. +* +* @example +* var bool = isTransposed( 'transpose' ); +* // returns true +* +* bool = isTransposed( 'conjugate-transpose' ); +* // returns true +* +* bool = isTransposed( 'no-transpose' ); +* // returns false +* +* bool = isTransposed( 'foo' ); +* // returns false +*/ +function isTransposed( value ) { + return ( ( value === 'transpose' ) || ( value === 'conjugate-transpose' ) ); +} + + +// EXPORTS // + +module.exports = isTransposed; diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/package.json b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/package.json new file mode 100644 index 000000000000..49d432c6cea3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/blas/base/assert/is-transposed", + "version": "0.0.0", + "description": "Test whether an input value indicates that a matrix should be transposed.", + "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", + "stdtypes", + "types", + "base", + "blas", + "transpose", + "multidimensional", + "ndarray", + "array", + "utilities", + "utility", + "utils", + "util", + "assert", + "test", + "check", + "is", + "valid", + "validate", + "validation", + "isvalid" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/assert/is-transposed/test/test.js b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/test/test.js new file mode 100644 index 000000000000..a02892a06a5d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/assert/is-transposed/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isTransposed = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isTransposed, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a transpose operation', function test( t ) { + var values; + var bool; + var i; + + values = [ + 'transpose', + 'conjugate-transpose' + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isTransposed( values[ i ] ); + t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided a transpose operation', function test( t ) { + var values; + var bool; + var i; + + values = [ + 'no-transpose', + 'c', + 'fortran', + 'c-style', + 'fortran-style', + '', + 'beep', + 'boop', + 'foo', + 'bar', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isTransposed( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +});