-
-
Notifications
You must be signed in to change notification settings - Fork 870
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
Changes from 1 commit
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 eece712
chore: update dlaswp.js
Pranavchiku b35d940
chore: update dlaswp.js
Pranavchiku 5f84f99
chore: update dlaswp.js
Pranavchiku 711aa9b
chore: lib/index.js
Pranavchiku b0eec9a
chore: add dlaswp.js
Pranavchiku 4649c54
chore: add main.js
Pranavchiku 44075d2
chore: delete lapack/blas/dlaswp.js
Pranavchiku dd393d4
chore: add example
Pranavchiku 40349ca
chore: add README.md
Pranavchiku e19ff82
chore: add package.json
Pranavchiku 559824a
chore: add README.md
Pranavchiku 9dcfa53
chore: add repl.txt
Pranavchiku b761225
chore: add test.ts
Pranavchiku d3f8069
chore: add index.d.ts
Pranavchiku 15a6b5a
chore: add benchmark
Pranavchiku 6326803
fix: row-major implementation
Pranavchiku 682b172
test: add tests
Pranavchiku dccfcf8
chore: apply suggestion and replace incX with strideIPIV
Pranavchiku d88b69b
chore: apply suggestion in index.d.ts
Pranavchiku 6514e12
chore: add all files
Pranavchiku 486985f
chore: show sipiv instead of strideIPIV in readme and repl
Pranavchiku 01237eb
chore: apply code review
Pranavchiku 2a0cf83
chore: apply code review
Pranavchiku 1cb1206
chore: apply suggestions from code review
Pranavchiku 3a6dc5c
test: update incorrect description
Pranavchiku 62e1af9
chore: update base.js description
Pranavchiku 1a91314
chore: link to LAPACK doc in readme
Pranavchiku 8610f1a
chore: update package level description
Pranavchiku a336167
chore: introduce offsetIPIV and consequent changes
Pranavchiku d2507ac
bench: update data generation
kgryte b436402
refactor: reorder parameters
kgryte 6001634
test: reorder parameters
kgryte db68b19
chore: consequent changes of parameter reorder
Pranavchiku d5bcee5
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into pr…
kgryte c5f42cd
temp: save snapshot
kgryte fee1ce6
refactor: update to support matrix strides
kgryte f317d45
test: rename fixtures and update ndarray tests
kgryte ddfd2c7
fix: account for layout when passing stride arguments and update tests
kgryte 3e53660
docs: fix parameters and resolve lint errors
kgryte d668fe1
docs: fix example
kgryte 5c29c0f
docs: update example
kgryte 81b27ac
chore: consequent changes
Pranavchiku 4c663d3
fix: incorrect readme example
Pranavchiku 5af48c0
bench: add facet for the number of interchanged rows
kgryte 254f41f
bench: add facet for measuring performance for different layouts
kgryte 8c47131
docs: update descriptions
kgryte 0f69c03
docs: update descriptions
kgryte 402d5c8
docs: update example
kgryte 70dc36f
chore: update keywords
kgryte 03eed0f
fix: ensure support for applying pivots in reverse
kgryte 461749a
refactor: remove comments
kgryte 9b9dbce
test: add tests for applying pivots in reverse with an IPIV stride
kgryte 45facca
test: add tests for appying pivots in reverse with an IPIV offset
kgryte 1ec29ed
test: add tests for positive `k1` value
kgryte 0a99eed
docs: update copy
kgryte b50c740
test: add stride tests
kgryte be33a85
test: add error handling tests
kgryte 6247f98
docs: add example
kgryte 8dd21b6
docs: update copy
kgryte 9019417
docs: fix note
kgryte 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
There are no files selected for viewing
133 changes: 133 additions & 0 deletions
133
lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.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,133 @@ | ||
/** | ||
* @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' ); | ||
|
||
|
||
// MAIN // | ||
|
||
/** | ||
* Performs a series of row interchanges on the matrix `A`. | ||
* | ||
* @param {PositiveInteger} N - number of columns of `A` | ||
* @param {Array} A - matrix | ||
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param {PositiveInteger} LDA - leading dimension of `A` | ||
* @param {PositiveInteger} k1 - first element of `IPIV` for which a row interchange will be done | ||
* @param {PositiveInteger} k2 - second element of `IPIV` for which a row interchange will be done | ||
kgryte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param {Array} IPIV - vector of pivot indices | ||
* @param {PositiveInteger} incX - increment between successive values of `IPIV` | ||
* @returns {Float64Array} permuted matrix `A` | ||
* | ||
* @example | ||
* TODO: | ||
*/ | ||
function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { | ||
kgryte marked this conversation as resolved.
Show resolved
Hide resolved
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var IPIV; | ||
var incX; | ||
var inc; | ||
var ix0; | ||
var LDA; | ||
var n32; | ||
var tmp; | ||
var i2; | ||
var ip; | ||
var ix; | ||
var k1; | ||
var k2; | ||
var i1; | ||
var A; | ||
var i; | ||
var j; | ||
var k; | ||
var N; | ||
|
||
if ( !isLayout( order ) ) { | ||
throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); | ||
} | ||
|
||
// Interchange row I with IPIV( k1 + ( I - k1 ) * abs( incX ) ) for | ||
// each rows k1 through k2. | ||
if ( incX > 0 ) { | ||
ix0 = k1; | ||
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
i1 = k1; | ||
i2 = k2; | ||
inc = 1; | ||
} else if ( incX < 0 ) { | ||
ix0 = k1 + ( k1 - k2 ) * incX; | ||
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
i1 = k2; | ||
i2 = k1; | ||
inc = -1; | ||
} else { | ||
return; | ||
} | ||
|
||
n32 = ( N / 32 ) * 32; | ||
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if ( n32 != 0 ) { | ||
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for ( j = 0; j < n32; j += 32 ) { | ||
ix = ix0; | ||
for ( i = i1 - 1; i < i2; i += inc ) { | ||
ip = IPIV[ ix - 1 ]; | ||
if ( ip != i ) { | ||
for ( k = j; k <= j + 31; k++ ) { | ||
if ( order == 'row-major' ) { | ||
kgryte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tmp = A[ i * LDA + k ]; | ||
A[ i * LDA + k ] = A[ ip * LDA + k ]; | ||
A[ ip * LDA + k ] = tmp; | ||
} else { | ||
tmp = A[ k * LDA + i ]; | ||
A[ k * LDA + i ] = A[ k * LDA + ip ]; | ||
A[ k * LDA + ip ] = tmp; | ||
} | ||
} | ||
} | ||
ix += incX; | ||
} | ||
} | ||
} | ||
if ( n32 != N ) { | ||
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
n32 += 1; | ||
ix = ix0; | ||
for ( i = i1 - 1; i < i2; i += inc ) { | ||
ip = IPIV[ ix - 1 ]; | ||
if ( ip != i ) { | ||
for ( k = n32 - 1 ; k < N; k++ ) { | ||
if ( order == 'row-major' ) { | ||
tmp = A[ i * LDA + k ]; | ||
A[ i * LDA + k ] = A[ ip * LDA + k ]; | ||
A[ ip * LDA + k ] = tmp; | ||
} else { | ||
tmp = A[ k * LDA + i ]; | ||
A[ k * LDA + i ] = A[ k * LDA + ip ]; | ||
Pranavchiku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
A[ k * LDA + ip ] = tmp; | ||
} | ||
} | ||
} | ||
ix += incX; | ||
} | ||
} | ||
return A; | ||
} | ||
kgryte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = dlaswp; |
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.