@stdlib/blas-ext-base-cfill 0.1.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/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +402 -0
- 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 +112 -0
- package/include/stdlib/blas/ext/base/cfill.h +46 -0
- package/lib/cfill.js +56 -0
- package/lib/cfill.native.js +58 -0
- package/lib/index.js +62 -0
- package/lib/main.js +35 -0
- package/lib/native.js +35 -0
- package/lib/ndarray.js +126 -0
- package/lib/ndarray.native.js +59 -0
- package/manifest.json +82 -0
- package/package.json +93 -0
- package/src/addon.c +64 -0
- package/src/main.c +90 -0
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/blas-ext-base-cfill",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fill a single-precision complex floating-point strided array with a specified scalar constant.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"main": "./lib",
|
|
17
|
+
"browser": "./lib/main.js",
|
|
18
|
+
"gypfile": false,
|
|
19
|
+
"directories": {
|
|
20
|
+
"doc": "./docs",
|
|
21
|
+
"include": "./include",
|
|
22
|
+
"lib": "./lib",
|
|
23
|
+
"src": "./src",
|
|
24
|
+
"dist": "./dist"
|
|
25
|
+
},
|
|
26
|
+
"types": "./docs/types",
|
|
27
|
+
"scripts": {},
|
|
28
|
+
"homepage": "https://stdlib.io",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git://github.com/stdlib-js/blas-ext-base-cfill.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
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/complex-float32-imag": "^0.1.1",
|
|
41
|
+
"@stdlib/complex-float32-real": "^0.1.1",
|
|
42
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
43
|
+
"@stdlib/napi-argv-complex64": "^0.0.2",
|
|
44
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
45
|
+
"@stdlib/napi-argv-strided-complex64array": "^0.2.2",
|
|
46
|
+
"@stdlib/napi-export": "^0.3.0",
|
|
47
|
+
"@stdlib/strided-base-reinterpret-complex64": "^0.2.1",
|
|
48
|
+
"@stdlib/strided-base-stride2offset": "^0.1.0",
|
|
49
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
50
|
+
"@stdlib/utils-library-manifest": "^0.2.3",
|
|
51
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=0.10.0",
|
|
56
|
+
"npm": ">2.7.0"
|
|
57
|
+
},
|
|
58
|
+
"os": [
|
|
59
|
+
"aix",
|
|
60
|
+
"darwin",
|
|
61
|
+
"freebsd",
|
|
62
|
+
"linux",
|
|
63
|
+
"macos",
|
|
64
|
+
"openbsd",
|
|
65
|
+
"sunos",
|
|
66
|
+
"win32",
|
|
67
|
+
"windows"
|
|
68
|
+
],
|
|
69
|
+
"keywords": [
|
|
70
|
+
"stdlib",
|
|
71
|
+
"stdmath",
|
|
72
|
+
"mathematics",
|
|
73
|
+
"math",
|
|
74
|
+
"blas",
|
|
75
|
+
"extended",
|
|
76
|
+
"fill",
|
|
77
|
+
"assign",
|
|
78
|
+
"set",
|
|
79
|
+
"equal",
|
|
80
|
+
"copy",
|
|
81
|
+
"broadcast",
|
|
82
|
+
"constant",
|
|
83
|
+
"strided",
|
|
84
|
+
"complex64",
|
|
85
|
+
"array",
|
|
86
|
+
"complex64array",
|
|
87
|
+
"ndarray"
|
|
88
|
+
],
|
|
89
|
+
"funding": {
|
|
90
|
+
"type": "opencollective",
|
|
91
|
+
"url": "https://opencollective.com/stdlib"
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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/ext/base/cfill.h"
|
|
20
|
+
#include "stdlib/blas/base/shared.h"
|
|
21
|
+
#include "stdlib/napi/export.h"
|
|
22
|
+
#include "stdlib/napi/argv.h"
|
|
23
|
+
#include "stdlib/napi/argv_complex64.h"
|
|
24
|
+
#include "stdlib/napi/argv_int64.h"
|
|
25
|
+
#include "stdlib/napi/argv_strided_complex64array.h"
|
|
26
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
27
|
+
#include <node_api.h>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Receives JavaScript callback invocation data.
|
|
31
|
+
*
|
|
32
|
+
* @param env environment under which the function is invoked
|
|
33
|
+
* @param info callback data
|
|
34
|
+
* @return Node-API value
|
|
35
|
+
*/
|
|
36
|
+
static napi_value addon( napi_env env, napi_callback_info info ) {
|
|
37
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
|
|
38
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
39
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
|
|
40
|
+
STDLIB_NAPI_ARGV_COMPLEX64( env, alpha, argv, 1 );
|
|
41
|
+
STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, X, N, strideX, argv, 2 );
|
|
42
|
+
API_SUFFIX(stdlib_strided_cfill)( N, alpha, (stdlib_complex64_t *)X, strideX );
|
|
43
|
+
return NULL;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Receives JavaScript callback invocation data.
|
|
48
|
+
*
|
|
49
|
+
* @param env environment under which the function is invoked
|
|
50
|
+
* @param info callback data
|
|
51
|
+
* @return Node-API value
|
|
52
|
+
*/
|
|
53
|
+
static napi_value addon_method( napi_env env, napi_callback_info info ) {
|
|
54
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 5 );
|
|
55
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
56
|
+
STDLIB_NAPI_ARGV_COMPLEX64( env, alpha, argv, 1 );
|
|
57
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
|
|
58
|
+
STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
|
|
59
|
+
STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, X, N, strideX, argv, 2 );
|
|
60
|
+
API_SUFFIX(stdlib_strided_cfill_ndarray)( N, alpha, (stdlib_complex64_t *)X, strideX, offsetX );
|
|
61
|
+
return NULL;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
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/ext/base/cfill.h"
|
|
20
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
21
|
+
#include "stdlib/strided/base/stride2offset.h"
|
|
22
|
+
#include "stdlib/blas/base/shared.h"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Fills a single-precision complex floating-point strided array with a specified scalar constant.
|
|
26
|
+
*
|
|
27
|
+
* @param N number of indexed elements
|
|
28
|
+
* @param alpha scalar constant
|
|
29
|
+
* @param X input array
|
|
30
|
+
* @param strideX stride length
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
void API_SUFFIX(stdlib_strided_cfill)( const CBLAS_INT N, const stdlib_complex64_t alpha, stdlib_complex64_t *X, const CBLAS_INT strideX ) {
|
|
34
|
+
CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
|
|
35
|
+
API_SUFFIX(stdlib_strided_cfill_ndarray)( N, alpha, X, strideX, ox );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Fills a single-precision complex floating-point strided array with a specified scalar constant using alternative indexing semantics.
|
|
40
|
+
*
|
|
41
|
+
* @param N number of indexed elements
|
|
42
|
+
* @param alpha scalar
|
|
43
|
+
* @param X input array
|
|
44
|
+
* @param strideX stride length
|
|
45
|
+
* @param offsetX starting index
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
void API_SUFFIX(stdlib_strided_cfill_ndarray)( const CBLAS_INT N, const stdlib_complex64_t alpha, stdlib_complex64_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
|
|
49
|
+
CBLAS_INT ix;
|
|
50
|
+
CBLAS_INT m;
|
|
51
|
+
CBLAS_INT i;
|
|
52
|
+
|
|
53
|
+
if ( N <= 0 ) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
ix = offsetX;
|
|
57
|
+
|
|
58
|
+
// Use loop unrolling if the stride is equal to `1`...
|
|
59
|
+
if ( strideX == 1 ) {
|
|
60
|
+
m = N % 8;
|
|
61
|
+
|
|
62
|
+
// If we have a remainder, run a clean-up loop...
|
|
63
|
+
if ( m > 0 ) {
|
|
64
|
+
for ( i = 0; i < m; i++ ) {
|
|
65
|
+
X[ ix ] = alpha;
|
|
66
|
+
ix += strideX;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if ( N < 8 ) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
for ( i = m; i < N; i += 8 ) {
|
|
73
|
+
X[ ix ] = alpha;
|
|
74
|
+
X[ ix+1 ] = alpha;
|
|
75
|
+
X[ ix+2 ] = alpha;
|
|
76
|
+
X[ ix+3 ] = alpha;
|
|
77
|
+
X[ ix+4 ] = alpha;
|
|
78
|
+
X[ ix+5 ] = alpha;
|
|
79
|
+
X[ ix+6 ] = alpha;
|
|
80
|
+
X[ ix+7 ] = alpha;
|
|
81
|
+
ix += 8;
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for ( i = 0; i < N; i++ ) {
|
|
86
|
+
X[ ix ] = alpha;
|
|
87
|
+
ix += strideX;
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|