@stdlib/blas-base-cswap 0.2.1 → 0.4.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 +143 -106
- package/dist/index.js +7 -7
- package/dist/index.js.map +4 -4
- package/docs/types/index.d.ts +12 -84
- package/include/stdlib/blas/base/cswap.h +11 -4
- package/include/stdlib/blas/base/cswap_cblas.h +6 -4
- package/include/stdlib/blas/base/cswap_fortran.h +4 -4
- package/lib/cswap.js +8 -75
- package/lib/cswap.native.js +3 -21
- package/lib/index.js +6 -42
- package/lib/ndarray.js +3 -21
- package/lib/ndarray.native.js +6 -32
- package/manifest.json +289 -9
- package/package.json +15 -14
- package/src/addon.c +23 -3
- package/src/cswap.c +6 -48
- package/src/cswap.f +1 -1
- package/src/cswap_cblas.c +25 -2
- package/src/cswap_f.c +24 -1
- package/src/cswap_ndarray.c +63 -0
- package/include.gypi +0 -70
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/blas-base-cswap",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Interchange two complex single-precision floating-point vectors.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "The Stdlib Authors",
|
|
@@ -34,15 +34,19 @@
|
|
|
34
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@stdlib/assert-is-error": "^0.2.
|
|
38
|
-
"@stdlib/
|
|
39
|
-
"@stdlib/
|
|
40
|
-
"@stdlib/napi-argv
|
|
41
|
-
"@stdlib/napi-
|
|
42
|
-
"@stdlib/
|
|
43
|
-
"@stdlib/
|
|
44
|
-
"@stdlib/
|
|
45
|
-
"@stdlib/
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.2",
|
|
38
|
+
"@stdlib/blas-base-shared": "^0.2.0",
|
|
39
|
+
"@stdlib/complex-float32-ctor": "^0.0.2",
|
|
40
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
41
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
42
|
+
"@stdlib/napi-argv-strided-complex64array": "^0.2.2",
|
|
43
|
+
"@stdlib/napi-export": "^0.3.0",
|
|
44
|
+
"@stdlib/strided-base-min-view-buffer-index": "^0.3.0",
|
|
45
|
+
"@stdlib/strided-base-reinterpret-complex64": "^0.2.1",
|
|
46
|
+
"@stdlib/strided-base-stride2offset": "^0.1.0",
|
|
47
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
48
|
+
"@stdlib/utils-library-manifest": "^0.2.3",
|
|
49
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {},
|
|
48
52
|
"engines": {
|
|
@@ -85,9 +89,6 @@
|
|
|
85
89
|
"single",
|
|
86
90
|
"float32array"
|
|
87
91
|
],
|
|
88
|
-
"__stdlib__": {
|
|
89
|
-
"wasm": false
|
|
90
|
-
},
|
|
91
92
|
"funding": {
|
|
92
93
|
"type": "opencollective",
|
|
93
94
|
"url": "https://opencollective.com/stdlib"
|
package/src/addon.c
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
#include "stdlib/blas/base/cswap.h"
|
|
20
|
+
#include "stdlib/blas/base/shared.h"
|
|
20
21
|
#include "stdlib/napi/export.h"
|
|
21
22
|
#include "stdlib/napi/argv.h"
|
|
22
23
|
#include "stdlib/napi/argv_int64.h"
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
/**
|
|
27
28
|
* Receives JavaScript callback invocation data.
|
|
28
29
|
*
|
|
29
|
-
* @private
|
|
30
30
|
* @param env environment under which the function is invoked
|
|
31
31
|
* @param info callback data
|
|
32
32
|
* @return Node-API value
|
|
@@ -38,8 +38,28 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
|
|
|
38
38
|
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 );
|
|
39
39
|
STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, X, N, strideX, argv, 1 );
|
|
40
40
|
STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, Y, N, strideY, argv, 3 );
|
|
41
|
-
c_cswap( N, (void *)X, strideX, (void *)Y, strideY );
|
|
41
|
+
API_SUFFIX(c_cswap)( N, (void *)X, strideX, (void *)Y, strideY );
|
|
42
42
|
return NULL;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Receives JavaScript callback invocation data.
|
|
47
|
+
*
|
|
48
|
+
* @param env environment under which the function is invoked
|
|
49
|
+
* @param info callback data
|
|
50
|
+
* @return Node-API value
|
|
51
|
+
*/
|
|
52
|
+
static napi_value addon_method( napi_env env, napi_callback_info info ) {
|
|
53
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 7 );
|
|
54
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
55
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
|
|
56
|
+
STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
|
|
57
|
+
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 );
|
|
58
|
+
STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 6 );
|
|
59
|
+
STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, X, N, strideX, argv, 1 );
|
|
60
|
+
STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, Y, N, strideY, argv, 4 );
|
|
61
|
+
API_SUFFIX(c_cswap_ndarray)( N, (void *)X, strideX, offsetX, (void *)Y, strideY, offsetY );
|
|
62
|
+
return NULL;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
|
package/src/cswap.c
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
#include "stdlib/blas/base/cswap.h"
|
|
20
|
+
#include "stdlib/blas/base/shared.h"
|
|
21
|
+
#include "stdlib/strided/base/stride2offset.h"
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Interchanges two complex single-precision floating-point vectors.
|
|
@@ -27,52 +29,8 @@
|
|
|
27
29
|
* @param Y second input array
|
|
28
30
|
* @param strideY Y stride length
|
|
29
31
|
*/
|
|
30
|
-
void c_cswap( const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
int ix;
|
|
35
|
-
int iy;
|
|
36
|
-
int i;
|
|
37
|
-
int j;
|
|
38
|
-
|
|
39
|
-
if ( N <= 0 ) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if ( strideX == 1 && strideY == 1 ) {
|
|
43
|
-
for ( i = 0; i < N*2; i += 2 ) {
|
|
44
|
-
tmp = x[ i ];
|
|
45
|
-
x[ i ] = y[ i ];
|
|
46
|
-
y[ i ] = tmp;
|
|
47
|
-
|
|
48
|
-
j = i + 1;
|
|
49
|
-
tmp = x[ j ];
|
|
50
|
-
x[ j ] = y[ j ];
|
|
51
|
-
y[ j ] = tmp;
|
|
52
|
-
}
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if ( strideX < 0 ) {
|
|
56
|
-
ix = 2 * (1-N) * strideX;
|
|
57
|
-
} else {
|
|
58
|
-
ix = 0;
|
|
59
|
-
}
|
|
60
|
-
if ( strideY < 0 ) {
|
|
61
|
-
iy = 2 * (1-N) * strideY;
|
|
62
|
-
} else {
|
|
63
|
-
iy = 0;
|
|
64
|
-
}
|
|
65
|
-
for ( i = 0; i < N; i++ ) {
|
|
66
|
-
tmp = x[ ix ];
|
|
67
|
-
x[ ix ] = y[ iy ];
|
|
68
|
-
y[ iy ] = tmp;
|
|
69
|
-
|
|
70
|
-
tmp = x[ ix+1 ];
|
|
71
|
-
x[ ix+1 ] = y[ iy+1 ];
|
|
72
|
-
y[ iy+1 ] = tmp;
|
|
73
|
-
|
|
74
|
-
ix += strideX * 2;
|
|
75
|
-
iy += strideY * 2;
|
|
76
|
-
}
|
|
77
|
-
return;
|
|
32
|
+
void API_SUFFIX(c_cswap)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ) {
|
|
33
|
+
CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
|
|
34
|
+
CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY );
|
|
35
|
+
API_SUFFIX(c_cswap_ndarray)( N, X, strideX, ox, Y, strideY, oy );
|
|
78
36
|
}
|
package/src/cswap.f
CHANGED
package/src/cswap_cblas.c
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
|
|
19
19
|
#include "stdlib/blas/base/cswap.h"
|
|
20
20
|
#include "stdlib/blas/base/cswap_cblas.h"
|
|
21
|
+
#include "stdlib/blas/base/shared.h"
|
|
22
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
23
|
+
#include "stdlib/strided/base/min_view_buffer_index.h"
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Interchanges two complex single-precision floating-point vectors.
|
|
@@ -28,6 +31,26 @@
|
|
|
28
31
|
* @param Y second input array
|
|
29
32
|
* @param strideY Y stride length
|
|
30
33
|
*/
|
|
31
|
-
void c_cswap( const
|
|
32
|
-
cblas_cswap( N, X, strideX, Y, strideY );
|
|
34
|
+
void API_SUFFIX(c_cswap)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ) {
|
|
35
|
+
API_SUFFIX(cblas_cswap)( N, X, strideX, Y, strideY );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Interchanges two complex single-precision floating-point vectors using alternative indexing semantics.
|
|
40
|
+
*
|
|
41
|
+
* @param N number of indexed elements
|
|
42
|
+
* @param X first input array
|
|
43
|
+
* @param strideX X stride length
|
|
44
|
+
* @param offsetX starting index for X
|
|
45
|
+
* @param Y second input array
|
|
46
|
+
* @param strideY Y stride length
|
|
47
|
+
* @param offsetY starting index for Y
|
|
48
|
+
*/
|
|
49
|
+
void API_SUFFIX(c_cswap_ndarray)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
|
|
50
|
+
stdlib_complex64_t *x = (stdlib_complex64_t *)X;
|
|
51
|
+
stdlib_complex64_t *y = (stdlib_complex64_t *)Y;
|
|
52
|
+
|
|
53
|
+
x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
|
|
54
|
+
y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
|
|
55
|
+
API_SUFFIX(cblas_cswap)( N, (void *)x, strideX, (void *)y, strideY );
|
|
33
56
|
}
|
package/src/cswap_f.c
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
|
|
19
19
|
#include "stdlib/blas/base/cswap.h"
|
|
20
20
|
#include "stdlib/blas/base/cswap_fortran.h"
|
|
21
|
+
#include "stdlib/blas/base/shared.h"
|
|
22
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
23
|
+
#include "stdlib/strided/base/min_view_buffer_index.h"
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Interchanges two complex single-precision floating-point vectors.
|
|
@@ -28,6 +31,26 @@
|
|
|
28
31
|
* @param Y second input array
|
|
29
32
|
* @param strideY Y stride length
|
|
30
33
|
*/
|
|
31
|
-
void c_cswap( const
|
|
34
|
+
void API_SUFFIX(c_cswap)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ) {
|
|
32
35
|
cswap( &N, X, &strideX, Y, &strideY );
|
|
33
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Interchanges two complex single-precision floating-point vectors using alternative indexing semantics.
|
|
40
|
+
*
|
|
41
|
+
* @param N number of indexed elements
|
|
42
|
+
* @param X first input array
|
|
43
|
+
* @param strideX X stride length
|
|
44
|
+
* @param offsetX starting index for X
|
|
45
|
+
* @param Y second input array
|
|
46
|
+
* @param strideY Y stride length
|
|
47
|
+
* @param offsetY starting index for Y
|
|
48
|
+
*/
|
|
49
|
+
void API_SUFFIX(c_cswap_ndarray)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
|
|
50
|
+
stdlib_complex64_t *x = (stdlib_complex64_t *)X;
|
|
51
|
+
stdlib_complex64_t *y = (stdlib_complex64_t *)Y;
|
|
52
|
+
|
|
53
|
+
x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX );
|
|
54
|
+
y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY );
|
|
55
|
+
cswap( &N, (void *)x, &strideX, (void *)y, &strideY );
|
|
56
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#include "stdlib/blas/base/cswap.h"
|
|
20
|
+
#include "stdlib/blas/base/shared.h"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Interchanges two complex single-precision floating-point vectors.
|
|
24
|
+
*
|
|
25
|
+
* @param N number of indexed elements
|
|
26
|
+
* @param X first input array
|
|
27
|
+
* @param strideX X stride length
|
|
28
|
+
* @param offsetX starting index for X
|
|
29
|
+
* @param Y second input array
|
|
30
|
+
* @param strideY Y stride length
|
|
31
|
+
* @param offsetY starting index for Y
|
|
32
|
+
*/
|
|
33
|
+
void API_SUFFIX(c_cswap_ndarray)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
|
|
34
|
+
float *x = (float *)X;
|
|
35
|
+
float *y = (float *)Y;
|
|
36
|
+
float tmp;
|
|
37
|
+
CBLAS_INT ix;
|
|
38
|
+
CBLAS_INT iy;
|
|
39
|
+
CBLAS_INT sx;
|
|
40
|
+
CBLAS_INT sy;
|
|
41
|
+
CBLAS_INT i;
|
|
42
|
+
|
|
43
|
+
if ( N <= 0 ) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
ix = offsetX * 2;
|
|
47
|
+
iy = offsetY * 2;
|
|
48
|
+
sx = strideX * 2;
|
|
49
|
+
sy = strideY * 2;
|
|
50
|
+
for ( i = 0; i < N; i++ ) {
|
|
51
|
+
tmp = x[ ix ];
|
|
52
|
+
x[ ix ] = y[ iy ];
|
|
53
|
+
y[ iy ] = tmp;
|
|
54
|
+
|
|
55
|
+
tmp = x[ ix+1 ];
|
|
56
|
+
x[ ix+1 ] = y[ iy+1 ];
|
|
57
|
+
y[ iy+1 ] = tmp;
|
|
58
|
+
|
|
59
|
+
ix += sx;
|
|
60
|
+
iy += sy;
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
package/include.gypi
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# @license Apache-2.0
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2020 The Stdlib Authors.
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
# A GYP include file for building a Node.js native add-on.
|
|
18
|
-
#
|
|
19
|
-
# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors.
|
|
20
|
-
#
|
|
21
|
-
# Main documentation:
|
|
22
|
-
#
|
|
23
|
-
# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
|
|
24
|
-
# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
|
|
25
|
-
#
|
|
26
|
-
# Variable nesting hacks:
|
|
27
|
-
#
|
|
28
|
-
# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi
|
|
29
|
-
# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004
|
|
30
|
-
{
|
|
31
|
-
# Define variables to be used throughout the configuration for all targets:
|
|
32
|
-
'variables': {
|
|
33
|
-
'variables': {
|
|
34
|
-
# Host BLAS library (to override -Dblas=<blas>):
|
|
35
|
-
'blas%': '',
|
|
36
|
-
|
|
37
|
-
# Path to BLAS library (to override -Dblas_dir=<path>):
|
|
38
|
-
'blas_dir%': '',
|
|
39
|
-
}, # end variables
|
|
40
|
-
|
|
41
|
-
# Source directory:
|
|
42
|
-
'src_dir': './src',
|
|
43
|
-
|
|
44
|
-
# Include directories:
|
|
45
|
-
'include_dirs': [
|
|
46
|
-
'<@(blas_dir)',
|
|
47
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{\'os\':\'<(OS)\',\'blas\':\'<(blas)\'},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
48
|
-
],
|
|
49
|
-
|
|
50
|
-
# Add-on destination directory:
|
|
51
|
-
'addon_output_dir': './src',
|
|
52
|
-
|
|
53
|
-
# Source files:
|
|
54
|
-
'src_files': [
|
|
55
|
-
'<(src_dir)/addon.c',
|
|
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
|
-
],
|
|
58
|
-
|
|
59
|
-
# Library dependencies:
|
|
60
|
-
'libraries': [
|
|
61
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{\'os\':\'<(OS)\',\'blas\':\'<(blas)\'},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
62
|
-
],
|
|
63
|
-
|
|
64
|
-
# Library directories:
|
|
65
|
-
'library_dirs': [
|
|
66
|
-
'<@(blas_dir)',
|
|
67
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{\'os\':\'<(OS)\',\'blas\':\'<(blas)\'},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
68
|
-
],
|
|
69
|
-
}, # end variables
|
|
70
|
-
}
|