-
-
Notifications
You must be signed in to change notification settings - Fork 859
feat: add lapack/base/dlacn2
#7438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aayush0325
wants to merge
19
commits into
stdlib-js:develop
Choose a base branch
from
aayush0325:lapack-dlacn2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5a51004
feat: add lapack/base/dlacn2
aayush0325 c2e6432
feat: add main exports
aayush0325 dba2eef
feat: add examples and benchmarks
aayush0325 f75dfa4
test: initial tests
aayush0325 bb6e5b2
test: add more tests
aayush0325 9660600
test: add test for N = 1
aayush0325 6169554
test: more tests
aayush0325 264501f
test: update tests
aayush0325 9c9a66a
test: add offset tests
aayush0325 81ad8a9
test: write tests
aayush0325 c2960b2
docs: add ts files
aayush0325 b0a1814
docs: update jsdoc
aayush0325 4181009
docs: add readme
aayush0325 60e6fba
docs: add repl.txt
aayush0325 3d5761d
Merge remote-tracking branch 'upstream/develop' into lapack-dlacn2
stdlib-bot 2e1ec09
refactor: add comments and optimise pointer arithmetic
aayush0325 805e889
chore: cleaning up
aayush0325 e7d80da
chore: cleanup
aayush0325 4417f63
chore: cleanup
aayush0325 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: initial tests
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
- Loading branch information
commit f75dfa4b2e3b72477438e94b6b973f7da6915604
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* @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'; | ||
|
||
/* eslint-disable array-element-newline */ | ||
|
||
// MODULES // | ||
|
||
var tape = require( 'tape' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var Int32Array = require( '@stdlib/array/int32' ); | ||
var dgemv = require( '@stdlib/blas/base/dgemv' ); | ||
var dcopy = require( '@stdlib/blas/base/dcopy' ); | ||
var dlacn2 = require( './../lib/dlacn2.js' ); | ||
|
||
|
||
// TESTS // | ||
|
||
tape( 'main export is a function', function test( t ) { | ||
t.ok( true, __filename ); | ||
t.strictEqual( typeof dlacn2, 'function', 'main export is a function' ); | ||
10000 | t.end(); | |
}); | ||
|
||
tape( 'the function has an arity of 7', function test( t ) { | ||
t.strictEqual( dlacn2.length, 7, 'returns expected value' ); | ||
t.end(); | ||
}); | ||
|
||
tape( 'the function returns expected values when calculating the one-norm of a square matrix', function test( t ) { | ||
var expectedISAVE; | ||
var expectedKASE; | ||
var expectedISGN; | ||
var expectedEST; | ||
var expectedV; | ||
var ISAVE; | ||
var KASE; | ||
var ISGN; | ||
var work; | ||
var EST; | ||
var X; | ||
var V; | ||
var A; | ||
|
||
A = new Float64Array([ | ||
1.0, -2.0, 0.0, 0.0, | ||
3.0, 4.0, -5.0, 0.0, | ||
0.0, 6.0, 7.0, -8.0, | ||
0.0, 0.0, 9.0, 10.0 | ||
]); | ||
|
||
KASE = new Int32Array( 1 ); | ||
EST = new Float64Array( 1 ); | ||
ISGN = new Int32Array( 4 ); | ||
ISAVE = new Int32Array( 3 ); | ||
X = new Float64Array( 4 ); | ||
V = new Float64Array( 4 ); | ||
|
||
work = new Float64Array( 4 ); | ||
|
||
while ( true ) { | ||
dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); | ||
|
||
if ( KASE[ 0 ] === 0 ) { | ||
break; | ||
} | ||
else if ( KASE[ 0 ] === 1 ) { | ||
dgemv( 'row-major', 'no-transpose', 4, 4, 1.0, A, 4, X, 1, 0, work, 1 ); | ||
dcopy( 4, work, 1, X, 1 ); | ||
} else if ( KASE[ 0 ] === 2 ) { | ||
dgemv( 'row-major', 'transpose', 4, 4, 1.0, A, 4, X, 1, 0, work, 1 ); | ||
dcopy( 4, work, 1, X, 1 ); | ||
} | ||
} | ||
|
||
expectedEST = new Float64Array( [ 12.0 ] ); | ||
expectedV = new Float64Array( [ -2.0, 4.0, 6.0, 0.0 ] ); | ||
expectedKASE = new Int32Array( [ 0 ] ); | ||
expectedISGN = new Int32Array( [ -1, 1, 1, 1 ] ); | ||
expectedISAVE = new Int32Array( [ 5, 1, 2 ] ); | ||
|
||
t.deepEqual( KASE, expectedKASE, 'returns expected value' ); | ||
t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); | ||
t.deepEqual( EST, expectedEST, 'returns expected value' ); | ||
t.deepEqual( V, expectedV, 'returns expected value' ); | ||
t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); | ||
|
||
t.end(); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2025 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 proxyquire = require( 'proxyquire' ); | ||
var IS_BROWSER = require( '@stdlib/assert/is-browser' ); | ||
var dlacn2 = require( './../lib' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var opts = { | ||
'skip': IS_BROWSER | ||
}; | ||
|
||
|
||
// TESTS // | ||
|
||
tape( 'main export is a function', function test( t ) { | ||
t.ok( true, __filename ); | ||
t.strictEqual( typeof dlacn2, 'function', 'main export is a function' ); | ||
t.end(); | ||
}); | ||
|
||
tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { | ||
t.strictEqual( typeof dlacn2.ndarray, 'function', 'method is a function' ); | ||
t.end(); | ||
}); | ||
|
||
tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { | ||
var dlacn2 = proxyquire( './../lib', { | ||
'@stdlib/utils/try-require': tryRequire | ||
}); | ||
|
||
t.strictEqual( dlacn2, mock, 'returns expected value' ); | ||
t.end(); | ||
|
||
function tryRequire() { | ||
return mock; | ||
} | ||
|
||
function mock() { | ||
// Mock... | ||
} | ||
}); | ||
|
||
tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { | ||
var dlacn2; | ||
var main; | ||
|
||
main = require( './../lib/dlacn2.js' ); | ||
|
||
dlacn2 = proxyquire( './../lib', { | ||
'@stdlib/utils/try-require': tryRequire | ||
}); | ||
|
||
t.strictEqual( dlacn2, main, 'returns expected value' ); | ||
t.end(); | ||
|
||
function tryRequire() { | ||
return new Error( 'Cannot find module' ); | ||
} | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.