Skip to content

feat: add javascript implementation for lapack/base/dlaswp #2483

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

Merged
merged 61 commits into from
Jul 13, 2024
Merged
Changes from 2 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
c92f72c
feat: add initial implementation for lapack/base/dlaswp
Pranavchiku Jul 1, 2024
eece712
chore: update dlaswp.js
Pranavchiku Jul 1, 2024
b35d940
chore: update dlaswp.js
Pranavchiku Jul 1, 2024
5f84f99
chore: update dlaswp.js
Pranavchiku Jul 1, 2024
711aa9b
chore: lib/index.js
Pranavchiku Jul 1, 2024
b0eec9a
chore: add dlaswp.js
Pranavchiku Jul 1, 2024
4649c54
chore: add main.js
Pranavchiku Jul 1, 2024
44075d2
chore: delete lapack/blas/dlaswp.js
Pranavchiku Jul 1, 2024
dd393d4
chore: add example
Pranavchiku Jul 1, 2024
40349ca
chore: add README.md
Pranavchiku Jul 1, 2024
e19ff82
chore: add package.json
Pranavchiku Jul 1, 2024
559824a
chore: add README.md
Pranavchiku Jul 1, 2024
9dcfa53
chore: add repl.txt
Pranavchiku Jul 1, 2024
b761225
chore: add test.ts
Pranavchiku Jul 1, 2024
d3f8069
chore: add index.d.ts
Pranavchiku Jul 1, 2024
15a6b5a
chore: add benchmark
Pranavchiku Jul 1, 2024
6326803
fix: row-major implementation
Pranavchiku Jul 1, 2024
682b172
test: add tests
Pranavchiku Jul 1, 2024
dccfcf8
chore: apply suggestion and replace incX with strideIPIV
Pranavchiku Jul 1, 2024
d88b69b
chore: apply suggestion in index.d.ts
Pranavchiku Jul 1, 2024
6514e12
chore: add all files
Pranavchiku Jul 1, 2024
486985f
chore: show sipiv instead of strideIPIV in readme and repl
Pranavchiku Jul 1, 2024
01237eb
chore: apply code review
Pranavchiku Jul 1, 2024
2a0cf83
chore: apply code review
Pranavchiku Jul 1, 2024
1cb1206
chore: apply suggestions from code review
Pranavchiku Jul 1, 2024
3a6dc5c
test: update incorrect description
Pranavchiku Jul 2, 2024
62e1af9
chore: update base.js description
Pranavchiku Jul 2, 2024
1a91314
chore: link to LAPACK doc in readme
Pranavchiku Jul 2, 2024
8610f1a
chore: update package level description
Pranavchiku Jul 2, 2024
a336167
chore: introduce offsetIPIV and consequent changes
Pranavchiku Jul 2, 2024
d2507ac
bench: update data generation
kgryte Jul 3, 2024
b436402
refactor: reorder parameters
kgryte Jul 4, 2024
6001634
test: reorder parameters
kgryte Jul 4, 2024
db68b19
chore: consequent changes of parameter reorder
Pranavchiku Jul 5, 2024
d5bcee5
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into pr…
kgryte Jul 10, 2024
c5f42cd
temp: save snapshot
kgryte Jul 11, 2024
fee1ce6
refactor: update to support matrix strides
kgryte Jul 11, 2024
f317d45
test: rename fixtures and update ndarray tests
kgryte Jul 11, 2024
ddfd2c7
fix: account for layout when passing stride arguments and update tests
kgryte Jul 11, 2024
3e53660
docs: fix parameters and resolve lint errors
kgryte Jul 11, 2024
d668fe1
docs: fix example
kgryte Jul 11, 2024
5c29c0f
docs: update example
kgryte Jul 11, 2024
81b27ac
chore: consequent changes
Pranavchiku Jul 11, 2024
4c663d3
fix: incorrect readme example
Pranavchiku Jul 11, 2024
5af48c0
bench: add facet for the number of interchanged rows
kgryte Jul 11, 2024
254f41f
bench: add facet for measuring performance for different layouts
kgryte Jul 11, 2024
8c47131
docs: update descriptions
kgryte Jul 11, 2024
0f69c03
docs: update descriptions
kgryte Jul 11, 2024
402d5c8
docs: update example
kgryte Jul 11, 2024
70dc36f
chore: update keywords
kgryte Jul 11, 2024
03eed0f
fix: ensure support for applying pivots in reverse
kgryte Jul 12, 2024
461749a
refactor: remove comments
kgryte Jul 12, 2024
9b9dbce
test: add tests for applying pivots in reverse with an IPIV stride
kgryte Jul 12, 2024
45facca
test: add tests for appying pivots in reverse with an IPIV offset
kgryte Jul 12, 2024
1ec29ed
test: add tests for positive `k1` value
kgryte Jul 12, 2024
0a99eed
docs: update copy
kgryte Jul 12, 2024
b50c740
test: add stride tests
kgryte Jul 13, 2024
be33a85
test: add error handling tests
kgryte Jul 13, 2024
6247f98
docs: add example
kgryte Jul 13, 2024
8dd21b6
docs: update copy
kgryte Jul 13, 2024
9019417
docs: fix note
kgryte Jul 13, 2024
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
151 changes: 151 additions & 0 deletions lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/**
* @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 isLayout = require( '@stdlib/blas/base/assert/is-layout' );
var floor = require( '@stdlib/math/base/special/floor' );
var dswap = require( '@stdlib/blas/base/dswap' );


// MAIN //

/**
* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`.
*
* @param {string} order - storage layout
* @param {PositiveInteger} N - number of columns of `A`
* @param {Float64Array} A - matrix
* @param {PositiveInteger} LDA - leading dimension of `A`
* @param {PositiveInteger} k1 - index of first row to interchange
* @param {PositiveInteger} k2 - index of last row to interchange
* @param {Int32Array} IPIV - vector of pivot indices
* @param {PositiveInteger} incX - increment between successive values of `IPIV`
* @returns {Float64Array} permuted matrix `A`
*
* @example
* var Int32Array = require( '@stdlib/array/int32' );
* var Float64Array = require( '@stdlib/array/float64' );
*
* var IPIV = new Int32Array( [ 2, 0, 1 ] );
* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
*
* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 );
* // A => <Float64Array>[ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ]
*/
function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) {

Check failure on line 53 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

`dlaswp` is missing `@throws {TypeError}` annotation(s)
var IPIV;

Check failure on line 54 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

IPIV is already defined
var incX;

Check failure on line 55 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

incX is already defined
var inc;
var ix0;
var LDA;

Check failure on line 58 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

LDA is already defined
var n32;
var tmp;
var i2;
var ip;
var ix;
var k1;

Check failure on line 64 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

k1 is already defined
var k2;

Check failure on line 65 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

k2 is already defined
var i1;
var A;

Check failure on line 67 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

A is already defined
var i;
var j;
var k;
var N;

Check failure on line 71 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

N is already defined

if ( !isLayout( order ) ) {
throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order );
}

if ( incX > 0 ) {
ix0 = k1;
i1 = k1;
i2 = k2;
inc = 1;
} else if ( incX < 0 ) {
ix0 = k1 + ( k1 - k2 ) * incX;

Check failure on line 83 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected mix of '+' and '*'. Use parentheses to clarify the intended order of operations

Check failure on line 83 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected mix of '+' and '*'. Use parentheses to clarify the intended order of operations
i1 = k2;
i2 = k1;
inc = -1;
} else {
return A;
}

if ( order === 'row-major' ) {
ix = ix0;
if ( inc === 1 ) {
for ( i = i1; i <= i2; i++ ) {
ip = IPIV[ ix ];
if ( ip !== i ) {
dswap( N, A, i * LDA, A, ip * LDA);
}
ix += incX;
}
return A;
}
for ( i = i1; i >= i2; i-- ) {
ip = IPIV[ ix ];
if ( ip !== i ) {
dswap( N, A, i * LDA, A, ip * LDA);
}
ix += incX;
}
return A;
} else {
n32 = floor( N / 32 ) * 32;
if ( n32 !== 0 ) {
for ( j = 1; j < n32; j += 32 ) {
ix = ix0;
for ( i = i1; i < i2; i += inc ) {
ip = IPIV[ ix ];
if ( ip !== i ) {
for ( k = j; k < j + 31; k++ ) {
tmp = A[ ( k - 1 ) * LDA + i ];
A[ ( k - 1 ) * LDA + i ] = A[ ( k - 1 ) * LDA + ip ];

Check warning on line 121 in lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 81. Maximum allowed is 80
A[ ( k - 1 ) * LDA + ip ] = tmp;
}
}
ix += incX;
}
}
}
if ( n32 !== N ) {
n32 += 1;
ix = ix0;
for ( i = i1; i < i2; i += inc ) {
ip = IPIV[ ix ];
if ( ip !== i ) {
for ( k = n32; k < N; k++ ) {
tmp = A[ ( k - 1 ) * LDA + i ];
A[ ( k - 1 ) * LDA + i ] = A[ ( k - 1 ) * LDA + ip ];
A[ ( k - 1 ) * LDA + ip ] = tmp;
}
}
ix += incX;
}
}
return A;
}
}


// EXPORTS //

module.exports = dlaswp;
Loading