8000 feat: add `lapack/base/dlacn2` by aayush0325 · Pull Request #7438 · stdlib-js/stdlib · GitHub
[go: up one dir, main page]

Skip to content

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
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
aayush0325 committed Jun 22, 2025
commit f75dfa4b2e3b72477438e94b6b973f7da6915604
105 changes: 105 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js
10000
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' );
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();
});
82 changes: 82 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.js
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' );
}
});
Loading
0