@stdlib/array-base-broadcasted-quaternary4d 0.0.1
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 +238 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +119 -0
- package/lib/index.js +59 -0
- package/lib/main.js +228 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
package/NOTICE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2024 The Stdlib Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
-->
|
|
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
|
+
|
|
32
|
+
# bquaternary4d
|
|
33
|
+
|
|
34
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
35
|
+
|
|
36
|
+
> Apply a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assign results to elements in a four-dimensional nested output array.
|
|
37
|
+
|
|
38
|
+
<section class="intro">
|
|
39
|
+
|
|
40
|
+
</section>
|
|
41
|
+
|
|
42
|
+
<!-- /.intro -->
|
|
43
|
+
|
|
44
|
+
<section class="installation">
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install @stdlib/array-base-broadcasted-quaternary4d
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
</section>
|
|
53
|
+
|
|
54
|
+
<section class="usage">
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
var bquaternary4d = require( '@stdlib/array-base-broadcasted-quaternary4d' );
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### bquaternary4d( arrays, shapes, fcn )
|
|
63
|
+
|
|
64
|
+
Applies a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assigns results to elements in a four-dimensional nested output array.
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
var add = require( '@stdlib/number-float64-base-add4' );
|
|
68
|
+
var zeros4d = require( '@stdlib/array-base-zeros4d' );
|
|
69
|
+
|
|
70
|
+
var x = [ [ 1.0, 2.0 ] ];
|
|
71
|
+
var y = [ [ 3.0 ], [ 4.0 ] ];
|
|
72
|
+
var z = [ [ 5.0 ] ];
|
|
73
|
+
var w = [ [ 2.0 ] ];
|
|
74
|
+
var out = zeros4d( [ 2, 2, 2, 2 ] );
|
|
75
|
+
|
|
76
|
+
var shapes = [
|
|
77
|
+
[ 1, 2 ],
|
|
78
|
+
[ 2, 1 ],
|
|
79
|
+
[ 1, 1 ],
|
|
80
|
+
[ 1, 1 ],
|
|
81
|
+
[ 1, 2, 2, 2 ]
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
bquaternary4d( [ x, y, z, w, out ], shapes, add );
|
|
85
|
+
// out => [ [ [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ], [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ] ] ]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The function accepts the following arguments:
|
|
89
|
+
|
|
90
|
+
- **arrays**: array-like object containing four input nested arrays and one output nested array.
|
|
91
|
+
- **shapes**: array shapes.
|
|
92
|
+
- **fcn**: quaternary function to apply.
|
|
93
|
+
|
|
94
|
+
</section>
|
|
95
|
+
|
|
96
|
+
<!-- /.usage -->
|
|
97
|
+
|
|
98
|
+
<section class="notes">
|
|
99
|
+
|
|
100
|
+
## Notes
|
|
101
|
+
|
|
102
|
+
- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes].
|
|
103
|
+
|
|
104
|
+
</section>
|
|
105
|
+
|
|
106
|
+
<!-- /.notes -->
|
|
107
|
+
|
|
108
|
+
<section class="examples">
|
|
109
|
+
|
|
110
|
+
## Examples
|
|
111
|
+
|
|
112
|
+
<!-- eslint no-undef: "error" -->
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
|
|
116
|
+
var filled4dBy = require( '@stdlib/array-base-filled4d-by' );
|
|
117
|
+
var zeros4d = require( '@stdlib/array-base-zeros4d' );
|
|
118
|
+
var add = require( '@stdlib/number-float64-base-add4' );
|
|
119
|
+
var bquaternary4d = require( '@stdlib/array-base-broadcasted-quaternary4d' );
|
|
120
|
+
|
|
121
|
+
var shapes = [
|
|
122
|
+
[ 1, 1, 3, 1 ],
|
|
123
|
+
[ 3, 1, 1, 1 ],
|
|
124
|
+
[ 1, 1, 1, 3 ],
|
|
125
|
+
[ 1, 3, 1, 1 ],
|
|
126
|
+
[ 3, 3, 3, 3 ]
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) );
|
|
130
|
+
console.log( x );
|
|
131
|
+
|
|
132
|
+
var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) );
|
|
133
|
+
console.log( y );
|
|
134
|
+
|
|
135
|
+
var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) );
|
|
136
|
+
console.log( z );
|
|
137
|
+
|
|
138
|
+
var w = filled4dBy( shapes[ 3 ], discreteUniform( -100, 100 ) );
|
|
139
|
+
console.log( w );
|
|
140
|
+
|
|
141
|
+
var out = zeros4d( shapes[ 4 ] );
|
|
142
|
+
console.log( out );
|
|
143
|
+
|
|
144
|
+
bquaternary4d( [ x, y, z, w, out ], shapes, add );
|
|
145
|
+
console.log( out );
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
</section>
|
|
149
|
+
|
|
150
|
+
<!-- /.examples -->
|
|
151
|
+
|
|
152
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
153
|
+
|
|
154
|
+
<section class="related">
|
|
155
|
+
|
|
156
|
+
</section>
|
|
157
|
+
|
|
158
|
+
<!-- /.related -->
|
|
159
|
+
|
|
160
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
<section class="main-repo" >
|
|
164
|
+
|
|
165
|
+
* * *
|
|
166
|
+
|
|
167
|
+
## Notice
|
|
168
|
+
|
|
169
|
+
This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
|
|
170
|
+
|
|
171
|
+
For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
|
|
172
|
+
|
|
173
|
+
#### Community
|
|
174
|
+
|
|
175
|
+
[![Chat][chat-image]][chat-url]
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
See [LICENSE][stdlib-license].
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
## Copyright
|
|
185
|
+
|
|
186
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
187
|
+
|
|
188
|
+
</section>
|
|
189
|
+
|
|
190
|
+
<!-- /.stdlib -->
|
|
191
|
+
|
|
192
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
193
|
+
|
|
194
|
+
<section class="links">
|
|
195
|
+
|
|
196
|
+
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-base-broadcasted-quaternary4d.svg
|
|
197
|
+
[npm-url]: https://npmjs.org/package/@stdlib/array-base-broadcasted-quaternary4d
|
|
198
|
+
|
|
199
|
+
[test-image]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/actions/workflows/test.yml/badge.svg?branch=v0.0.1
|
|
200
|
+
[test-url]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/actions/workflows/test.yml?query=branch:v0.0.1
|
|
201
|
+
|
|
202
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-broadcasted-quaternary4d/main.svg
|
|
203
|
+
[coverage-url]: https://codecov.io/github/stdlib-js/array-base-broadcasted-quaternary4d?branch=main
|
|
204
|
+
|
|
205
|
+
<!--
|
|
206
|
+
|
|
207
|
+
[dependencies-image]: https://img.shields.io/david/stdlib-js/array-base-broadcasted-quaternary4d.svg
|
|
208
|
+
[dependencies-url]: https://david-dm.org/stdlib-js/array-base-broadcasted-quaternary4d/main
|
|
209
|
+
|
|
210
|
+
-->
|
|
211
|
+
|
|
212
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
213
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
214
|
+
|
|
215
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
216
|
+
|
|
217
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
218
|
+
|
|
219
|
+
[umd]: https://github.com/umdjs/umd
|
|
220
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
221
|
+
|
|
222
|
+
[deno-url]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/tree/deno
|
|
223
|
+
[deno-readme]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/blob/deno/README.md
|
|
224
|
+
[umd-url]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/tree/umd
|
|
225
|
+
[umd-readme]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/blob/umd/README.md
|
|
226
|
+
[esm-url]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/tree/esm
|
|
227
|
+
[esm-readme]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/blob/esm/README.md
|
|
228
|
+
[branches-url]: https://github.com/stdlib-js/array-base-broadcasted-quaternary4d/blob/main/branches.md
|
|
229
|
+
|
|
230
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-broadcasted-quaternary4d/main/LICENSE
|
|
231
|
+
|
|
232
|
+
[@stdlib/array/base/broadcast-array]: https://www.npmjs.com/package/@stdlib/array-base-broadcast-array
|
|
233
|
+
|
|
234
|
+
[@stdlib/ndarray/base/broadcast-shapes]: https://www.npmjs.com/package/@stdlib/ndarray-base-broadcast-shapes
|
|
235
|
+
|
|
236
|
+
</section>
|
|
237
|
+
|
|
238
|
+
<!-- /.links -->
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var mr=function(t,v){return function(){return v||t((v={exports:{}}).exports,v),v.exports}};var fr=mr(function(kr,zr){
|
|
2
|
+
var n=require('@stdlib/array-base-broadcast-array/dist');function sr(t,v,yr){var F,G,H,I,J,K,L,M,N,O,P,Q,R,T,U,V,o,w,z,f,i,u,e,x,y,m,s,c,j,k,S,q,b,A,g,l,B,C,D,E,W,X,Y,Z,_,$,p,h,rr,ar,vr,dr,tr,ir,ur,d,r,a,er,xr,nr,or,wr;if(d=v[4],o=d[3],w=d[2],z=d[1],f=d[0],!(o<=0||w<=0||z<=0||f<=0))for(a=n(t[0],v[0],d),er=a.data,r=a.strides,F=r[3],G=r[2],H=r[1],I=r[0],a=n(t[1],v[1],d),xr=a.data,r=a.strides,J=r[3],K=r[2],L=r[1],M=r[0],a=n(t[2],v[2],d),nr=a.data,r=a.strides,N=r[3],O=r[2],P=r[1],Q=r[0],a=n(t[3],v[3],d),or=a.data,r=a.strides,R=r[3],T=r[2],U=r[1],V=r[0],wr=t[4],c=0,q=0,l=0,E=0,x=0;x<f;x++){for(s=0,S=0,g=0,D=0,Y=er[c],$=xr[q],rr=nr[l],dr=or[E],ur=wr[x],e=0;e<z;e++){for(m=0,k=0,A=0,C=0,X=Y[s],_=$[S],h=rr[g],vr=dr[D],ir=ur[e],u=0;u<w;u++){for(y=0,j=0,b=0,B=0,W=X[m],Z=_[k],p=h[A],ar=vr[C],tr=ir[u],i=0;i<o;i++)tr[i]=yr(W[y],Z[j],p[b],ar[B]),y+=F,j+=J,b+=N,B+=R;m+=G,k+=K,A+=O,C+=T}s+=H,S+=L,g+=P,D+=U}c+=I,q+=M,l+=Q,E+=V}}zr.exports=sr
|
|
3
|
+
});var cr=fr();module.exports=cr;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 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 broadcastArray = require( '@stdlib/array-base-broadcast-array' );\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject<Array>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject<NonNegativeIntegerArray>} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* var add = require( '@stdlib/number-float64-base-add4' );\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* var shapes = [\n* [ 1, 3, 1, 1 ],\n* [ 1, 1, 3, 1 ],\n* [ 1, 1, 1, 3 ],\n* [ 1, 1, 1, 1 ],\n* [ 1, 3, 3, 3 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var w = ones4d( shapes[ 3 ] );\n* var out = zeros4d( shapes[ 4 ] );\n*\n* bquaternary4d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ]\n*/\nfunction bquaternary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar dw3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar n3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar u0;\n\tvar u1;\n\tvar u2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 3 ];\n\tdz1 = st[ 2 ];\n\tdz2 = st[ 1 ];\n\tdz3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 3 ];\n\tdw1 = st[ 2 ];\n\tdw2 = st[ 1 ];\n\tdw3 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj3 = 0;\n\tk3 = 0;\n\tm3 = 0;\n\tn3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tm2 = 0;\n\t\tn2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ m3 ];\n\t\tw2 = w[ n3 ];\n\t\tu2 = u[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tm1 = 0;\n\t\t\tn1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ m2 ];\n\t\t\tw1 = w2[ n2 ];\n\t\t\tu1 = u2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tm0 = 0;\n\t\t\t\tn0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\tw0 = w1[ n1 ];\n\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t\tm0 += dz0;\n\t\t\t\t\tn0 += dw0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t\tm1 += dz1;\n\t\t\t\tn1 += dw1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t\tm2 += dz2;\n\t\t\tn2 += dw2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t\tm3 += dz3;\n\t\tn3 += dw3;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = bquaternary4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 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* Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a four-dimensional nested output array.\n*\n* @module @stdlib/array-base-broadcasted-quaternary4d\n*\n* @example\n* var add = require( '@stdlib/number-float64-base-add4' );\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var bquaternary4d = require( '@stdlib/array-base-broadcasted-quaternary4d' );\n*\n* var shapes = [\n* [ 1, 3, 1, 1 ],\n* [ 1, 1, 3, 1 ],\n* [ 1, 1, 1, 3 ],\n* [ 1, 1, 1, 1 ],\n* [ 1, 3, 3, 3 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var w = ones4d( shapes[ 3 ] );\n* var out = zeros4d( shapes[ 4 ] );\n*\n* bquaternary4d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "broadcastArray", "bquaternary4d", "arrays", "shapes", "fcn", "dx0", "dx1", "dx2", "dx3", "dy0", "dy1", "dy2", "dy3", "dz0", "dz1", "dz2", "dz3", "dw0", "dw1", "dw2", "dw3", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "j0", "j1", "j2", "j3", "k0", "k1", "k2", "k3", "m0", "m1", "m2", "m3", "n0", "n1", "n2", "n3", "x0", "x1", "x2", "y0", "y1", "y2", "z0", "z1", "z2", "w0", "w1", "w2", "u0", "u1", "u2", "sh", "st", "o", "x", "y", "z", "w", "u", "main"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/// <reference types="@stdlib/types"/>
|
|
22
|
+
|
|
23
|
+
import { Array1D, Array2D, Array3D, Array4D } from '@stdlib/types/array';
|
|
24
|
+
import { Shape1D, Shape2D, Shape3D, Shape4D } from '@stdlib/types/ndarray';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Quaternary callback.
|
|
28
|
+
*
|
|
29
|
+
* @param v1 - element from first input array
|
|
30
|
+
* @param v2 - element from second input array
|
|
31
|
+
* @param v3 - element from third input array
|
|
32
|
+
* @param v4 - element from fourth input array
|
|
33
|
+
* @returns result
|
|
34
|
+
*/
|
|
35
|
+
type Quaternary<T, U, V, W, X> = ( v1: T, v2: U, v3: V, v4: W ) => X;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Input array.
|
|
39
|
+
*/
|
|
40
|
+
type InputArray<T> = Array1D<T> | Array2D<T> | Array3D<T> | Array4D<T>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Input array shape.
|
|
44
|
+
*/
|
|
45
|
+
type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Output array.
|
|
49
|
+
*/
|
|
50
|
+
type OutputArray<T> = Array4D<T>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Output array shape.
|
|
54
|
+
*/
|
|
55
|
+
type OutputArrayShape = Shape4D;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Input and output arrays.
|
|
59
|
+
*/
|
|
60
|
+
type InOutArrays<T, U, V, W, X> = [
|
|
61
|
+
InputArray<T>,
|
|
62
|
+
InputArray<U>,
|
|
63
|
+
InputArray<V>,
|
|
64
|
+
InputArray<W>,
|
|
65
|
+
OutputArray<X>
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Input and output array shapes.
|
|
70
|
+
*/
|
|
71
|
+
type InOutShapes = [
|
|
72
|
+
InputArrayShape,
|
|
73
|
+
InputArrayShape,
|
|
74
|
+
InputArrayShape,
|
|
75
|
+
InputArrayShape,
|
|
76
|
+
OutputArrayShape
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.
|
|
81
|
+
*
|
|
82
|
+
* ## Notes
|
|
83
|
+
*
|
|
84
|
+
* - The input array shapes must be broadcast compatible with the output array shape.
|
|
85
|
+
*
|
|
86
|
+
* @param arrays - array containing four input nested arrays and one output nested array
|
|
87
|
+
* @param shapes - array shapes
|
|
88
|
+
* @param fcn - quaternary callback
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* var add = require( '@stdlib/number-float64-base-add4' );
|
|
92
|
+
* var ones4d = require( '@stdlib/array-base-ones4d' );
|
|
93
|
+
* var zeros4d = require( '@stdlib/array-base-zeros4d' );
|
|
94
|
+
*
|
|
95
|
+
* var shapes = [
|
|
96
|
+
* [ 1, 3, 1, 1 ],
|
|
97
|
+
* [ 1, 1, 3, 1 ],
|
|
98
|
+
* [ 1, 1, 1, 3 ],
|
|
99
|
+
* [ 1, 1, 1, 1 ],
|
|
100
|
+
* [ 1, 3, 3, 3 ]
|
|
101
|
+
* ];
|
|
102
|
+
*
|
|
103
|
+
* var x = ones4d( shapes[ 0 ] );
|
|
104
|
+
* var y = ones4d( shapes[ 1 ] );
|
|
105
|
+
* var z = ones4d( shapes[ 2 ] );
|
|
106
|
+
* var w = ones4d( shapes[ 3 ] );
|
|
107
|
+
* var out = zeros4d( shapes[ 4 ] );
|
|
108
|
+
*
|
|
109
|
+
* bquaternary4d( [ x, y, z, w, out ], shapes, add );
|
|
110
|
+
*
|
|
111
|
+
* console.log( out );
|
|
112
|
+
* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ]
|
|
113
|
+
*/
|
|
114
|
+
declare function bquaternary4d<T = unknown, U = unknown, V = unknown, W = unknown, X = unknown>( arrays: InOutArrays<T, U, V, W, X>, shapes: InOutShapes, fcn: Quaternary<T, U, V, W, X> ): void;
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
// EXPORTS //
|
|
118
|
+
|
|
119
|
+
export = bquaternary4d;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a four-dimensional nested output array.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/array-base-broadcasted-quaternary4d
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var add = require( '@stdlib/number-float64-base-add4' );
|
|
28
|
+
* var ones4d = require( '@stdlib/array-base-ones4d' );
|
|
29
|
+
* var zeros4d = require( '@stdlib/array-base-zeros4d' );
|
|
30
|
+
* var bquaternary4d = require( '@stdlib/array-base-broadcasted-quaternary4d' );
|
|
31
|
+
*
|
|
32
|
+
* var shapes = [
|
|
33
|
+
* [ 1, 3, 1, 1 ],
|
|
34
|
+
* [ 1, 1, 3, 1 ],
|
|
35
|
+
* [ 1, 1, 1, 3 ],
|
|
36
|
+
* [ 1, 1, 1, 1 ],
|
|
37
|
+
* [ 1, 3, 3, 3 ]
|
|
38
|
+
* ];
|
|
39
|
+
*
|
|
40
|
+
* var x = ones4d( shapes[ 0 ] );
|
|
41
|
+
* var y = ones4d( shapes[ 1 ] );
|
|
42
|
+
* var z = ones4d( shapes[ 2 ] );
|
|
43
|
+
* var w = ones4d( shapes[ 3 ] );
|
|
44
|
+
* var out = zeros4d( shapes[ 4 ] );
|
|
45
|
+
*
|
|
46
|
+
* bquaternary4d( [ x, y, z, w, out ], shapes, add );
|
|
47
|
+
*
|
|
48
|
+
* console.log( out );
|
|
49
|
+
* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ]
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
// MODULES //
|
|
53
|
+
|
|
54
|
+
var main = require( './main.js' );
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// EXPORTS //
|
|
58
|
+
|
|
59
|
+
module.exports = main;
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var broadcastArray = require( '@stdlib/array-base-broadcast-array' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.
|
|
30
|
+
*
|
|
31
|
+
* @param {ArrayLikeObject<Array>} arrays - array-like object containing four input nested arrays and one output nested array
|
|
32
|
+
* @param {ArrayLikeObject<NonNegativeIntegerArray>} shapes - array shapes
|
|
33
|
+
* @param {Callback} fcn - quaternary callback
|
|
34
|
+
* @returns {void}
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var add = require( '@stdlib/number-float64-base-add4' );
|
|
38
|
+
* var ones4d = require( '@stdlib/array-base-ones4d' );
|
|
39
|
+
* var zeros4d = require( '@stdlib/array-base-zeros4d' );
|
|
40
|
+
*
|
|
41
|
+
* var shapes = [
|
|
42
|
+
* [ 1, 3, 1, 1 ],
|
|
43
|
+
* [ 1, 1, 3, 1 ],
|
|
44
|
+
* [ 1, 1, 1, 3 ],
|
|
45
|
+
* [ 1, 1, 1, 1 ],
|
|
46
|
+
* [ 1, 3, 3, 3 ]
|
|
47
|
+
* ];
|
|
48
|
+
*
|
|
49
|
+
* var x = ones4d( shapes[ 0 ] );
|
|
50
|
+
* var y = ones4d( shapes[ 1 ] );
|
|
51
|
+
* var z = ones4d( shapes[ 2 ] );
|
|
52
|
+
* var w = ones4d( shapes[ 3 ] );
|
|
53
|
+
* var out = zeros4d( shapes[ 4 ] );
|
|
54
|
+
*
|
|
55
|
+
* bquaternary4d( [ x, y, z, w, out ], shapes, add );
|
|
56
|
+
*
|
|
57
|
+
* console.log( out );
|
|
58
|
+
* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ]
|
|
59
|
+
*/
|
|
60
|
+
function bquaternary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements
|
|
61
|
+
var dx0;
|
|
62
|
+
var dx1;
|
|
63
|
+
var dx2;
|
|
64
|
+
var dx3;
|
|
65
|
+
var dy0;
|
|
66
|
+
var dy1;
|
|
67
|
+
var dy2;
|
|
68
|
+
var dy3;
|
|
69
|
+
var dz0;
|
|
70
|
+
var dz1;
|
|
71
|
+
var dz2;
|
|
72
|
+
var dz3;
|
|
73
|
+
var dw0;
|
|
74
|
+
var dw1;
|
|
75
|
+
var dw2;
|
|
76
|
+
var dw3;
|
|
77
|
+
var S0;
|
|
78
|
+
var S1;
|
|
79
|
+
var S2;
|
|
80
|
+
var S3;
|
|
81
|
+
var i0;
|
|
82
|
+
var i1;
|
|
83
|
+
var i2;
|
|
84
|
+
var i3;
|
|
85
|
+
var j0;
|
|
86
|
+
var j1;
|
|
87
|
+
var j2;
|
|
88
|
+
var j3;
|
|
89
|
+
var k0;
|
|
90
|
+
var k1;
|
|
91
|
+
var k2;
|
|
92
|
+
var k3;
|
|
93
|
+
var m0;
|
|
94
|
+
var m1;
|
|
95
|
+
var m2;
|
|
96
|
+
var m3;
|
|
97
|
+
var n0;
|
|
98
|
+
var n1;
|
|
99
|
+
var n2;
|
|
100
|
+
var n3;
|
|
101
|
+
var x0;
|
|
102
|
+
var x1;
|
|
103
|
+
var x2;
|
|
104
|
+
var y0;
|
|
105
|
+
var y1;
|
|
106
|
+
var y2;
|
|
107
|
+
var z0;
|
|
108
|
+
var z1;
|
|
109
|
+
var z2;
|
|
110
|
+
var w0;
|
|
111
|
+
var w1;
|
|
112
|
+
var w2;
|
|
113
|
+
var u0;
|
|
114
|
+
var u1;
|
|
115
|
+
var u2;
|
|
116
|
+
var sh;
|
|
117
|
+
var st;
|
|
118
|
+
var o;
|
|
119
|
+
var x;
|
|
120
|
+
var y;
|
|
121
|
+
var z;
|
|
122
|
+
var w;
|
|
123
|
+
var u;
|
|
124
|
+
|
|
125
|
+
sh = shapes[ 4 ];
|
|
126
|
+
S0 = sh[ 3 ];
|
|
127
|
+
S1 = sh[ 2 ];
|
|
128
|
+
S2 = sh[ 1 ];
|
|
129
|
+
S3 = sh[ 0 ];
|
|
130
|
+
if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );
|
|
134
|
+
x = o.data;
|
|
135
|
+
st = o.strides;
|
|
136
|
+
dx0 = st[ 3 ];
|
|
137
|
+
dx1 = st[ 2 ];
|
|
138
|
+
dx2 = st[ 1 ];
|
|
139
|
+
dx3 = st[ 0 ];
|
|
140
|
+
|
|
141
|
+
o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );
|
|
142
|
+
y = o.data;
|
|
143
|
+
st = o.strides;
|
|
144
|
+
dy0 = st[ 3 ];
|
|
145
|
+
dy1 = st[ 2 ];
|
|
146
|
+
dy2 = st[ 1 ];
|
|
147
|
+
dy3 = st[ 0 ];
|
|
148
|
+
|
|
149
|
+
o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );
|
|
150
|
+
z = o.data;
|
|
151
|
+
st = o.strides;
|
|
152
|
+
dz0 = st[ 3 ];
|
|
153
|
+
dz1 = st[ 2 ];
|
|
154
|
+
dz2 = st[ 1 ];
|
|
155
|
+
dz3 = st[ 0 ];
|
|
156
|
+
|
|
157
|
+
o = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );
|
|
158
|
+
w = o.data;
|
|
159
|
+
st = o.strides;
|
|
160
|
+
dw0 = st[ 3 ];
|
|
161
|
+
dw1 = st[ 2 ];
|
|
162
|
+
dw2 = st[ 1 ];
|
|
163
|
+
dw3 = st[ 0 ];
|
|
164
|
+
|
|
165
|
+
u = arrays[ 4 ];
|
|
166
|
+
|
|
167
|
+
j3 = 0;
|
|
168
|
+
k3 = 0;
|
|
169
|
+
m3 = 0;
|
|
170
|
+
n3 = 0;
|
|
171
|
+
for ( i3 = 0; i3 < S3; i3++ ) {
|
|
172
|
+
j2 = 0;
|
|
173
|
+
k2 = 0;
|
|
174
|
+
m2 = 0;
|
|
175
|
+
n2 = 0;
|
|
176
|
+
x2 = x[ j3 ];
|
|
177
|
+
y2 = y[ k3 ];
|
|
178
|
+
z2 = z[ m3 ];
|
|
179
|
+
w2 = w[ n3 ];
|
|
180
|
+
u2 = u[ i3 ];
|
|
181
|
+
for ( i2 = 0; i2 < S2; i2++ ) {
|
|
182
|
+
j1 = 0;
|
|
183
|
+
k1 = 0;
|
|
184
|
+
m1 = 0;
|
|
185
|
+
n1 = 0;
|
|
186
|
+
x1 = x2[ j2 ];
|
|
187
|
+
y1 = y2[ k2 ];
|
|
188
|
+
z1 = z2[ m2 ];
|
|
189
|
+
w1 = w2[ n2 ];
|
|
190
|
+
u1 = u2[ i2 ];
|
|
191
|
+
for ( i1 = 0; i1 < S1; i1++ ) {
|
|
192
|
+
j0 = 0;
|
|
193
|
+
k0 = 0;
|
|
194
|
+
m0 = 0;
|
|
195
|
+
n0 = 0;
|
|
196
|
+
x0 = x1[ j1 ];
|
|
197
|
+
y0 = y1[ k1 ];
|
|
198
|
+
z0 = z1[ m1 ];
|
|
199
|
+
w0 = w1[ n1 ];
|
|
200
|
+
u0 = u1[ i1 ];
|
|
201
|
+
for ( i0 = 0; i0 < S0; i0++ ) {
|
|
202
|
+
u0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );
|
|
203
|
+
j0 += dx0;
|
|
204
|
+
k0 += dy0;
|
|
205
|
+
m0 += dz0;
|
|
206
|
+
n0 += dw0;
|
|
207
|
+
}
|
|
208
|
+
j1 += dx1;
|
|
209
|
+
k1 += dy1;
|
|
210
|
+
m1 += dz1;
|
|
211
|
+
n1 += dw1;
|
|
212
|
+
}
|
|
213
|
+
j2 += dx2;
|
|
214
|
+
k2 += dy2;
|
|
215
|
+
m2 += dz2;
|
|
216
|
+
n2 += dw2;
|
|
217
|
+
}
|
|
218
|
+
j3 += dx3;
|
|
219
|
+
k3 += dy3;
|
|
220
|
+
m3 += dz3;
|
|
221
|
+
n3 += dw3;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
// EXPORTS //
|
|
227
|
+
|
|
228
|
+
module.exports = bquaternary4d;
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/array-base-broadcasted-quaternary4d",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a four-dimensional nested output array.",
|
|
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
|
+
"directories": {
|
|
18
|
+
"doc": "./docs",
|
|
19
|
+
"lib": "./lib",
|
|
20
|
+
"dist": "./dist"
|
|
21
|
+
},
|
|
22
|
+
"types": "./docs/types",
|
|
23
|
+
"scripts": {},
|
|
24
|
+
"homepage": "https://stdlib.io",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git://github.com/stdlib-js/array-base-broadcasted-quaternary4d.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@stdlib/array-base-broadcast-array": "^0.2.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=0.10.0",
|
|
38
|
+
"npm": ">2.7.0"
|
|
39
|
+
},
|
|
40
|
+
"os": [
|
|
41
|
+
"aix",
|
|
42
|
+
"darwin",
|
|
43
|
+
"freebsd",
|
|
44
|
+
"linux",
|
|
45
|
+
"macos",
|
|
46
|
+
"openbsd",
|
|
47
|
+
"sunos",
|
|
48
|
+
"win32",
|
|
49
|
+
"windows"
|
|
50
|
+
],
|
|
51
|
+
"keywords": [
|
|
52
|
+
"stdlib",
|
|
53
|
+
"base",
|
|
54
|
+
"array",
|
|
55
|
+
"multidimensional",
|
|
56
|
+
"ndarray",
|
|
57
|
+
"matrix",
|
|
58
|
+
"4d",
|
|
59
|
+
"quaternary",
|
|
60
|
+
"apply",
|
|
61
|
+
"foreach",
|
|
62
|
+
"map",
|
|
63
|
+
"transform",
|
|
64
|
+
"broadcast"
|
|
65
|
+
],
|
|
66
|
+
"funding": {
|
|
67
|
+
"type": "opencollective",
|
|
68
|
+
"url": "https://opencollective.com/stdlib"
|
|
69
|
+
}
|
|
70
|
+
}
|