@stdlib/blas-base-cswap 0.0.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +34 -26
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +18 -18
- package/include.gypi +1 -1
- package/lib/cswap.js +4 -4
- package/lib/cswap.native.js +4 -4
- package/lib/ndarray.js +4 -4
- package/lib/ndarray.native.js +10 -10
- package/manifest.json +167 -116
- package/package.json +30 -19
- package/src/addon.c +45 -0
- package/src/cswap.c +1 -1
- package/src/cswap.f +1 -1
- package/src/cswap_cblas.c +1 -1
- package/src/cswap_f.c +1 -1
- package/docs/repl.txt +0 -158
- package/docs/types/test.ts +0 -249
- package/src/addon.cpp +0 -151
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# cswap
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -77,26 +88,23 @@ im = imagf( z );
|
|
|
77
88
|
|
|
78
89
|
The function has the following parameters:
|
|
79
90
|
|
|
80
|
-
- **N**: number of
|
|
81
|
-
- **x**: input [`Complex64Array`][@stdlib/array/complex64].
|
|
91
|
+
- **N**: number of indexed elements.
|
|
92
|
+
- **x**: first input [`Complex64Array`][@stdlib/array/complex64].
|
|
82
93
|
- **strideX**: index increment for `x`.
|
|
83
|
-
- **y**:
|
|
94
|
+
- **y**: second input [`Complex64Array`][@stdlib/array/complex64].
|
|
84
95
|
- **strideY**: index increment for `y`.
|
|
85
96
|
|
|
86
|
-
The `N` and
|
|
97
|
+
The `N` and stride parameters determine how values from `x` are interchanged with values from `y`. For example, to interchange in reverse order every other value in `x` into the first `N` elements of `y`,
|
|
87
98
|
|
|
88
99
|
```javascript
|
|
89
100
|
var Complex64Array = require( '@stdlib/array-complex64' );
|
|
90
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
91
101
|
var realf = require( '@stdlib/complex-realf' );
|
|
92
102
|
var imagf = require( '@stdlib/complex-imagf' );
|
|
93
103
|
|
|
94
104
|
var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
95
105
|
var y = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
cswap( N, x, -2, y, 1 );
|
|
107
|
+
cswap( 2, x, -2, y, 1 );
|
|
100
108
|
|
|
101
109
|
var z = y.get( 0 );
|
|
102
110
|
// returns <Complex64>
|
|
@@ -194,7 +202,7 @@ The function has the following additional parameters:
|
|
|
194
202
|
- **offsetX**: starting index for `x`.
|
|
195
203
|
- **offsetY**: starting index for `y`.
|
|
196
204
|
|
|
197
|
-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying
|
|
205
|
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to interchange every other value in `x` starting from the second value into the last `N` elements in `y` where `x[i] = y[n]`, `x[i+2] = y[n-1]`,...,
|
|
198
206
|
|
|
199
207
|
```javascript
|
|
200
208
|
var Complex64Array = require( '@stdlib/array-complex64' );
|
|
@@ -248,24 +256,21 @@ im = imagf( z );
|
|
|
248
256
|
|
|
249
257
|
```javascript
|
|
250
258
|
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
|
|
251
|
-
var
|
|
259
|
+
var filledarrayBy = require( '@stdlib/array-filled-by' );
|
|
260
|
+
var Complex64 = require( '@stdlib/complex-float32' );
|
|
252
261
|
var cswap = require( '@stdlib/blas-base-cswap' );
|
|
253
262
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
var x = new Complex64Array( 10 );
|
|
258
|
-
var y = new Complex64Array( 10 );
|
|
259
|
-
|
|
260
|
-
var i;
|
|
261
|
-
for ( i = 0; i < x.length; i++ ) {
|
|
262
|
-
x.set( [ re(), im() ], i );
|
|
263
|
-
y.set( [ re(), im() ], i );
|
|
263
|
+
function rand() {
|
|
264
|
+
return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
|
|
264
265
|
}
|
|
266
|
+
|
|
267
|
+
var x = filledarrayBy( 10, 'complex64', rand );
|
|
265
268
|
console.log( x.get( 0 ).toString() );
|
|
269
|
+
|
|
270
|
+
var y = filledarrayBy( 10, 'complex64', rand );
|
|
266
271
|
console.log( y.get( 0 ).toString() );
|
|
267
272
|
|
|
268
|
-
// Swap elements in `x`
|
|
273
|
+
// Swap elements in `x` into `y` starting from the end of `y`:
|
|
269
274
|
cswap( x.length, x, 1, y, -1 );
|
|
270
275
|
console.log( x.get( x.length-1 ).toString() );
|
|
271
276
|
console.log( y.get( y.length-1 ).toString() );
|
|
@@ -283,7 +288,7 @@ console.log( y.get( y.length-1 ).toString() );
|
|
|
283
288
|
|
|
284
289
|
## See Also
|
|
285
290
|
|
|
286
|
-
- <span class="package-name">[`@stdlib/blas
|
|
291
|
+
- <span class="package-name">[`@stdlib/blas-base/ccopy`][@stdlib/blas/base/ccopy]</span><span class="delimiter">: </span><span class="description">copy values from one complex single-precision floating-point vector to another complex single-precision floating-point vector.</span>
|
|
287
292
|
|
|
288
293
|
</section>
|
|
289
294
|
|
|
@@ -315,7 +320,7 @@ See [LICENSE][stdlib-license].
|
|
|
315
320
|
|
|
316
321
|
## Copyright
|
|
317
322
|
|
|
318
|
-
Copyright © 2016-
|
|
323
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
319
324
|
|
|
320
325
|
</section>
|
|
321
326
|
|
|
@@ -328,8 +333,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
328
333
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-base-cswap.svg
|
|
329
334
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-base-cswap
|
|
330
335
|
|
|
331
|
-
[test-image]: https://github.com/stdlib-js/blas-base-cswap/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
332
|
-
[test-url]: https://github.com/stdlib-js/blas-base-cswap/actions/workflows/test.yml?query=branch:v0.0
|
|
336
|
+
[test-image]: https://github.com/stdlib-js/blas-base-cswap/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
337
|
+
[test-url]: https://github.com/stdlib-js/blas-base-cswap/actions/workflows/test.yml?query=branch:v0.2.0
|
|
333
338
|
|
|
334
339
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-base-cswap/main.svg
|
|
335
340
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-base-cswap?branch=main
|
|
@@ -342,7 +347,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
342
347
|
-->
|
|
343
348
|
|
|
344
349
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
345
|
-
[chat-url]: https://gitter.im
|
|
350
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
346
351
|
|
|
347
352
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
348
353
|
|
|
@@ -352,8 +357,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
352
357
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
353
358
|
|
|
354
359
|
[deno-url]: https://github.com/stdlib-js/blas-base-cswap/tree/deno
|
|
360
|
+
[deno-readme]: https://github.com/stdlib-js/blas-base-cswap/blob/deno/README.md
|
|
355
361
|
[umd-url]: https://github.com/stdlib-js/blas-base-cswap/tree/umd
|
|
362
|
+
[umd-readme]: https://github.com/stdlib-js/blas-base-cswap/blob/umd/README.md
|
|
356
363
|
[esm-url]: https://github.com/stdlib-js/blas-base-cswap/tree/esm
|
|
364
|
+
[esm-readme]: https://github.com/stdlib-js/blas-base-cswap/blob/esm/README.md
|
|
357
365
|
[branches-url]: https://github.com/stdlib-js/blas-base-cswap/blob/main/branches.md
|
|
358
366
|
|
|
359
367
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/blas-base-cswap/main/LICENSE
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";var x=function(t,n){return function(){return n||t((n={exports:{}}).exports,n),n.exports}};var y=x(function(I,l){
|
|
2
|
+
var j=require('@stdlib/strided-base-reinterpret-complex64/dist');function k(t,n,c,q,p){var i,v,e,o,f,u,s,r,a;if(t<=0)return q;if(i=j(n,0),v=j(q,0),c===1&&p===1){for(r=0;r<t*2;r+=2)e=i[r],i[r]=v[r],v[r]=e,a=r+1,e=i[a],i[a]=v[a],v[a]=e;return q}for(c<0?u=2*(1-t)*c:u=0,p<0?s=2*(1-t)*p:s=0,o=c*2,f=p*2,r=0;r<t;r++)e=i[u],i[u]=v[s],v[s]=e,e=i[u+1],i[u+1]=v[s+1],v[s+1]=e,u+=o,s+=f;return q}l.exports=k
|
|
3
|
+
});var E=x(function(J,_){
|
|
4
|
+
var R=require('@stdlib/strided-base-reinterpret-complex64/dist');function z(t,n,c,q,p,i,v){var e,o,f,u,s,r,a,w;if(t<=0)return p;for(e=R(n,0),o=R(p,0),u=c*2,s=i*2,r=q*2,a=v*2,w=0;w<t;w++)f=e[r],e[r]=o[a],o[a]=f,f=e[r+1],e[r+1]=o[a+1],o[a+1]=f,r+=u,a+=s;return p}_.exports=z
|
|
5
|
+
});var g=x(function(K,b){
|
|
6
|
+
var A=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),O=y(),B=E();A(O,"ndarray",B);b.exports=O
|
|
7
|
+
});var C=require("path").join,D=require('@stdlib/utils-try-require/dist'),F=require('@stdlib/assert-is-error/dist'),G=g(),m,h=D(C(__dirname,"./native.js"));F(h)?m=G:m=h;module.exports=m;
|
|
8
|
+
/** @license Apache-2.0 */
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/cswap.js", "../lib/ndarray.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\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 reinterpret = require( '@stdlib/strided-base-reinterpret-complex64' );\n\n\n// MAIN //\n\n/**\n* Interchanges two complex single-precision floating-point vectors.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Complex64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {Complex64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @returns {Complex64Array} `y`\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n*\n* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* cswap( x.length, x, 1, y, 1 );\n*\n* var z = y.get( 0 );\n* // returns <Complex64>\n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*\n* z = x.get( 0 );\n* // returns <Complex64>\n*\n* re = realf( z );\n* // returns 7.0\n*\n* im = imagf( z );\n* // returns 8.0\n*/\nfunction cswap( N, x, strideX, y, strideY ) {\n\tvar viewX;\n\tvar viewY;\n\tvar tmp;\n\tvar sx;\n\tvar sy;\n\tvar ix;\n\tvar iy;\n\tvar i;\n\tvar j;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tviewX = reinterpret( x, 0 );\n\tviewY = reinterpret( y, 0 );\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tfor ( i = 0; i < N*2; i += 2 ) {\n\t\t\ttmp = viewX[ i ];\n\t\t\tviewX[ i ] = viewY[ i ];\n\t\t\tviewY[ i ] = tmp;\n\n\t\t\tj = i + 1;\n\t\t\ttmp = viewX[ j ];\n\t\t\tviewX[ j ] = viewY[ j ];\n\t\t\tviewY[ j ] = tmp;\n\t\t}\n\t\treturn y;\n\t}\n\tif ( strideX < 0 ) {\n\t\tix = 2 * (1-N) * strideX;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( strideY < 0 ) {\n\t\tiy = 2 * (1-N) * strideY;\n\t} else {\n\t\tiy = 0;\n\t}\n\tsx = strideX * 2;\n\tsy = strideY * 2;\n\tfor ( i = 0; i < N; i++ ) {\n\t\ttmp = viewX[ ix ];\n\t\tviewX[ ix ] = viewY[ iy ];\n\t\tviewY[ iy ] = tmp;\n\n\t\ttmp = viewX[ ix+1 ];\n\t\tviewX[ ix+1 ] = viewY[ iy+1 ];\n\t\tviewY[ iy+1 ] = tmp;\n\n\t\tix += sx;\n\t\tiy += sy;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cswap;\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 reinterpret = require( '@stdlib/strided-base-reinterpret-complex64' );\n\n\n// MAIN //\n\n/**\n* Interchanges two complex single-precision floating-point vectors.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Complex64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Complex64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {Complex64Array} `y`\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n*\n* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* cswap( x.length, x, 1, 0, y, 1, 0 );\n*\n* var z = y.get( 0 );\n* // returns <Complex64>\n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*\n* z = x.get( 0 );\n* // returns <Complex64>\n*\n* re = realf( z );\n* // returns 7.0\n*\n* im = imagf( z );\n* // returns 8.0\n*/\nfunction cswap( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar viewX;\n\tvar viewY;\n\tvar tmp;\n\tvar sx;\n\tvar sy;\n\tvar ix;\n\tvar iy;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tviewX = reinterpret( x, 0 );\n\tviewY = reinterpret( y, 0 );\n\tsx = strideX * 2;\n\tsy = strideY * 2;\n\tix = offsetX * 2;\n\tiy = offsetY * 2;\n\tfor ( i = 0; i < N; i++ ) {\n\t\ttmp = viewX[ ix ];\n\t\tviewX[ ix ] = viewY[ iy ];\n\t\tviewY[ iy ] = tmp;\n\n\t\ttmp = viewX[ ix+1 ];\n\t\tviewX[ ix+1 ] = viewY[ iy+1 ];\n\t\tviewY[ iy+1 ] = tmp;\n\n\t\tix += sx;\n\t\tiy += sy;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cswap;\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 cswap = require( './cswap.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( cswap, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = cswap;\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 complex single-precision floating-point vectors.\n*\n* @module @stdlib/blas-base-cswap\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var cswap = require( '@stdlib/blas-base-cswap' );\n*\n* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* cswap( x.length, x, 1, y, 1 );\n*\n* var z = y.get( 0 );\n* // returns <Complex64>\n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*\n* z = x.get( 0 );\n* // returns <Complex64>\n*\n* re = realf( z );\n* // returns 7.0\n*\n* im = imagf( z );\n* // returns 8.0\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var cswap = require( '@stdlib/blas-base-cswap' );\n*\n* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* cswap.ndarray( x.length, x, 1, 0, y, 1, 0 );\n*\n* var z = y.get( 0 );\n* // returns <Complex64>\n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*\n* z = x.get( 0 );\n* // returns <Complex64>\n*\n* re = realf( z );\n* // returns 7.0\n*\n* im = imagf( z );\n* // returns 8.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 cswap;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tcswap = main;\n} else {\n\tcswap = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cswap;\n\n// exports: { \"ndarray\": \"cswap.ndarray\" }\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,4CAA6C,EA2CxE,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAAGC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKb,GAAK,EACT,OAAOG,EAIR,GAFAE,EAAQP,EAAaG,EAAG,CAAE,EAC1BK,EAAQR,EAAaK,EAAG,CAAE,EACrBD,IAAY,GAAKE,IAAY,EAAI,CACrC,IAAMQ,EAAI,EAAGA,EAAIZ,EAAE,EAAGY,GAAK,EAC1BL,EAAMF,EAAOO,CAAE,EACfP,EAAOO,CAAE,EAAIN,EAAOM,CAAE,EACtBN,EAAOM,CAAE,EAAIL,EAEbM,EAAID,EAAI,EACRL,EAAMF,EAAOQ,CAAE,EACfR,EAAOQ,CAAE,EAAIP,EAAOO,CAAE,EACtBP,EAAOO,CAAE,EAAIN,EAEd,OAAOJ,CACR,CAaA,IAZKD,EAAU,EACdQ,EAAK,GAAK,EAAEV,GAAKE,EAEjBQ,EAAK,EAEDN,EAAU,EACdO,EAAK,GAAK,EAAEX,GAAKI,EAEjBO,EAAK,EAENH,EAAKN,EAAU,EACfO,EAAKL,EAAU,EACTQ,EAAI,EAAGA,EAAIZ,EAAGY,IACnBL,EAAMF,EAAOK,CAAG,EAChBL,EAAOK,CAAG,EAAIJ,EAAOK,CAAG,EACxBL,EAAOK,CAAG,EAAIJ,EAEdA,EAAMF,EAAOK,EAAG,CAAE,EAClBL,EAAOK,EAAG,CAAE,EAAIJ,EAAOK,EAAG,CAAE,EAC5BL,EAAOK,EAAG,CAAE,EAAIJ,EAEhBG,GAAMF,EACNG,GAAMF,EAEP,OAAON,CACR,CAKAN,EAAO,QAAUE,IC5HjB,IAAAe,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,4CAA6C,EA6CxE,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAAU,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKd,GAAK,EACT,OAAOI,EAQR,IANAG,EAAQT,EAAaG,EAAG,CAAE,EAC1BO,EAAQV,EAAaM,EAAG,CAAE,EAC1BM,EAAKR,EAAU,EACfS,EAAKN,EAAU,EACfO,EAAKT,EAAU,EACfU,EAAKP,EAAU,EACTQ,EAAI,EAAGA,EAAId,EAAGc,IACnBL,EAAMF,EAAOK,CAAG,EAChBL,EAAOK,CAAG,EAAIJ,EAAOK,CAAG,EACxBL,EAAOK,CAAG,EAAIJ,EAEdA,EAAMF,EAAOK,EAAG,CAAE,EAClBL,EAAOK,EAAG,CAAE,EAAIJ,EAAOK,EAAG,CAAE,EAC5BL,EAAOK,EAAG,CAAE,EAAIJ,EAEhBG,GAAMF,EACNG,GAAMF,EAEP,OAAOP,CACR,CAKAP,EAAO,QAAUE,ICxGjB,IAAAgB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAQ,IACRC,EAAU,IAKdF,EAAaC,EAAO,UAAWC,CAAQ,EAKvCH,EAAO,QAAUE,ICoDjB,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",
|
|
6
|
+
"names": ["require_cswap", "__commonJSMin", "exports", "module", "reinterpret", "cswap", "N", "x", "strideX", "y", "strideY", "viewX", "viewY", "tmp", "sx", "sy", "ix", "iy", "i", "j", "require_ndarray", "__commonJSMin", "exports", "module", "reinterpret", "cswap", "N", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "viewX", "viewY", "tmp", "sx", "sy", "ix", "iy", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "cswap", "ndarray", "join", "tryRequire", "isError", "main", "cswap", "tmp"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
@@ -29,7 +29,7 @@ interface Routine {
|
|
|
29
29
|
/**
|
|
30
30
|
* Interchanges two complex single-precision floating-point vectors.
|
|
31
31
|
*
|
|
32
|
-
* @param N - number of
|
|
32
|
+
* @param N - number of indexed elements
|
|
33
33
|
* @param x - first input array
|
|
34
34
|
* @param strideX - `x` stride length
|
|
35
35
|
* @param y - second input array
|
|
@@ -37,9 +37,9 @@ interface Routine {
|
|
|
37
37
|
* @returns `y`
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
|
-
* var Complex64Array = require(
|
|
41
|
-
* var realf = require(
|
|
42
|
-
* var imagf = require(
|
|
40
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
41
|
+
* var realf = require( '@stdlib/complex-realf' );
|
|
42
|
+
* var imagf = require( '@stdlib/complex-imagf' );
|
|
43
43
|
*
|
|
44
44
|
* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
|
|
45
45
|
* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
|
|
@@ -64,12 +64,12 @@ interface Routine {
|
|
|
64
64
|
* im = imagf( z );
|
|
65
65
|
* // returns 8.0
|
|
66
66
|
*/
|
|
67
|
-
( N: number, x: Complex64Array, strideX: number, y: Complex64Array, strideY: number ): Complex64Array;
|
|
67
|
+
( N: number, x: Complex64Array, strideX: number, y: Complex64Array, strideY: number ): Complex64Array;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Interchanges two complex single-precision floating-point vectors using alternative indexing semantics.
|
|
71
71
|
*
|
|
72
|
-
* @param N - number of
|
|
72
|
+
* @param N - number of indexed elements
|
|
73
73
|
* @param x - first input array
|
|
74
74
|
* @param strideX - `x` stride length
|
|
75
75
|
* @param offsetX - starting index for `x`
|
|
@@ -79,9 +79,9 @@ interface Routine {
|
|
|
79
79
|
* @returns `y`
|
|
80
80
|
*
|
|
81
81
|
* @example
|
|
82
|
-
* var Complex64Array = require(
|
|
83
|
-
* var realf = require(
|
|
84
|
-
* var imagf = require(
|
|
82
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
83
|
+
* var realf = require( '@stdlib/complex-realf' );
|
|
84
|
+
* var imagf = require( '@stdlib/complex-imagf' );
|
|
85
85
|
*
|
|
86
86
|
* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
|
|
87
87
|
* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
|
|
@@ -106,13 +106,13 @@ interface Routine {
|
|
|
106
106
|
* im = imagf( z );
|
|
107
107
|
* // returns 8.0
|
|
108
108
|
*/
|
|
109
|
-
ndarray( N: number, x: Complex64Array, strideX: number, offsetX: number, y: Complex64Array, strideY: number, offsetY: number ): Complex64Array;
|
|
109
|
+
ndarray( N: number, x: Complex64Array, strideX: number, offsetX: number, y: Complex64Array, strideY: number, offsetY: number ): Complex64Array;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Interchanges two complex single-precision floating-point vectors.
|
|
114
114
|
*
|
|
115
|
-
* @param N - number of
|
|
115
|
+
* @param N - number of indexed elements
|
|
116
116
|
* @param x - first input array
|
|
117
117
|
* @param strideX - `x` stride length
|
|
118
118
|
* @param y - second input array
|
|
@@ -120,9 +120,9 @@ interface Routine {
|
|
|
120
120
|
* @returns `y`
|
|
121
121
|
*
|
|
122
122
|
* @example
|
|
123
|
-
* var Complex64Array = require(
|
|
124
|
-
* var realf = require(
|
|
125
|
-
* var imagf = require(
|
|
123
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
124
|
+
* var realf = require( '@stdlib/complex-realf' );
|
|
125
|
+
* var imagf = require( '@stdlib/complex-imagf' );
|
|
126
126
|
*
|
|
127
127
|
* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
|
|
128
128
|
* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
|
|
@@ -148,9 +148,9 @@ interface Routine {
|
|
|
148
148
|
* // returns 8.0
|
|
149
149
|
*
|
|
150
150
|
* @example
|
|
151
|
-
* var Complex64Array = require(
|
|
152
|
-
* var realf = require(
|
|
153
|
-
* var imagf = require(
|
|
151
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
152
|
+
* var realf = require( '@stdlib/complex-realf' );
|
|
153
|
+
* var imagf = require( '@stdlib/complex-imagf' );
|
|
154
154
|
*
|
|
155
155
|
* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
|
|
156
156
|
* var y = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
|
package/include.gypi
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
|
|
53
53
|
# Source files:
|
|
54
54
|
'src_files': [
|
|
55
|
-
'<(src_dir)/addon.
|
|
55
|
+
'<(src_dir)/addon.c',
|
|
56
56
|
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{\'os\':\'<(OS)\',\'blas\':\'<(blas)\'},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
57
57
|
],
|
|
58
58
|
|
package/lib/cswap.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var reinterpret = require( '@stdlib/strided-base-reinterpret-complex64' );
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
// MAIN //
|
|
@@ -28,7 +28,7 @@ var Float32Array = require( '@stdlib/array-float32' );
|
|
|
28
28
|
/**
|
|
29
29
|
* Interchanges two complex single-precision floating-point vectors.
|
|
30
30
|
*
|
|
31
|
-
* @param {PositiveInteger} N - number of
|
|
31
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
32
32
|
* @param {Complex64Array} x - first input array
|
|
33
33
|
* @param {integer} strideX - `x` stride length
|
|
34
34
|
* @param {Complex64Array} y - second input array
|
|
@@ -77,8 +77,8 @@ function cswap( N, x, strideX, y, strideY ) {
|
|
|
77
77
|
if ( N <= 0 ) {
|
|
78
78
|
return y;
|
|
79
79
|
}
|
|
80
|
-
viewX =
|
|
81
|
-
viewY =
|
|
80
|
+
viewX = reinterpret( x, 0 );
|
|
81
|
+
viewY = reinterpret( y, 0 );
|
|
82
82
|
if ( strideX === 1 && strideY === 1 ) {
|
|
83
83
|
for ( i = 0; i < N*2; i += 2 ) {
|
|
84
84
|
tmp = viewX[ i ];
|
package/lib/cswap.native.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var reinterpret = require( '@stdlib/strided-base-reinterpret-complex64' );
|
|
24
24
|
var addon = require( './../src/addon.node' );
|
|
25
25
|
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ var addon = require( './../src/addon.node' );
|
|
|
29
29
|
/**
|
|
30
30
|
* Interchanges two complex single-precision floating-point vectors.
|
|
31
31
|
*
|
|
32
|
-
* @param {PositiveInteger} N - number of
|
|
32
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
33
33
|
* @param {Complex64Array} x - first input array
|
|
34
34
|
* @param {integer} strideX - `x` stride length
|
|
35
35
|
* @param {Complex64Array} y - second input array
|
|
@@ -65,8 +65,8 @@ var addon = require( './../src/addon.node' );
|
|
|
65
65
|
* // returns 8.0
|
|
66
66
|
*/
|
|
67
67
|
function cswap( N, x, strideX, y, strideY ) {
|
|
68
|
-
var viewX =
|
|
69
|
-
var viewY =
|
|
68
|
+
var viewX = reinterpret( x, 0 );
|
|
69
|
+
var viewY = reinterpret( y, 0 );
|
|
70
70
|
addon( N, viewX, strideX, viewY, strideY );
|
|
71
71
|
return y;
|
|
72
72
|
}
|
package/lib/ndarray.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var reinterpret = require( '@stdlib/strided-base-reinterpret-complex64' );
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
// MAIN //
|
|
@@ -28,7 +28,7 @@ var Float32Array = require( '@stdlib/array-float32' );
|
|
|
28
28
|
/**
|
|
29
29
|
* Interchanges two complex single-precision floating-point vectors.
|
|
30
30
|
*
|
|
31
|
-
* @param {PositiveInteger} N - number of
|
|
31
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
32
32
|
* @param {Complex64Array} x - first input array
|
|
33
33
|
* @param {integer} strideX - `x` stride length
|
|
34
34
|
* @param {NonNegativeInteger} offsetX - starting `x` index
|
|
@@ -78,8 +78,8 @@ function cswap( N, x, strideX, offsetX, y, strideY, offsetY ) {
|
|
|
78
78
|
if ( N <= 0 ) {
|
|
79
79
|
return y;
|
|
80
80
|
}
|
|
81
|
-
viewX =
|
|
82
|
-
viewY =
|
|
81
|
+
viewX = reinterpret( x, 0 );
|
|
82
|
+
viewY = reinterpret( y, 0 );
|
|
83
83
|
sx = strideX * 2;
|
|
84
84
|
sy = strideY * 2;
|
|
85
85
|
ix = offsetX * 2;
|
package/lib/ndarray.native.js
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var reinterpret = require( '@stdlib/strided-base-reinterpret-complex64' );
|
|
24
|
+
var minViewBufferIndex = require( '@stdlib/strided-base-min-view-buffer-index' );
|
|
24
25
|
var addon = require( './../src/addon.node' );
|
|
25
26
|
|
|
26
27
|
|
|
@@ -29,7 +30,7 @@ var addon = require( './../src/addon.node' );
|
|
|
29
30
|
/**
|
|
30
31
|
* Interchanges two complex single-precision floating-point vectors.
|
|
31
32
|
*
|
|
32
|
-
* @param {PositiveInteger} N - number of
|
|
33
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
33
34
|
* @param {Complex64Array} x - first input array
|
|
34
35
|
* @param {integer} strideX - `x` stride length
|
|
35
36
|
* @param {NonNegativeInteger} offsetX - starting `x` index
|
|
@@ -69,14 +70,13 @@ var addon = require( './../src/addon.node' );
|
|
|
69
70
|
function cswap( N, x, strideX, offsetX, y, strideY, offsetY ) {
|
|
70
71
|
var viewX;
|
|
71
72
|
var viewY;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
viewY = new Float32Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), 2*(y.length-offsetY) ); // eslint-disable-line max-len
|
|
73
|
+
|
|
74
|
+
offsetX = minViewBufferIndex( N, strideX, offsetX );
|
|
75
|
+
offsetY = minViewBufferIndex( N, strideY, offsetY );
|
|
76
|
+
|
|
77
|
+
viewX = reinterpret( x, offsetX );
|
|
78
|
+
viewY = reinterpret( y, offsetY );
|
|
79
|
+
|
|
80
80
|
addon( N, viewX, strideX, viewY, strideY );
|
|
81
81
|
return y;
|
|
82
82
|
}
|