From 2c200fe903ef0aaa7d9fc684935b4aa95430e95f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 6 Jul 2024 06:12:36 +0000 Subject: [PATCH] Auto-generated commit --- .github/.keepalive | 1 - CHANGELOG.md | 106 +++++++++++++++++++++++++++++++++++++++++++-- dist/index.js | 14 +++--- dist/index.js.map | 8 ++-- lib/dswap.js | 62 +++----------------------- package.json | 1 + 6 files changed, 121 insertions(+), 71 deletions(-) delete mode 100644 .github/.keepalive diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 537714b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T01:54:10.013Z diff --git a/CHANGELOG.md b/CHANGELOG.md index 16c2e19..a84519d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,94 @@
-## Unreleased (2024-07-01) +## Unreleased (2024-07-06) + +
+ +### Features + +- [`ee78820`](https://github.com/stdlib-js/stdlib/commit/ee788201141cbc9a25d1d74982c1c762080ae6fb) - add support for specifying integer size + +
+ + + +
+ +### Bug Fixes + +- [`5c514c7`](https://github.com/stdlib-js/stdlib/commit/5c514c7ad5828bc5047594ff001d11334f8f5670) - specify integer type to match CBLAS + +
+ + + +
+ +### Commits + +
+ +- [`271f5d5`](https://github.com/stdlib-js/stdlib/commit/271f5d5d3e530225bd82f34efebf5df9a944fdde) - **refactor:** reduce code duplication in `blas/base` level 1 routines [(#2517)](https://github.com/stdlib-js/stdlib/pull/2517) _(by Aman Bhansali)_ +- [`6226f32`](https://github.com/stdlib-js/stdlib/commit/6226f32ba8be2b8d880353194c510e629760b53f) - **docs:** update signatures _(by Athan Reines)_ +- [`f104cf4`](https://github.com/stdlib-js/stdlib/commit/f104cf45eeb8638e70830f6d42f2a8ed96912ebc) - **refactor:** support building with API suffix _(by Athan Reines)_ +- [`5c514c7`](https://github.com/stdlib-js/stdlib/commit/5c514c7ad5828bc5047594ff001d11334f8f5670) - **fix:** specify integer type to match CBLAS _(by Athan Reines)_ +- [`ee78820`](https://github.com/stdlib-js/stdlib/commit/ee788201141cbc9a25d1d74982c1c762080ae6fb) - **feat:** add support for specifying integer size _(by Athan Reines)_ +- [`38464b7`](https://github.com/stdlib-js/stdlib/commit/38464b74545be9702eda7bae820c40b56e7e7256) - **docs:** remove comments _(by Athan Reines)_ +- [`f1576ec`](https://github.com/stdlib-js/stdlib/commit/f1576ec5ade09cd8cd034dc0db8c9f5c7d70e3eb) - **docs:** remove comments _(by Athan Reines)_ +- [`1c696a0`](https://github.com/stdlib-js/stdlib/commit/1c696a0ef09fc302874c25e924cfbc5c4c95ce30) - **build:** add separate configurations for benchmarks and examples _(by Athan Reines)_ +- [`0244027`](https://github.com/stdlib-js/stdlib/commit/0244027e1e2c0ceb1cd8ae1808196c24fa77b142) - **chore:** add missing trailing newlines _(by Philipp Burckhardt)_ + +
+ +
+ + + +
+ +### Contributors + +A total of 3 people contributed to this release. Thank you to the following contributors: + +- Aman Bhansali +- Athan Reines +- Philipp Burckhardt + +
+ + + +
+ + + +
+ +## 0.2.1 (2024-02-22) + +
+ +### Features + +- [`cca37d0`](https://github.com/stdlib-js/stdlib/commit/cca37d051d8c0209970fc681353fdb4e4d257a8a) - update minimum TypeScript version + +
+ + + +
+ +### BREAKING CHANGES + +- [`cca37d0`](https://github.com/stdlib-js/stdlib/commit/cca37d051d8c0209970fc681353fdb4e4d257a8a): update minimum TypeScript version +- [`cca37d0`](https://github.com/stdlib-js/stdlib/commit/cca37d051d8c0209970fc681353fdb4e4d257a8a): update minimum TypeScript version to 4.1 + + - To migrate, users should upgrade their TypeScript version to at least version 4.1. + +
+ +
@@ -12,7 +99,19 @@
-- [`a591e05`](https://github.com/stdlib-js/stdlib/commit/a591e052cf1b1515c267781b914c6a482e150425) - **test:** fix test configuration _(by Athan Reines)_ +- [`dea49e0`](https://github.com/stdlib-js/stdlib/commit/dea49e03ab5571233e3da26835a6a6d3256d5737) - **docs:** use single quotes in require calls instead of backticks _(by Philipp Burckhardt)_ +- [`004b244`](https://github.com/stdlib-js/stdlib/commit/004b24478b4af2a51f2e568fe2c1efd8cb5ef59d) - **docs:** update examples to use random/array utilities _(by Athan Reines)_ +- [`efc6522`](https://github.com/stdlib-js/stdlib/commit/efc65220a39e226839fd507b59190d6402bebe61) - **bench:** update benchmarks to use random/array utilities _(by Athan Reines)_ +- [`4ec2cd0`](https://github.com/stdlib-js/stdlib/commit/4ec2cd0d22446eac8818845f4a816d2d4a1bfde2) - **docs:** update copy _(by Athan Reines)_ +- [`a7badd8`](https://github.com/stdlib-js/stdlib/commit/a7badd864d83199f2221f9e71eb65504df8dba3d) - **build:** add wasm configuration _(by Athan Reines)_ +- [`888e071`](https://github.com/stdlib-js/stdlib/commit/888e0715e4a32f56fdf975dedb5fbbe81b63b280) - **test:** update assertion messages _(by Athan Reines)_ +- [`2514e0a`](https://github.com/stdlib-js/stdlib/commit/2514e0afdaaa875b378bf3761a43be6c841549fd) - **refactor:** avoid unnecessary cast _(by Athan Reines)_ +- [`e14f9fe`](https://github.com/stdlib-js/stdlib/commit/e14f9fe08ccf094847acd12e17757870b9a5a417) - **docs:** update example _(by Athan Reines)_ +- [`5a36be3`](https://github.com/stdlib-js/stdlib/commit/5a36be3f681bf65914abdc58bbc3142533cb2328) - **style:** resolve lint errors _(by Athan Reines)_ +- [`df3c9b3`](https://github.com/stdlib-js/stdlib/commit/df3c9b368d8a3dd7dd38f8768deb53c2a780c055) - **build:** remove tslint directives _(by Philipp Burckhardt)_ +- [`cca37d0`](https://github.com/stdlib-js/stdlib/commit/cca37d051d8c0209970fc681353fdb4e4d257a8a) - **feat:** update minimum TypeScript version _(by Philipp Burckhardt)_ +- [`28e1c84`](https://github.com/stdlib-js/stdlib/commit/28e1c84390d88044883c9ef940a12f38d66ea3ef) - **docs:** resolve C lint errors _(by Athan Reines)_ +- [`9d552f8`](https://github.com/stdlib-js/stdlib/commit/9d552f8ee1087df295267fd3ddc2e5a04526ed6a) - **docs:** standardize parameter description and update docs _(by Athan Reines)_
@@ -24,9 +123,10 @@ ### Contributors -A total of 1 person contributed to this release. Thank you to this contributor: +A total of 2 people contributed to this release. Thank you to the following contributors: - Athan Reines +- Philipp Burckhardt
diff --git a/dist/index.js b/dist/index.js index 8485369..19f3ad8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,10 +1,10 @@ -"use strict";var m=function(n,a){return function(){return a||n((a={exports:{}}).exports,a),a.exports}};var w=m(function(G,l){ -var c=3;function g(n,a,s,v,e){var t,p,u,i,r,f;if(n<=0)return v;if(s===1&&e===1){if(i=n%c,i>0)for(r=0;r0)for(o=0;o0)for(v=0;v [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction dswap( N, x, strideX, y, strideY ) {\n\tvar tmp;\n\tvar ix;\n\tvar iy;\n\tvar m;\n\tvar i;\n\tvar j;\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\t// Use unrolled loops if both strides are equal to `1`...\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ttmp = x[ i ];\n\t\t\t\tx[ i ] = y[ i ];\n\t\t\t\ty[ i ] = tmp;\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn y;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\ttmp = x[ i ];\n\t\t\tx[ i ] = y[ i ];\n\t\t\ty[ i ] = tmp;\n\n\t\t\tj = i + 1;\n\t\t\ttmp = x[ j ];\n\t\t\tx[ j ] = y[ j ];\n\t\t\ty[ j ] = tmp;\n\n\t\t\tj += 1;\n\t\t\ttmp = x[ j ];\n\t\t\tx[ j ] = y[ j ];\n\t\t\ty[ j ] = tmp;\n\t\t}\n\t\treturn y;\n\t}\n\tif ( strideX < 0 ) {\n\t\tix = (1-N) * strideX;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( strideY < 0 ) {\n\t\tiy = (1-N) * strideY;\n\t} else {\n\t\tiy = 0;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\ttmp = x[ ix ];\n\t\tx[ ix ] = y[ iy ];\n\t\ty[ iy ] = tmp;\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar M = 3;\n\n\n// MAIN //\n\n/**\n* Interchanges two double-precision floating-point vectors.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {Float64Array} `y`\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );\n*\n* dswap( x.length, x, 1, 0, y, 1, 0 );\n* // x => [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction dswap( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar tmp;\n\tvar ix;\n\tvar iy;\n\tvar m;\n\tvar i;\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tix = offsetX;\n\tiy = offsetY;\n\n\t// Use unrolled loops if both strides are equal to `1`...\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ttmp = x[ ix ];\n\t\t\t\tx[ ix ] = y[ iy ];\n\t\t\t\ty[ iy ] = tmp;\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn y;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\ttmp = x[ ix ];\n\t\t\tx[ ix ] = y[ iy ];\n\t\t\ty[ iy ] = tmp;\n\n\t\t\ttmp = x[ ix+1 ];\n\t\t\tx[ ix+1 ] = y[ iy+1 ];\n\t\t\ty[ iy+1 ] = tmp;\n\n\t\t\ttmp = x[ ix+2 ];\n\t\t\tx[ ix+2 ] = y[ iy+2 ];\n\t\t\ty[ iy+2 ] = tmp;\n\n\t\t\tix += M;\n\t\t\tiy += M;\n\t\t}\n\t\treturn y;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\ttmp = x[ ix ];\n\t\tx[ ix ] = y[ iy ];\n\t\ty[ iy ] = tmp;\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dswap = require( './dswap.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dswap, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* BLAS level 1 routine to interchange two double-precision floating-point vectors.\n*\n* @module @stdlib/blas-base-dswap\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dswap = require( '@stdlib/blas-base-dswap' );\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );\n*\n* dswap( x.length, x, 1, y, 1 );\n* // x => [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dswap = require( '@stdlib/blas-base-dswap' );\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );\n*\n* dswap.ndarray( x.length, x, 1, 0, y, 1, 0 );\n* // x => [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dswap;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdswap = main;\n} else {\n\tdswap = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n\n// exports: { \"ndarray\": \"dswap.ndarray\" }\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAI,EAyBR,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAAGC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKV,GAAK,EACT,OAAOG,EAGR,GAAKD,IAAY,GAAKE,IAAY,EAAI,CAIrC,GAHAI,EAAIR,EAAIF,EAGHU,EAAI,EACR,IAAMC,EAAI,EAAGA,EAAID,EAAGC,IACnBJ,EAAMJ,EAAGQ,CAAE,EACXR,EAAGQ,CAAE,EAAIN,EAAGM,CAAE,EACdN,EAAGM,CAAE,EAAIJ,EAGX,GAAKL,EAAIF,EACR,OAAOK,EAER,IAAMM,EAAID,EAAGC,EAAIT,EAAGS,GAAKX,EACxBO,EAAMJ,EAAGQ,CAAE,EACXR,EAAGQ,CAAE,EAAIN,EAAGM,CAAE,EACdN,EAAGM,CAAE,EAAIJ,EAETK,EAAID,EAAI,EACRJ,EAAMJ,EAAGS,CAAE,EACXT,EAAGS,CAAE,EAAIP,EAAGO,CAAE,EACdP,EAAGO,CAAE,EAAIL,EAETK,GAAK,EACLL,EAAMJ,EAAGS,CAAE,EACXT,EAAGS,CAAE,EAAIP,EAAGO,CAAE,EACdP,EAAGO,CAAE,EAAIL,EAEV,OAAOF,CACR,CAWA,IAVKD,EAAU,EACdI,GAAM,EAAEN,GAAKE,EAEbI,EAAK,EAEDF,EAAU,EACdG,G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O,CAAG,EACZP,EAAGO,CAAG,EAAIJ,EAAGK,CAAG,EAChBL,EAAGK,CAAG,EAAIF,EACVC,GAAMN,EACNO,GAAMJ,EAEP,OAAOD,CACR,CAKAP,EAAO,QAAUE,IC7GjB,IAAAa,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAQ,IACRC,EAAU,IAKdF,EAAaC,EAAO,UAAWC,CAAQ,EAKvCH,EAAO,QAAUE,ICgBjB,IAAIE,EAAO,QAAS,MAAO,EAAE,KACzBC,EAAa,QAAS,2BAA4B,EAClDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAO,IAKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAQD,EAERC,EAAQC,EAMT,OAAO,QAAUD", - "names": ["require_dswap", "__commonJSMin", "exports", "module", "M", "dswap", "N", "x", "strideX", "y", "strideY", "tmp", "ix", "iy", "m", "i", "j", "require_ndarray", "__commonJSMin", "exports", "module", "M", "dswap", "N", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "tmp", "ix", "iy", "m", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dswap", "ndarray", "join", "tryRequire", "isError", "main", "dswap", "tmp"] + "sources": ["../lib/ndarray.js", "../lib/dswap.js", "../lib/main.js", "../lib/index.js"], + "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar M = 3;\n\n\n// MAIN //\n\n/**\n* Interchanges two double-precision floating-point vectors.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {Float64Array} `y`\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );\n*\n* dswap( x.length, x, 1, 0, y, 1, 0 );\n* // x => [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction dswap( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar tmp;\n\tvar ix;\n\tvar iy;\n\tvar m;\n\tvar i;\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tix = offsetX;\n\tiy = offsetY;\n\n\t// Use unrolled loops if both strides are equal to `1`...\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ttmp = x[ ix ];\n\t\t\t\tx[ ix ] = y[ iy ];\n\t\t\t\ty[ iy ] = tmp;\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn y;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\ttmp = x[ ix ];\n\t\t\tx[ ix ] = y[ iy ];\n\t\t\ty[ iy ] = tmp;\n\n\t\t\ttmp = x[ ix+1 ];\n\t\t\tx[ ix+1 ] = y[ iy+1 ];\n\t\t\ty[ iy+1 ] = tmp;\n\n\t\t\ttmp = x[ ix+2 ];\n\t\t\tx[ ix+2 ] = y[ iy+2 ];\n\t\t\ty[ iy+2 ] = tmp;\n\n\t\t\tix += M;\n\t\t\tiy += M;\n\t\t}\n\t\treturn y;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\ttmp = x[ ix ];\n\t\tx[ ix ] = y[ iy ];\n\t\ty[ iy ] = tmp;\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\n/**\n* Interchanges two double-precision floating-point vectors.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @returns {Float64Array} `y`\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );\n*\n* dswap( x.length, x, 1, y, 1 );\n* // x => [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction dswap( N, x, strideX, y, strideY ) {\n\tvar ix;\n\tvar iy;\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tix = stride2offset( N, strideX );\n\tiy = stride2offset( N, strideY );\n\treturn ndarray( N, x, strideX, ix, y, strideY, iy );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dswap = require( './dswap.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dswap, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* BLAS level 1 routine to interchange two double-precision floating-point vectors.\n*\n* @module @stdlib/blas-base-dswap\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dswap = require( '@stdlib/blas-base-dswap' );\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );\n*\n* dswap( x.length, x, 1, y, 1 );\n* // x => [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dswap = require( '@stdlib/blas-base-dswap' );\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );\n*\n* dswap.ndarray( x.length, x, 1, 0, y, 1, 0 );\n* // x => [ 6.0, 7.0, 8.0, 9.0, 10.0 ]\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dswap;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdswap = main;\n} else {\n\tdswap = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dswap;\n\n// exports: { \"ndarray\": \"dswap.ndarray\" }\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAI,EA2BR,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAAU,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKX,GAAK,EACT,OAAOI,EAMR,GAJAI,EAAKL,EACLM,EAAKH,EAGAJ,IAAY,GAAKG,IAAY,EAAI,CAIrC,GAHAK,EAAIV,EAAIF,EAGHY,EAAI,EACR,IAAMC,EAAI,EAAGA,EAAID,EAAGC,IACnBJ,EAAMN,EAAGO,CAAG,EACZP,EAAGO,CAAG,EAAIJ,EAAGK,CAAG,EAChBL,EAAGK,CAAG,EAAIF,EACVC,GAAMN,EACNO,GAAMJ,EAGR,GAAKL,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,QAAS,2BAA4B,EAClDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAO,IAKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAQD,EAERC,EAAQC,EAMT,OAAO,QAAUD", + "names": ["require_ndarray", "__commonJSMin", "exports", "module", "M", "dswap", "N", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "tmp", "ix", "iy", "m", "i", "require_dswap", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "dswap", "N", "x", "strideX", "y", "strideY", "ix", "iy", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dswap", "ndarray", "join", "tryRequire", "isError", "main", "dswap", "tmp"] } diff --git a/lib/dswap.js b/lib/dswap.js index 910f209..e83e4d6 100644 --- a/lib/dswap.js +++ b/lib/dswap.js @@ -18,9 +18,10 @@ 'use strict'; -// VARIABLES // +// MODULES // -var M = 3; +var stride2offset = require( '@stdlib/strided-base-stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -46,65 +47,14 @@ var M = 3; * // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] */ function dswap( N, x, strideX, y, strideY ) { - var tmp; var ix; var iy; - var m; - var i; - var j; if ( N <= 0 ) { return y; } - // Use unrolled loops if both strides are equal to `1`... - if ( strideX === 1 && strideY === 1 ) { - m = N % M; - - // If we have a remainder, run a clean-up loop... - if ( m > 0 ) { - for ( i = 0; i < m; i++ ) { - tmp = x[ i ]; - x[ i ] = y[ i ]; - y[ i ] = tmp; - } - } - if ( N < M ) { - return y; - } - for ( i = m; i < N; i += M ) { - tmp = x[ i ]; - x[ i ] = y[ i ]; - y[ i ] = tmp; - - j = i + 1; - tmp = x[ j ]; - x[ j ] = y[ j ]; - y[ j ] = tmp; - - j += 1; - tmp = x[ j ]; - x[ j ] = y[ j ]; - y[ j ] = tmp; - } - return y; - } - if ( strideX < 0 ) { - ix = (1-N) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = (1-N) * strideY; - } else { - iy = 0; - } - for ( i = 0; i < N; i++ ) { - tmp = x[ ix ]; - x[ ix ] = y[ iy ]; - y[ iy ] = tmp; - ix += strideX; - iy += strideY; - } - return y; + ix = stride2offset( N, strideX ); + iy = stride2offset( N, strideY ); + return ndarray( N, x, strideX, ix, y, strideY, iy ); } diff --git a/package.json b/package.json index 2f374e9..5ec46d8 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "@stdlib/napi-argv-int64": "^0.2.1", "@stdlib/napi-argv-strided-float64array": "^0.2.1", "@stdlib/napi-export": "^0.2.1", + "@stdlib/strided-base-stride2offset": "github:stdlib-js/strided-base-stride2offset#main", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-library-manifest": "^0.2.1", "@stdlib/utils-try-require": "^0.2.1"