diff --git a/blas/ext/base/srev/coverage.ndjson b/blas/ext/base/srev/coverage.ndjson new file mode 100644 index 000000000..ad45abebc --- /dev/null +++ b/blas/ext/base/srev/coverage.ndjson @@ -0,0 +1 @@ +[479,479,100,40,40,100,4,4,100,479,479,100,"7c23a540fa9286c4ff1d7ec8411d56fc977fba82","2024-03-05 03:42:33 -0800"] diff --git a/blas/ext/base/srev/index.html b/blas/ext/base/srev/index.html new file mode 100644 index 000000000..d04d69788 --- /dev/null +++ b/blas/ext/base/srev/index.html @@ -0,0 +1,206 @@ + + + + +
++ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
index.js | +
+
+ |
+ 100% | +68/68 | +100% | +3/3 | +100% | +0/0 | +100% | +68/68 | +
main.js | +
+
+ |
+ 100% | +35/35 | +100% | +1/1 | +100% | +0/0 | +100% | +35/35 | +
native.js | +
+
+ |
+ 100% | +35/35 | +100% | +1/1 | +100% | +0/0 | +100% | +35/35 | +
ndarray.js | +
+
+ |
+ 100% | +114/114 | +100% | +14/14 | +100% | +1/1 | +100% | +114/114 | +
ndarray.native.js | +
+
+ |
+ 100% | +60/60 | +100% | +2/2 | +100% | +1/1 | +100% | +60/60 | +
srev.js | +
+
+ |
+ 100% | +115/115 | +100% | +17/17 | +100% | +1/1 | +100% | +115/115 | +
srev.native.js | +
+
+ |
+ 100% | +52/52 | +100% | +2/2 | +100% | +1/1 | +100% | +52/52 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 | 3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +1x +3x +2x +2x +3x +3x +3x +3x +3x +3x +3x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2020 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'; + +/** +* Reverse a single-precision floating-point strided array in-place. +* +* @module @stdlib/blas/ext/base/srev +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var srev = require( '@stdlib/blas/ext/base/srev' ); +* +* var x = new Float32Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* srev( x.length, x, 1 ); +* // x => <Float32Array>[ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var srev = require( '@stdlib/blas/ext/base/srev' ); +* +* var x = new Float32Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* srev( x.length, x, 1, 0 ); +* // x => <Float32Array>[ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var srev; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + srev = main; +} else { + srev = tmp; +} + + +// EXPORTS // + +module.exports = srev; + +// exports: { "ndarray": "srev.ndarray" } + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var srev = require( './srev.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( srev, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = srev; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var srev = require( './srev.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( srev, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = srev; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 | 2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +15x +15x +15x +15x +15x +15x +15x +15x +15x +2x +2x +13x +13x +13x +13x +15x +7x +7x +7x +7x +7x +6x +9x +9x +9x +9x +9x +9x +6x +7x +3x +3x +7x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +4x +4x +6x +15x +9x +9x +9x +9x +9x +9x +6x +15x +2x +2x +2x +2x +2x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 floor = require( '@stdlib/math/base/special/floor' ); + + +// VARIABLES // + +var M = 3; + + +// MAIN // + +/** +* Reverses a single-precision floating-point strided array in-place. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Float32Array} x - input array +* @param {integer} stride - index increment +* @param {NonNegativeInteger} offset - starting index +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); +* +* srev( 3, x, 1, x.length-3 ); +* // x => <Float32Array>[ 1.0, -2.0, 3.0, -6.0, 5.0, -4.0 ] +*/ +function srev( N, x, stride, offset ) { + var tmp; + var ix; + var iy; + var m; + var n; + var i; + + if ( N <= 0 ) { + return x; + } + n = floor( N/2 ); + ix = offset; + + // Use loop unrolling if the stride is equal to `1`... + if ( stride === 1 ) { + m = n % M; + iy = ix + N - 1; + + // If we have a remainder, run a clean-up loop... + if ( m > 0 ) { + for ( i = 0; i < m; i++ ) { + tmp = x[ ix ]; + x[ ix ] = x[ iy ]; + x[ iy ] = tmp; + ix += stride; + iy -= stride; + } + } + if ( n < M ) { + return x; + } + for ( i = m; i < n; i += M ) { + tmp = x[ ix ]; + x[ ix ] = x[ iy ]; + x[ iy ] = tmp; + + tmp = x[ ix+1 ]; + x[ ix+1 ] = x[ iy-1 ]; + x[ iy-1 ] = tmp; + + tmp = x[ ix+2 ]; + x[ ix+2 ] = x[ iy-2 ]; + x[ iy-2 ] = tmp; + + ix += M; + iy -= M; + } + return x; + } + iy = ix + ((N-1)*stride); + for ( i = 0; i < n; i++ ) { + tmp = x[ ix ]; + x[ ix ] = x[ iy ]; + x[ iy ] = tmp; + ix += stride; + iy -= stride; + } + return x; +} + + +// EXPORTS // + +module.exports = srev; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 | 2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +15x +15x +15x +15x +15x +15x +15x +15x +15x +2x +2x +2x +2x +2x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); +var addon = require( './srev.native.js' ); + + +// MAIN // + +/** +* Reverses a single-precision floating-point strided array in-place. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Float32Array} x - input array +* @param {integer} stride - index increment +* @param {NonNegativeInteger} offset - starting index +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); +* +* srev( 3, x, 1, x.length-3 ); +* // x => <Float32Array>[ 1.0, -2.0, 3.0, -6.0, 5.0, -4.0 ] +*/ +function srev( N, x, stride, offset ) { + var view; + + offset = minViewBufferIndex( N, stride, offset ); + view = offsetView( x, offset ); + + addon( N, view, stride ); + return x; +} + + +// EXPORTS // + +module.exports = srev; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 | 2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +14x +14x +14x +14x +14x +14x +14x +14x +14x +2x +2x +12x +12x +12x +14x +7x +7x +7x +7x +7x +6x +9x +9x +9x +9x +9x +6x +7x +3x +3x +7x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +73x +4x +4x +14x +2x +14x +3x +3x +5x +14x +7x +7x +7x +7x +7x +7x +5x +14x +2x +2x +2x +2x +2x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 floor = require( '@stdlib/math/base/special/floor' ); + + +// VARIABLES // + +var M = 3; + + +// MAIN // + +/** +* Reverses a single-precision floating-point strided array in-place. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Float32Array} x - input array +* @param {integer} stride - index increment +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* srev( x.length, x, 1 ); +* // x => <Float32Array>[ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ] +*/ +function srev( N, x, stride ) { + var tmp; + var ix; + var iy; + var m; + var n; + var i; + + if ( N <= 0 ) { + return x; + } + n = floor( N/2 ); + + // Use loop unrolling if the stride is equal to `1`... + if ( stride === 1 ) { + m = n % M; + iy = N - 1; + + // If we have a remainder, run a clean-up loop... + if ( m > 0 ) { + for ( ix = 0; ix < m; ix++ ) { + tmp = x[ ix ]; + x[ ix ] = x[ iy ]; + x[ iy ] = tmp; + iy -= 1; + } + } + if ( n < M ) { + return x; + } + for ( ix = m; ix < n; ix += M ) { + tmp = x[ ix ]; + x[ ix ] = x[ iy ]; + x[ iy ] = tmp; + + tmp = x[ ix+1 ]; + x[ ix+1 ] = x[ iy-1 ]; + x[ iy-1 ] = tmp; + + tmp = x[ ix+2 ]; + x[ ix+2 ] = x[ iy-2 ]; + x[ iy-2 ] = tmp; + + iy -= M; + } + return x; + } + if ( stride < 0 ) { + ix = (1-N) * stride; + } else { + ix = 0; + } + iy = ix + ((N-1)*stride); + for ( i = 0; i < n; i++ ) { + tmp = x[ ix ]; + x[ ix ] = x[ iy ]; + x[ iy ] = tmp; + ix += stride; + iy -= stride; + } + return x; +} + + +// EXPORTS // + +module.exports = srev; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 | 3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +29x +29x +29x +29x +3x +3x +3x +3x +3x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Reverses a single-precision floating-point strided array in-place. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Float32Array} x - input array +* @param {integer} stride - index increment +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* srev( x.length, x, 1 ); +* // x => <Float32Array>[ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ] +*/ +function srev( N, x, stride ) { + addon( N, x, stride ); + return x; +} + + +// EXPORTS // + +module.exports = srev; + |