feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
This commit is contained in:
parent
d670b89c4d
commit
b6addc7f05
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1 @@
|
|||
**/node_modules
|
||||
**/samples-gpt
|
||||
|
|
53
js/node_modules/.yarn-integrity
generated
vendored
Normal file
53
js/node_modules/.yarn-integrity
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"systemParams": "linux-x64-93",
|
||||
"modulesFolders": [
|
||||
"node_modules"
|
||||
],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [
|
||||
"@stdlib/random@^0.0.12"
|
||||
],
|
||||
"lockfileEntries": {
|
||||
"@stdlib/array@^0.0.x": "https://registry.yarnpkg.com/@stdlib/array/-/array-0.0.12.tgz#12f40ab95bb36d424cdad991f29fc3cb491ee29e",
|
||||
"@stdlib/assert@^0.0.x": "https://registry.yarnpkg.com/@stdlib/assert/-/assert-0.0.12.tgz#1648c9016e5041291f55a6464abcc4069c5103ce",
|
||||
"@stdlib/bigint@^0.0.x": "https://registry.yarnpkg.com/@stdlib/bigint/-/bigint-0.0.11.tgz#c416a1d727001c55f4897e6424124199d638f2fd",
|
||||
"@stdlib/blas@^0.0.x": "https://registry.yarnpkg.com/@stdlib/blas/-/blas-0.0.12.tgz#7e93e42b4621fc6903bf63264f045047333536c2",
|
||||
"@stdlib/buffer@^0.0.x": "https://registry.yarnpkg.com/@stdlib/buffer/-/buffer-0.0.11.tgz#6137b00845e6c905181cc7ebfae9f7e47c01b0ce",
|
||||
"@stdlib/cli@^0.0.x": "https://registry.yarnpkg.com/@stdlib/cli/-/cli-0.0.10.tgz#28e2fbe6865d7f5cd15b7dc5846c99bd3b91674f",
|
||||
"@stdlib/complex@^0.0.x": "https://registry.yarnpkg.com/@stdlib/complex/-/complex-0.0.12.tgz#3afbc190cd0a9b37fc7c6e508c3aa9fda9106944",
|
||||
"@stdlib/constants@^0.0.x": "https://registry.yarnpkg.com/@stdlib/constants/-/constants-0.0.11.tgz#78cd56d6c2982b30264843c3d75bde7125e90cd2",
|
||||
"@stdlib/fs@^0.0.x": "https://registry.yarnpkg.com/@stdlib/fs/-/fs-0.0.12.tgz#662365fd5846a51f075724b4f2888ae88441b70d",
|
||||
"@stdlib/math@^0.0.x": "https://registry.yarnpkg.com/@stdlib/math/-/math-0.0.11.tgz#eb6638bc03a20fbd6727dd5b977ee0170bda4649",
|
||||
"@stdlib/ndarray@^0.0.x": "https://registry.yarnpkg.com/@stdlib/ndarray/-/ndarray-0.0.13.tgz#2e8fc645e10f56a645a0ab81598808c0e8f43b82",
|
||||
"@stdlib/nlp@^0.0.x": "https://registry.yarnpkg.com/@stdlib/nlp/-/nlp-0.0.11.tgz#532ec0f7267b8d639e4c20c6de864e8de8a09054",
|
||||
"@stdlib/number@^0.0.x": "https://registry.yarnpkg.com/@stdlib/number/-/number-0.0.10.tgz#4030ad8fc3fac19a9afb415c443cee6deea0e65c",
|
||||
"@stdlib/os@^0.0.x": "https://registry.yarnpkg.com/@stdlib/os/-/os-0.0.12.tgz#08bbf013c62a7153099fa9cbac086ca1349a4677",
|
||||
"@stdlib/process@^0.0.x": "https://registry.yarnpkg.com/@stdlib/process/-/process-0.0.12.tgz#123325079d89a32f4212f72fb694f8fe3614cf18",
|
||||
"@stdlib/random@^0.0.12": "https://registry.yarnpkg.com/@stdlib/random/-/random-0.0.12.tgz#e819c3abd602ed5559ba800dba751e49c633ff85",
|
||||
"@stdlib/random@^0.0.x": "https://registry.yarnpkg.com/@stdlib/random/-/random-0.0.12.tgz#e819c3abd602ed5559ba800dba751e49c633ff85",
|
||||
"@stdlib/regexp@^0.0.x": "https://registry.yarnpkg.com/@stdlib/regexp/-/regexp-0.0.13.tgz#80b98361dc7a441b47bc3fa964bb0c826759e971",
|
||||
"@stdlib/stats@^0.0.x": "https://registry.yarnpkg.com/@stdlib/stats/-/stats-0.0.13.tgz#87c973f385379d794707c7b5196a173dba8b07e1",
|
||||
"@stdlib/streams@^0.0.x": "https://registry.yarnpkg.com/@stdlib/streams/-/streams-0.0.12.tgz#07f5ceae5852590afad8e1cb7ce94174becc8739",
|
||||
"@stdlib/strided@^0.0.x": "https://registry.yarnpkg.com/@stdlib/strided/-/strided-0.0.12.tgz#86ac48e660cb7f64a45cf07e80cbbfe58be21ae1",
|
||||
"@stdlib/string@^0.0.x": "https://registry.yarnpkg.com/@stdlib/string/-/string-0.0.14.tgz#4feea4f9089ab72428eebb65fe7b93d90a7f34f4",
|
||||
"@stdlib/symbol@^0.0.x": "https://registry.yarnpkg.com/@stdlib/symbol/-/symbol-0.0.12.tgz#b9f396b0bf269c2985bb7fe99810a8e26d7288c3",
|
||||
"@stdlib/time@^0.0.x": "https://registry.yarnpkg.com/@stdlib/time/-/time-0.0.14.tgz#ea6daa438b1d3b019b99f5091117ee4bcef55d60",
|
||||
"@stdlib/types@^0.0.x": "https://registry.yarnpkg.com/@stdlib/types/-/types-0.0.14.tgz#02d3aab7a9bfaeb86e34ab749772ea22f7b2f7e0",
|
||||
"@stdlib/utils@^0.0.x": "https://registry.yarnpkg.com/@stdlib/utils/-/utils-0.0.12.tgz#670de5a7b253f04f11a4cba38f790e82393bcb46",
|
||||
"core-util-is@~1.0.0": "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85",
|
||||
"debug@^2.6.9": "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f",
|
||||
"inherits@~2.0.3": "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c",
|
||||
"isarray@~1.0.0": "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11",
|
||||
"minimist@^1.2.0": "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18",
|
||||
"ms@2.0.0": "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8",
|
||||
"process-nextick-args@~2.0.0": "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2",
|
||||
"readable-stream@^2.1.4": "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57",
|
||||
"safe-buffer@~5.1.0": "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d",
|
||||
"safe-buffer@~5.1.1": "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d",
|
||||
"string_decoder@~1.1.1": "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8",
|
||||
"util-deprecate@~1.0.1": "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
|
||||
},
|
||||
"files": [],
|
||||
"artifacts": {}
|
||||
}
|
481
js/node_modules/@stdlib/array/LICENSE
generated
vendored
Normal file
481
js/node_modules/@stdlib/array/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,481 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by this
|
||||
license (the "Software") to use, reproduce, display, distribute, execute, and
|
||||
transmit the Software, and to prepare derivative works of the Software, and to
|
||||
permit third-parties to whom the Software is furnished to do so, all subject to
|
||||
the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including the
|
||||
above license grant, this restriction and the following disclaimer, must be
|
||||
included in all copies of the Software, in whole or in part, and all derivative
|
||||
works of the Software, unless such copies or derivative works are solely in the
|
||||
form of machine-executable object code generated by a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
|
||||
OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
||||
DEPENDENCIES
|
||||
|
||||
The library links against the following external libraries, which have their own
|
||||
licenses:
|
||||
|
||||
* OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
|
||||
def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
|
||||
|
||||
Copyright (c) 2011-2014, The OpenBLAS Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. Neither the name of the OpenBLAS project nor the names of
|
||||
its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
* Electron <https://raw.githubusercontent.com/electron/electron/
|
||||
c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
|
||||
|
||||
Copyright (c) 2013-2017 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
* Boost <http://www.boost.org/LICENSE_1_0.txt>
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
* Cephes <http://www.netlib.org/cephes/readme>
|
||||
|
||||
Copyright (c) 1984-2000 Stephen L. Moshier
|
||||
|
||||
Some software in this archive may be from the book _Methods and Programs for
|
||||
Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
|
||||
or from the Cephes Mathematical Library, a commercial product. In either event,
|
||||
it is copyrighted by the author. What you see here may be used freely but it
|
||||
comes with no support or guarantee.
|
||||
|
||||
Stephen L. Moshier
|
||||
moshier@na-net.ornl.gov
|
||||
|
||||
|
||||
|
||||
ATTRIBUTION
|
||||
|
||||
The library contains implementations from the following external libraries,
|
||||
which have their own licenses:
|
||||
|
||||
* FreeBSD <https://svnweb.freebsd.org/>
|
||||
|
||||
Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
Permission to use, copy, modify, and distribute this
|
||||
software is freely granted, provided that this notice
|
||||
is preserved.
|
||||
|
||||
|
||||
* FDLIBM <http://www.netlib.org/fdlibm/>
|
||||
|
||||
Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
Permission to use, copy, modify, and distribute this
|
||||
software is freely granted, provided that this notice
|
||||
is preserved.
|
||||
|
||||
|
||||
* Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
* SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
|
||||
|
||||
Public domain.
|
||||
|
||||
|
||||
* ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
|
||||
|
||||
Copyright JS Foundation and other contributors, https://js.foundation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
* StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
|
||||
e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
|
||||
|
||||
Copyright (c) 2015: Dahua Lin.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
* SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
|
||||
SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
|
||||
|
||||
https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
* MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
|
||||
mt19937ar.c>
|
||||
|
||||
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The names of its contributors may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
js/node_modules/@stdlib/array/NOTICE
generated
vendored
Normal file
1
js/node_modules/@stdlib/array/NOTICE
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Copyright (c) 2016-2021 The Stdlib Authors.
|
371
js/node_modules/@stdlib/array/README.md
generated
vendored
Normal file
371
js/node_modules/@stdlib/array/README.md
generated
vendored
Normal file
|
@ -0,0 +1,371 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2018 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# Arrays
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
|
||||
|
||||
> Arrays.
|
||||
|
||||
<section class="installation">
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @stdlib/array
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var ns = require( '@stdlib/array' );
|
||||
```
|
||||
|
||||
#### ns
|
||||
|
||||
Arrays.
|
||||
|
||||
```javascript
|
||||
var o = ns;
|
||||
// returns {...}
|
||||
```
|
||||
|
||||
The namespace exports the following array constructors:
|
||||
|
||||
<!-- <toc pattern="+(int*|float*|uint*|*buffer)"> -->
|
||||
|
||||
<div class="namespace-toc">
|
||||
|
||||
- <span class="signature">[`ArrayBuffer( size )`][@stdlib/array/buffer]</span><span class="delimiter">: </span><span class="description">constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.</span>
|
||||
- <span class="signature">[`Float32Array()`][@stdlib/array/float32]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.</span>
|
||||
- <span class="signature">[`Float64Array()`][@stdlib/array/float64]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order.</span>
|
||||
- <span class="signature">[`Int16Array()`][@stdlib/array/int16]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order.</span>
|
||||
- <span class="signature">[`Int32Array()`][@stdlib/array/int32]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.</span>
|
||||
- <span class="signature">[`Int8Array()`][@stdlib/array/int8]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order.</span>
|
||||
- <span class="signature">[`SharedArrayBuffer( size )`][@stdlib/array/shared-buffer]</span><span class="delimiter">: </span><span class="description">constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory.</span>
|
||||
- <span class="signature">[`Uint16Array()`][@stdlib/array/uint16]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.</span>
|
||||
- <span class="signature">[`Uint32Array()`][@stdlib/array/uint32]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order.</span>
|
||||
- <span class="signature">[`Uint8Array()`][@stdlib/array/uint8]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order.</span>
|
||||
- <span class="signature">[`Uint8ClampedArray()`][@stdlib/array/uint8c]</span><span class="delimiter">: </span><span class="description">typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </toc> -->
|
||||
|
||||
```javascript
|
||||
var arr = new ns.Int32Array( 5 );
|
||||
// returns <Int32Array>[ 0, 0, 0, 0, 0 ]
|
||||
```
|
||||
|
||||
Alternatively, use the `typedarray` function to create a typed array of a given data type:
|
||||
|
||||
<!-- <toc pattern="typed"> -->
|
||||
|
||||
<div class="namespace-toc">
|
||||
|
||||
- <span class="signature">[`typedarray()`][@stdlib/array/typed]</span><span class="delimiter">: </span><span class="description">create a typed array.</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </toc> -->
|
||||
|
||||
```javascript
|
||||
var arr1 = ns.typedarray( 5 );
|
||||
// returns <Float64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0 ]
|
||||
|
||||
var arr2 = ns.typedarray( 5, 'uint8' );
|
||||
// returns <Uint8Array>[ 0, 0, 0, 0, 0 ]
|
||||
```
|
||||
|
||||
The namespace contains functions to create arrays pre-filled with spaced values:
|
||||
|
||||
<!-- <toc pattern="*space"> -->
|
||||
|
||||
<div class="namespace-toc">
|
||||
|
||||
- <span class="signature">[`datespace( start, stop[, length][, opts] )`][@stdlib/array/datespace]</span><span class="delimiter">: </span><span class="description">generate an array of linearly spaced dates.</span>
|
||||
- <span class="signature">[`incrspace( start, stop[, increment] )`][@stdlib/array/incrspace]</span><span class="delimiter">: </span><span class="description">generate a linearly spaced numeric array using a provided increment.</span>
|
||||
- <span class="signature">[`linspace( start, stop[, length] )`][@stdlib/array/linspace]</span><span class="delimiter">: </span><span class="description">generate a linearly spaced numeric array.</span>
|
||||
- <span class="signature">[`logspace( a, b[, length] )`][@stdlib/array/logspace]</span><span class="delimiter">: </span><span class="description">generate a logarithmically spaced numeric array.</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </toc> -->
|
||||
|
||||
You can use the following functions to retrieve a list of available data types:
|
||||
|
||||
<!-- <toc pattern="*dtypes"> -->
|
||||
|
||||
<div class="namespace-toc">
|
||||
|
||||
- <span class="signature">[`arrayDataTypes()`][@stdlib/array/dtypes]</span><span class="delimiter">: </span><span class="description">list of array data types.</span>
|
||||
- <span class="signature">[`typedarrayComplexDataTypes()`][@stdlib/array/typed-complex-dtypes]</span><span class="delimiter">: </span><span class="description">list of complex typed array data types.</span>
|
||||
- <span class="signature">[`typedarrayDataTypes()`][@stdlib/array/typed-dtypes]</span><span class="delimiter">: </span><span class="description">list of typed array data types.</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </toc> -->
|
||||
|
||||
```javascript
|
||||
var DTYPES = ns.arrayDataTypes();
|
||||
// returns [ 'float32', 'float64', 'generic', 'int16', 'int32', 'int8', 'uint16', 'uint32', 'uint8', 'uint8c' ]
|
||||
```
|
||||
|
||||
Furthermore, the namespace contains utility functions to retrieve a given constructor:
|
||||
|
||||
<!-- <toc keywords="+constructors,+constructor"> -->
|
||||
|
||||
<div class="namespace-toc">
|
||||
|
||||
- <span class="signature">[`arrayCtors( dtype )`][@stdlib/array/ctors]</span><span class="delimiter">: </span><span class="description">array constructors.</span>
|
||||
- <span class="signature">[`typedarrayComplexCtors( dtype )`][@stdlib/array/typed-complex-ctors]</span><span class="delimiter">: </span><span class="description">complex typed array constructors.</span>
|
||||
- <span class="signature">[`typedarrayCtors( dtype )`][@stdlib/array/typed-ctors]</span><span class="delimiter">: </span><span class="description">typed array constructors.</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </toc> -->
|
||||
|
||||
```javascript
|
||||
var ctor = ns.typedarrayCtors( 'float64' );
|
||||
// returns <Function>
|
||||
|
||||
ctor = ns.typedarrayCtors( 'int' );
|
||||
// returns null
|
||||
```
|
||||
|
||||
Lastly, the namespace contains various other functions for dealing with arrays, including functions to convert arrays from one data type to another or to serialize them as JSON and vice versa.
|
||||
|
||||
<!-- <toc ignore="+(int*|float*|uint*|*buffer)" ignore="typed" ignore="*dtypes" keywords="-constructors,-constructor"> -->
|
||||
|
||||
<div class="namespace-toc">
|
||||
|
||||
- <span class="signature">[`Complex128Array()`][@stdlib/array/complex128]</span><span class="delimiter">: </span><span class="description">128-bit complex number array.</span>
|
||||
- <span class="signature">[`Complex64Array()`][@stdlib/array/complex64]</span><span class="delimiter">: </span><span class="description">64-bit complex number array.</span>
|
||||
- <span class="signature">[`convertArraySame( x, y )`][@stdlib/array/convert-same]</span><span class="delimiter">: </span><span class="description">convert an array to the same data type as a second input array.</span>
|
||||
- <span class="signature">[`convertArray( arr, dtype )`][@stdlib/array/convert]</span><span class="delimiter">: </span><span class="description">convert an array to an array of a different data type.</span>
|
||||
- <span class="signature">[`DataView( buffer[, byteOffset[, byteLength]] )`][@stdlib/array/dataview]</span><span class="delimiter">: </span><span class="description">constructor which returns a data view representing a provided array buffer.</span>
|
||||
- <span class="signature">[`arrayDataType( array )`][@stdlib/array/dtype]</span><span class="delimiter">: </span><span class="description">return the data type of an array.</span>
|
||||
- <span class="signature">[`filledarray()`][@stdlib/array/filled]</span><span class="delimiter">: </span><span class="description">create a filled array.</span>
|
||||
- <span class="signature">[`iterator2array( iterator[, out][, mapFcn[, thisArg]] )`][@stdlib/array/from-iterator]</span><span class="delimiter">: </span><span class="description">create (or fill) an array from an iterator.</span>
|
||||
- <span class="signature">[`arrayMinDataType( value )`][@stdlib/array/min-dtype]</span><span class="delimiter">: </span><span class="description">determine the minimum array data type of the closest "kind" necessary for storing a provided scalar value.</span>
|
||||
- <span class="signature">[`arrayNextDataType( [dtype] )`][@stdlib/array/next-dtype]</span><span class="delimiter">: </span><span class="description">return the next larger array data type of the same kind.</span>
|
||||
- <span class="signature">[`typedarraypool()`][@stdlib/array/pool]</span><span class="delimiter">: </span><span class="description">allocate typed arrays from a typed array memory pool.</span>
|
||||
- <span class="signature">[`arrayPromotionRules( [dtype1, dtype2] )`][@stdlib/array/promotion-rules]</span><span class="delimiter">: </span><span class="description">return the array data type with the smallest size and closest "kind" to which array data types can be **safely** cast.</span>
|
||||
- <span class="signature">[`reviveTypedArray( key, value )`][@stdlib/array/reviver]</span><span class="delimiter">: </span><span class="description">revive a JSON-serialized typed array.</span>
|
||||
- <span class="signature">[`arraySafeCasts( [dtype] )`][@stdlib/array/safe-casts]</span><span class="delimiter">: </span><span class="description">return a list of array data types to which a provided array data type can be safely cast.</span>
|
||||
- <span class="signature">[`arraySameKindCasts( [dtype] )`][@stdlib/array/same-kind-casts]</span><span class="delimiter">: </span><span class="description">return a list of array data types to which a provided array data type can be safely cast or cast within the same "kind".</span>
|
||||
- <span class="signature">[`arrayShape( arr )`][@stdlib/array/shape]</span><span class="delimiter">: </span><span class="description">determine (nested) array dimensions.</span>
|
||||
- <span class="signature">[`circarray2iterator( src[, options][, mapFcn[, thisArg]] )`][@stdlib/array/to-circular-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator which repeatedly iterates over the elements of an array-like object.</span>
|
||||
- <span class="signature">[`array2iteratorRight( src[, mapFcn[, thisArg]] )`][@stdlib/array/to-iterator-right]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object, iterating from right to left.</span>
|
||||
- <span class="signature">[`array2iterator( src[, mapFcn[, thisArg]] )`][@stdlib/array/to-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object.</span>
|
||||
- <span class="signature">[`typedarray2json( typedarray )`][@stdlib/array/to-json]</span><span class="delimiter">: </span><span class="description">return a JSON representation of a typed array.</span>
|
||||
- <span class="signature">[`sparsearray2iteratorRight( src[, mapFcn[, thisArg]] )`][@stdlib/array/to-sparse-iterator-right]</span><span class="delimiter">: </span><span class="description">create an iterator from a sparse array-like object, iterating from right to left.</span>
|
||||
- <span class="signature">[`sparsearray2iterator( src[, mapFcn[, thisArg]] )`][@stdlib/array/to-sparse-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from a sparse array-like object.</span>
|
||||
- <span class="signature">[`stridedarray2iterator( N, src, stride, offset[, mapFcn[, thisArg]] )`][@stdlib/array/to-strided-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from a strided array-like object.</span>
|
||||
- <span class="signature">[`arrayview2iteratorRight( src[, begin[, end]][, mapFcn[, thisArg]] )`][@stdlib/array/to-view-iterator-right]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object view, iterating from right to left.</span>
|
||||
- <span class="signature">[`arrayview2iterator( src[, begin[, end]][, mapFcn[, thisArg]] )`][@stdlib/array/to-view-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object view.</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </toc> -->
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- TODO: better examples -->
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var objectKeys = require( '@stdlib/utils/keys' );
|
||||
var ns = require( '@stdlib/array' );
|
||||
|
||||
console.log( objectKeys( ns ) );
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
|
||||
<section class="main-repo" >
|
||||
|
||||
* * *
|
||||
|
||||
## Notice
|
||||
|
||||
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.
|
||||
|
||||
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].
|
||||
|
||||
#### Community
|
||||
|
||||
[![Chat][chat-image]][chat-url]
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
See [LICENSE][stdlib-license].
|
||||
|
||||
|
||||
## Copyright
|
||||
|
||||
Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.stdlib -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
[npm-image]: http://img.shields.io/npm/v/@stdlib/array.svg
|
||||
[npm-url]: https://npmjs.org/package/@stdlib/array
|
||||
|
||||
[test-image]: https://github.com/stdlib-js/array/actions/workflows/test.yml/badge.svg
|
||||
[test-url]: https://github.com/stdlib-js/array/actions/workflows/test.yml
|
||||
|
||||
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array/main.svg
|
||||
[coverage-url]: https://codecov.io/github/stdlib-js/array?branch=main
|
||||
|
||||
[dependencies-image]: https://img.shields.io/david/stdlib-js/array.svg
|
||||
[dependencies-url]: https://david-dm.org/stdlib-js/array/main
|
||||
|
||||
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
||||
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
||||
|
||||
[stdlib]: https://github.com/stdlib-js/stdlib
|
||||
|
||||
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
||||
|
||||
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array/main/LICENSE
|
||||
|
||||
<!-- <toc-links> -->
|
||||
|
||||
[@stdlib/array/complex128]: https://www.npmjs.com/package/@stdlib/array/tree/main/complex128
|
||||
|
||||
[@stdlib/array/complex64]: https://www.npmjs.com/package/@stdlib/array/tree/main/complex64
|
||||
|
||||
[@stdlib/array/convert-same]: https://www.npmjs.com/package/@stdlib/array/tree/main/convert-same
|
||||
|
||||
[@stdlib/array/convert]: https://www.npmjs.com/package/@stdlib/array/tree/main/convert
|
||||
|
||||
[@stdlib/array/dataview]: https://www.npmjs.com/package/@stdlib/array/tree/main/dataview
|
||||
|
||||
[@stdlib/array/dtype]: https://www.npmjs.com/package/@stdlib/array/tree/main/dtype
|
||||
|
||||
[@stdlib/array/filled]: https://www.npmjs.com/package/@stdlib/array/tree/main/filled
|
||||
|
||||
[@stdlib/array/from-iterator]: https://www.npmjs.com/package/@stdlib/array/tree/main/from-iterator
|
||||
|
||||
[@stdlib/array/min-dtype]: https://www.npmjs.com/package/@stdlib/array/tree/main/min-dtype
|
||||
|
||||
[@stdlib/array/next-dtype]: https://www.npmjs.com/package/@stdlib/array/tree/main/next-dtype
|
||||
|
||||
[@stdlib/array/pool]: https://www.npmjs.com/package/@stdlib/array/tree/main/pool
|
||||
|
||||
[@stdlib/array/promotion-rules]: https://www.npmjs.com/package/@stdlib/array/tree/main/promotion-rules
|
||||
|
||||
[@stdlib/array/reviver]: https://www.npmjs.com/package/@stdlib/array/tree/main/reviver
|
||||
|
||||
[@stdlib/array/safe-casts]: https://www.npmjs.com/package/@stdlib/array/tree/main/safe-casts
|
||||
|
||||
[@stdlib/array/same-kind-casts]: https://www.npmjs.com/package/@stdlib/array/tree/main/same-kind-casts
|
||||
|
||||
[@stdlib/array/shape]: https://www.npmjs.com/package/@stdlib/array/tree/main/shape
|
||||
|
||||
[@stdlib/array/to-circular-iterator]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-circular-iterator
|
||||
|
||||
[@stdlib/array/to-iterator-right]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-iterator-right
|
||||
|
||||
[@stdlib/array/to-iterator]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-iterator
|
||||
|
||||
[@stdlib/array/to-json]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-json
|
||||
|
||||
[@stdlib/array/to-sparse-iterator-right]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-sparse-iterator-right
|
||||
|
||||
[@stdlib/array/to-sparse-iterator]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-sparse-iterator
|
||||
|
||||
[@stdlib/array/to-strided-iterator]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-strided-iterator
|
||||
|
||||
[@stdlib/array/to-view-iterator-right]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-view-iterator-right
|
||||
|
||||
[@stdlib/array/to-view-iterator]: https://www.npmjs.com/package/@stdlib/array/tree/main/to-view-iterator
|
||||
|
||||
[@stdlib/array/ctors]: https://www.npmjs.com/package/@stdlib/array/tree/main/ctors
|
||||
|
||||
[@stdlib/array/typed-complex-ctors]: https://www.npmjs.com/package/@stdlib/array/tree/main/typed-complex-ctors
|
||||
|
||||
[@stdlib/array/typed-ctors]: https://www.npmjs.com/package/@stdlib/array/tree/main/typed-ctors
|
||||
|
||||
[@stdlib/array/dtypes]: https://www.npmjs.com/package/@stdlib/array/tree/main/dtypes
|
||||
|
||||
[@stdlib/array/typed-complex-dtypes]: https://www.npmjs.com/package/@stdlib/array/tree/main/typed-complex-dtypes
|
||||
|
||||
[@stdlib/array/typed-dtypes]: https://www.npmjs.com/package/@stdlib/array/tree/main/typed-dtypes
|
||||
|
||||
[@stdlib/array/datespace]: https://www.npmjs.com/package/@stdlib/array/tree/main/datespace
|
||||
|
||||
[@stdlib/array/incrspace]: https://www.npmjs.com/package/@stdlib/array/tree/main/incrspace
|
||||
|
||||
[@stdlib/array/linspace]: https://www.npmjs.com/package/@stdlib/array/tree/main/linspace
|
||||
|
||||
[@stdlib/array/logspace]: https://www.npmjs.com/package/@stdlib/array/tree/main/logspace
|
||||
|
||||
[@stdlib/array/typed]: https://www.npmjs.com/package/@stdlib/array/tree/main/typed
|
||||
|
||||
[@stdlib/array/buffer]: https://www.npmjs.com/package/@stdlib/array/tree/main/buffer
|
||||
|
||||
[@stdlib/array/float32]: https://www.npmjs.com/package/@stdlib/array/tree/main/float32
|
||||
|
||||
[@stdlib/array/float64]: https://www.npmjs.com/package/@stdlib/array/tree/main/float64
|
||||
|
||||
[@stdlib/array/int16]: https://www.npmjs.com/package/@stdlib/array/tree/main/int16
|
||||
|
||||
[@stdlib/array/int32]: https://www.npmjs.com/package/@stdlib/array/tree/main/int32
|
||||
|
||||
[@stdlib/array/int8]: https://www.npmjs.com/package/@stdlib/array/tree/main/int8
|
||||
|
||||
[@stdlib/array/shared-buffer]: https://www.npmjs.com/package/@stdlib/array/tree/main/shared-buffer
|
||||
|
||||
[@stdlib/array/uint16]: https://www.npmjs.com/package/@stdlib/array/tree/main/uint16
|
||||
|
||||
[@stdlib/array/uint32]: https://www.npmjs.com/package/@stdlib/array/tree/main/uint32
|
||||
|
||||
[@stdlib/array/uint8]: https://www.npmjs.com/package/@stdlib/array/tree/main/uint8
|
||||
|
||||
[@stdlib/array/uint8c]: https://www.npmjs.com/package/@stdlib/array/tree/main/uint8c
|
||||
|
||||
<!-- </toc-links> -->
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
235
js/node_modules/@stdlib/array/buffer/README.md
generated
vendored
Normal file
235
js/node_modules/@stdlib/array/buffer/README.md
generated
vendored
Normal file
|
@ -0,0 +1,235 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2018 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# ArrayBuffer
|
||||
|
||||
> [Constructor][mdn-arraybuffer] which returns an object used to represent a generic, fixed-length raw binary data buffer.
|
||||
|
||||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="intro">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.intro -->
|
||||
|
||||
<!-- Package usage documentation. -->
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
```
|
||||
|
||||
#### ArrayBuffer( size )
|
||||
|
||||
Returns an [`ArrayBuffer`][mdn-arraybuffer] having a specified number of bytes.
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var buf = new ArrayBuffer( 5 );
|
||||
// returns <ArrayBuffer>
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
### Properties
|
||||
|
||||
#### ArrayBuffer.length
|
||||
|
||||
Number of input arguments the constructor accepts.
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var len = ArrayBuffer.length;
|
||||
// returns 1
|
||||
```
|
||||
|
||||
#### ArrayBuffer.prototype.byteLength
|
||||
|
||||
**Read-only** property which returns the length (in bytes) of the [`ArrayBuffer`][mdn-arraybuffer].
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var buf = new ArrayBuffer( 5 );
|
||||
var byteLength = buf.byteLength;
|
||||
// returns 5
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
### Methods
|
||||
|
||||
#### ArrayBuffer.isView( arr )
|
||||
|
||||
Static method which returns a `boolean` indicating if provided a buffer view.
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var Float64Array = require( '@stdlib/array/float64' );
|
||||
var view = new Float64Array( 10 );
|
||||
|
||||
var bool = ArrayBuffer.isView( view );
|
||||
// returns true
|
||||
```
|
||||
|
||||
#### ArrayBuffer.prototype.slice( \[start\[, end]] )
|
||||
|
||||
Copies the bytes of an `ArrayBuffer` to a new [`ArrayBuffer`][mdn-arraybuffer].
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var b1 = new ArrayBuffer( 10 );
|
||||
|
||||
var b2 = b1.slice();
|
||||
// returns <ArrayBuffer>
|
||||
|
||||
var bool = ( b2 === b1 );
|
||||
// returns false
|
||||
```
|
||||
|
||||
By default, the method copies from the beginning of the [`ArrayBuffer`][mdn-arraybuffer]. To beginning copying from a different byte index, provide a `start` argument, specifying the starting byte index (inclusive).
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var b1 = new ArrayBuffer( 10 );
|
||||
var b2 = b1.slice( 2 );
|
||||
|
||||
var nbytes = b2.byteLength;
|
||||
// returns 8
|
||||
```
|
||||
|
||||
If `start < 0`, the index is relative to the end of the [`ArrayBuffer`][mdn-arraybuffer].
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var b1 = new ArrayBuffer( 10 );
|
||||
var b2 = b1.slice( -2 );
|
||||
|
||||
var nbytes = b2.byteLength;
|
||||
// returns 2
|
||||
```
|
||||
|
||||
By default, the method copies to the end of the [`ArrayBuffer`][mdn-arraybuffer]. To copy until a particular byte index, provide an `end` index, specifying the ending byte index (exclusive).
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var b1 = new ArrayBuffer( 10 );
|
||||
var b2 = b1.slice( 2, 6 );
|
||||
|
||||
var nbytes = b2.byteLength;
|
||||
// returns 4
|
||||
```
|
||||
|
||||
If `end < 0`, the index is relative to the end of the [`ArrayBuffer`][mdn-arraybuffer].
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var b1 = new ArrayBuffer( 10 );
|
||||
var b2 = b1.slice( 2, -2 );
|
||||
|
||||
var nbytes = b2.byteLength;
|
||||
// returns 6
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
* * *
|
||||
|
||||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<!-- Package usage examples. -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var randu = require( '@stdlib/random/base/randu' );
|
||||
var Float64Array = require( '@stdlib/array/float64' );
|
||||
var Uint8Array = require( '@stdlib/array/uint8' );
|
||||
var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' );
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
|
||||
var bytes;
|
||||
var buf;
|
||||
var arr;
|
||||
var i;
|
||||
|
||||
// Create a new ArrayBuffer:
|
||||
buf = new ArrayBuffer( 64 );
|
||||
|
||||
// Create a Float64 array buffer view:
|
||||
arr = new Float64Array( buf.byteLength/8 );
|
||||
for ( i = 0; i < arr.length; i++ ) {
|
||||
arr[ i ] = randu() * 100.0;
|
||||
}
|
||||
|
||||
// Create a "bytes" view of the array buffer:
|
||||
bytes = new Uint8Array( arr.buffer );
|
||||
|
||||
// Print the bytes:
|
||||
for ( i = 0; i < bytes.length; i++ ) {
|
||||
console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) );
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="references">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.references -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
[mdn-arraybuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
92
js/node_modules/@stdlib/array/buffer/docs/repl.txt
generated
vendored
Normal file
92
js/node_modules/@stdlib/array/buffer/docs/repl.txt
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
|
||||
{{alias}}( size )
|
||||
Returns an array buffer having a specified number of bytes.
|
||||
|
||||
Buffer contents are initialized to 0.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
size: integer
|
||||
Number of bytes.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out: ArrayBuffer
|
||||
An array buffer.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var buf = new {{alias}}( 5 )
|
||||
<ArrayBuffer>
|
||||
|
||||
|
||||
{{alias}}.length
|
||||
Number of input arguments the constructor accepts.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> {{alias}}.length
|
||||
1
|
||||
|
||||
|
||||
{{alias}}.isView( arr )
|
||||
Returns a boolean indicating if provided an array buffer view.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
arr: any
|
||||
Value to test.
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool: boolean
|
||||
Boolean indicating if an input argument is a buffer view.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var arr = new {{alias:@stdlib/array/float64}}( 10 );
|
||||
> {{alias}}.isView( arr )
|
||||
true
|
||||
|
||||
|
||||
{{alias}}.prototype.byteLength
|
||||
Read-only property which returns the length (in bytes) of the array buffer.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var buf = new {{alias}}( 5 );
|
||||
> buf.byteLength
|
||||
5
|
||||
|
||||
|
||||
{{alias}}.prototype.slice( [start[, end]] )
|
||||
Copies the bytes of an array buffer to a new array buffer.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start: integer (optional)
|
||||
Index at which to start copying buffer contents (inclusive). If
|
||||
negative, the index is relative to the end of the buffer.
|
||||
|
||||
end: integer (optional)
|
||||
Index at which to stop copying buffer contents (exclusive). If negative,
|
||||
the index is relative to the end of the buffer.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out: ArrayBuffer
|
||||
A new array buffer whose contents have been copied from the calling
|
||||
array buffer.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var b1 = new {{alias}}( 10 );
|
||||
> var b2 = b1.slice( 2, 6 );
|
||||
> var bool = ( b1 === b2 )
|
||||
false
|
||||
> b2.byteLength
|
||||
4
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
26
js/node_modules/@stdlib/array/buffer/docs/types/index.d.ts
generated
vendored
Normal file
26
js/node_modules/@stdlib/array/buffer/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
/**
|
||||
* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.
|
||||
*/
|
||||
export = ArrayBuffer;
|
35
js/node_modules/@stdlib/array/buffer/docs/types/test.ts
generated
vendored
Normal file
35
js/node_modules/@stdlib/array/buffer/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// tslint:disable: no-construct
|
||||
// tslint:disable: no-unused-expression
|
||||
|
||||
import ArrayBuffer = require( './index' );
|
||||
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns a data view instance...
|
||||
{
|
||||
new ArrayBuffer( 5 ); // $ExpectType ArrayBuffer
|
||||
}
|
||||
|
||||
// The constructor function has to be invoked with `new`...
|
||||
{
|
||||
ArrayBuffer( 5 ); // $ExpectError
|
||||
}
|
28
js/node_modules/@stdlib/array/buffer/lib/arraybuffer.js
generated
vendored
Normal file
28
js/node_modules/@stdlib/array/buffer/lib/arraybuffer.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MAIN //
|
||||
|
||||
var ctor = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : void 0; // eslint-disable-line stdlib/require-globals
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = ctor;
|
52
js/node_modules/@stdlib/array/buffer/lib/index.js
generated
vendored
Normal file
52
js/node_modules/@stdlib/array/buffer/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.
|
||||
*
|
||||
* @module @stdlib/array/buffer
|
||||
*
|
||||
* @example
|
||||
* var ctor = require( '@stdlib/array/buffer' );
|
||||
*
|
||||
* var buf = new ctor( 10 );
|
||||
* // returns <ArrayBuffer>
|
||||
*/
|
||||
|
||||
// MODULES //
|
||||
|
||||
var hasArrayBufferSupport = require( '@stdlib/assert/has-arraybuffer-support' );
|
||||
var builtin = require( './arraybuffer.js' );
|
||||
var polyfill = require( './polyfill.js' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
var ctor;
|
||||
if ( hasArrayBufferSupport() ) {
|
||||
ctor = builtin;
|
||||
} else {
|
||||
ctor = polyfill;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = ctor;
|
37
js/node_modules/@stdlib/array/buffer/lib/polyfill.js
generated
vendored
Normal file
37
js/node_modules/@stdlib/array/buffer/lib/polyfill.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// TODO: write polyfill
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.
|
||||
*
|
||||
* @throws {Error} not implemented
|
||||
*/
|
||||
function polyfill() {
|
||||
throw new Error( 'not implemented' );
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = polyfill;
|
66
js/node_modules/@stdlib/array/buffer/package.json
generated
vendored
Normal file
66
js/node_modules/@stdlib/array/buffer/package.json
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"name": "@stdlib/array/buffer",
|
||||
"version": "0.0.0",
|
||||
"description": "ArrayBuffer.",
|
||||
"license": "Apache-2.0",
|
||||
"author": {
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"directories": {
|
||||
"benchmark": "./benchmark",
|
||||
"doc": "./docs",
|
||||
"example": "./examples",
|
||||
"lib": "./lib",
|
||||
"test": "./test"
|
||||
},
|
||||
"types": "./docs/types",
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/stdlib-js/stdlib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stdlib-js/stdlib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stdlib-js/stdlib/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.10.0",
|
||||
"npm": ">2.7.0"
|
||||
},
|
||||
"os": [
|
||||
"aix",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"macos",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32",
|
||||
"windows"
|
||||
],
|
||||
"keywords": [
|
||||
"stdlib",
|
||||
"stdtypes",
|
||||
"types",
|
||||
"data",
|
||||
"structure",
|
||||
"array",
|
||||
"typed",
|
||||
"typed array",
|
||||
"typed-array",
|
||||
"arraybuffer",
|
||||
"buffer",
|
||||
"buf",
|
||||
"binary"
|
||||
]
|
||||
}
|
127
js/node_modules/@stdlib/array/complex128/README.md
generated
vendored
Normal file
127
js/node_modules/@stdlib/array/complex128/README.md
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2021 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# Complex128Array
|
||||
|
||||
> 128-bit complex number array.
|
||||
|
||||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="intro">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.intro -->
|
||||
|
||||
<!-- Package usage documentation. -->
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
```
|
||||
|
||||
<a name="constructor"></a>
|
||||
|
||||
#### Complex128Array()
|
||||
|
||||
Creates a 128-bit complex number array.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex128Array();
|
||||
// returns <Complex128Array>
|
||||
```
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<!-- Package usage examples. -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
* * *
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var Complex128 = require( '@stdlib/complex/float64' );
|
||||
var Float64Array = require( '@stdlib/array/float64' );
|
||||
var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
|
||||
var arr;
|
||||
var out;
|
||||
|
||||
// Create a complex array by specifying a length:
|
||||
out = new Complex128Array( 3 );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an array of complex numbers:
|
||||
arr = [
|
||||
new Complex128( 1.0, -1.0 ),
|
||||
new Complex128( -3.14, 3.14 ),
|
||||
new Complex128( 0.5, 0.5 )
|
||||
];
|
||||
out = new Complex128Array( arr );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an interleaved typed array:
|
||||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
|
||||
out = new Complex128Array( arr );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an array buffer:
|
||||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
|
||||
out = new Complex128Array( arr.buffer );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an array buffer view:
|
||||
arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
|
||||
out = new Complex128Array( arr.buffer, 16, 2 );
|
||||
console.log( out );
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="references">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.references -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
538
js/node_modules/@stdlib/array/complex128/docs/types/index.d.ts
generated
vendored
Normal file
538
js/node_modules/@stdlib/array/complex128/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,538 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
/// <reference types="@stdlib/types"/>
|
||||
|
||||
import { ArrayLike, TypedArray } from '@stdlib/types/array';
|
||||
import { ComplexLike } from '@stdlib/types/object';
|
||||
import ArrayBuffer = require( './../../../buffer' );
|
||||
import Complex128 = require( '@stdlib/complex/float64' );
|
||||
|
||||
/**
|
||||
* Class for creating a 128-bit complex number array.
|
||||
*/
|
||||
declare class Complex128Array {
|
||||
/**
|
||||
* 128-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array();
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf, 8 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf, 8, 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
constructor( arg?: number | TypedArray | ArrayLike<number | ComplexLike> | ArrayBuffer | Iterable<number | ComplexLike>, byteOffset?: number, length?: number ); // tslint:disable-line:max-line-length
|
||||
|
||||
/**
|
||||
* Length (in bytes) of the array.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var byteLength = arr.byteLength;
|
||||
* // returns 160
|
||||
*/
|
||||
readonly byteLength: number;
|
||||
|
||||
/**
|
||||
* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var byteOffset = arr.byteOffset;
|
||||
* // returns 0
|
||||
*/
|
||||
readonly byteOffset: number;
|
||||
|
||||
/**
|
||||
* Size (in bytes) of each array element.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var nbytes = arr.BYTES_PER_ELEMENT;
|
||||
* // returns 16
|
||||
*/
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/**
|
||||
* Number of array elements.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 10
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Returns an array element.
|
||||
*
|
||||
* @param i - element index
|
||||
* @throws index argument must be a nonnegative integer
|
||||
* @returns array element
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex128>
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( 100 );
|
||||
* // returns undefined
|
||||
*/
|
||||
get( i: number ): Complex128 | void;
|
||||
|
||||
/**
|
||||
* Returns an array element.
|
||||
*
|
||||
* @param out - output array
|
||||
* @param i - element index
|
||||
* @throws index argument must be a nonnegative integer
|
||||
* @returns array element
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex128>
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( [ 0.0, 0.0 ], 0 );
|
||||
* // returns [ 1.0, -1.0 ]
|
||||
*/
|
||||
get( out: ArrayLike<number>, i: number ): ArrayLike<number> | void;
|
||||
|
||||
/**
|
||||
* Sets an array element.
|
||||
*
|
||||
* ## Notes
|
||||
*
|
||||
* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:
|
||||
*
|
||||
* ```text
|
||||
* buf: ---------------------
|
||||
* src: ---------------------
|
||||
* ```
|
||||
*
|
||||
* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.
|
||||
*
|
||||
* In the other overlapping scenario,
|
||||
*
|
||||
* ```text
|
||||
* buf: ---------------------
|
||||
* src: ---------------------
|
||||
* ```
|
||||
*
|
||||
* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended.
|
||||
*
|
||||
*
|
||||
* @param value - value(s)
|
||||
* @param i - element index at which to start writing values (default: 0)
|
||||
* @throws index argument must be a nonnegative integer
|
||||
* @throws array-like objects must have a length which is a multiple of two
|
||||
* @throws index argument is out-of-bounds
|
||||
* @throws target array lacks sufficient storage to accommodate source values
|
||||
*
|
||||
* @example
|
||||
* var real = require( `@stdlib/complex/real` );
|
||||
* var imag = require( `@stdlib/complex/imag` );
|
||||
*
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex128>
|
||||
*
|
||||
* var re = real( z );
|
||||
* // returns 0.0
|
||||
*
|
||||
* var im = imag( z );
|
||||
* // returns 0.0
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( 0 );
|
||||
* // returns <Complex128>
|
||||
*
|
||||
* re = real( z );
|
||||
* // returns 1.0
|
||||
*
|
||||
* im = imag( z );
|
||||
* // returns -1.0
|
||||
*/
|
||||
set( value: ArrayLike<number | ComplexLike> | Complex128Array | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface defining a 128-bit complex number array constructor which is both "newable" and "callable".
|
||||
*/
|
||||
interface Constructor {
|
||||
/**
|
||||
* 128-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array();
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf, 8 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf, 8, 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
new( arg?: number | TypedArray | ArrayLike<number | ComplexLike> | ArrayBuffer | Iterable<number | ComplexLike>, byteOffset?: number, length?: number ): Complex128Array; // tslint-disable-line max-line-length
|
||||
|
||||
/**
|
||||
* 128-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array();
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf, 8 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf, 8, 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
( arg?: number | TypedArray | ArrayLike<number | ComplexLike> | ArrayBuffer | Iterable<number | ComplexLike>, byteOffset?: number, length?: number ): Complex128Array; // tslint-disable-line max-line-length
|
||||
|
||||
/**
|
||||
* Constructor name.
|
||||
*
|
||||
* @example
|
||||
* var str = Complex128Array.name;
|
||||
* // returns 'Complex128Array'
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* Size (in bytes) of each array element.
|
||||
*
|
||||
* @example
|
||||
* var nbytes = Complex128Array.BYTES_PER_ELEMENT;
|
||||
* // returns 16
|
||||
*/
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/**
|
||||
* Creates a new 128-bit complex number array from an array-like object or an iterable.
|
||||
*
|
||||
* @param src - array-like object or iterable
|
||||
* @param clbk - callback to invoke for each source element
|
||||
* @param thisArg - context
|
||||
* @throws array-like objects must have a length which is a multiple of two
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @throws when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns 128-bit complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = Complex128Array.from( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var Complex128 = require( `@stdlib/complex/float64` );
|
||||
*
|
||||
* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var Complex128 = require( `@stdlib/complex/float64` );
|
||||
* var real = require( `@stdlib/complex/real` );
|
||||
* var imag = require( `@stdlib/complex/imag` );
|
||||
*
|
||||
* function clbk( v ) {
|
||||
* return new Complex128( real(v)*2.0, imag(v)*2.0 );
|
||||
* }
|
||||
*
|
||||
* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*/
|
||||
from( src: ArrayLike<number | ComplexLike> | Iterable<number | ComplexLike>, clbk?: Function, thisArg?: any ): Complex128Array; // tslint:disable-line:max-line-length
|
||||
|
||||
/**
|
||||
* Creates a new 128-bit complex number array from a variable number of arguments.
|
||||
*
|
||||
* @param element - array elements
|
||||
* @returns 128-bit complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
of( ...elements: Array<number> ): Complex128Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* 128-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array();
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex128Array( buf, 8 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf, 8, 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
declare var ctor: Constructor;
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
export = ctor;
|
153
js/node_modules/@stdlib/array/complex128/docs/types/test.ts
generated
vendored
Normal file
153
js/node_modules/@stdlib/array/complex128/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// tslint:disable:no-unused-expression
|
||||
|
||||
import Complex128Array = require( './index' );
|
||||
import Complex128 = require( '@stdlib/complex/float64' );
|
||||
import ArrayBuffer = require( './../../../buffer' );
|
||||
import real = require( '@stdlib/complex/real' );
|
||||
import imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
const clbk = ( v: Complex128 ) => {
|
||||
return new Complex128( real( v ) * 2.0, imag( v ) * 2.0 );
|
||||
};
|
||||
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns a complex number array...
|
||||
{
|
||||
new Complex128Array(); // $ExpectType Complex128Array
|
||||
Complex128Array(); // $ExpectType Complex128Array
|
||||
new Complex128Array( 2 ); // $ExpectType Complex128Array
|
||||
Complex128Array( 2 ); // $ExpectType Complex128Array
|
||||
new Complex128Array( [ 1.0, -1.0 ] ); // $ExpectType Complex128Array
|
||||
Complex128Array( [ 1.0, -1.0 ] ); // $ExpectType Complex128Array
|
||||
|
||||
const buf = new ArrayBuffer( 16 );
|
||||
new Complex128Array( buf ); // $ExpectType Complex128Array
|
||||
Complex128Array( buf ); // $ExpectType Complex128Array
|
||||
new Complex128Array( buf, 8 ); // $ExpectType Complex128Array
|
||||
Complex128Array( buf, 8 ); // $ExpectType Complex128Array
|
||||
new Complex128Array( buf, 8, 2 ); // $ExpectType Complex128Array
|
||||
Complex128Array( buf, 8, 2 ); // $ExpectType Complex128Array
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer...
|
||||
{
|
||||
new Complex128Array( true ); // $ExpectError
|
||||
new Complex128Array( false ); // $ExpectError
|
||||
new Complex128Array( null ); // $ExpectError
|
||||
new Complex128Array( 'abc' ); // $ExpectError
|
||||
new Complex128Array( {} ); // $ExpectError
|
||||
new Complex128Array( ( x: number ): number => x ); // $ExpectError
|
||||
|
||||
Complex128Array( true ); // $ExpectError
|
||||
Complex128Array( false ); // $ExpectError
|
||||
Complex128Array( null ); // $ExpectError
|
||||
Complex128Array( 'abc' ); // $ExpectError
|
||||
Complex128Array( {} ); // $ExpectError
|
||||
Complex128Array( ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a second argument that is not a number...
|
||||
{
|
||||
const buf = new ArrayBuffer( 16 );
|
||||
new Complex128Array( buf, true ); // $ExpectError
|
||||
new Complex128Array( buf, false ); // $ExpectError
|
||||
new Complex128Array( buf, null ); // $ExpectError
|
||||
new Complex128Array( buf, 'abc' ); // $ExpectError
|
||||
new Complex128Array( buf, {} ); // $ExpectError
|
||||
new Complex128Array( buf, ( x: number ): number => x ); // $ExpectError
|
||||
|
||||
Complex128Array( buf, true ); // $ExpectError
|
||||
Complex128Array( buf, false ); // $ExpectError
|
||||
Complex128Array( buf, null ); // $ExpectError
|
||||
Complex128Array( buf, 'abc' ); // $ExpectError
|
||||
Complex128Array( buf, {} ); // $ExpectError
|
||||
Complex128Array( buf, ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a third argument that is not a number...
|
||||
{
|
||||
const buf = new ArrayBuffer( 16 );
|
||||
new Complex128Array( buf, 8, true ); // $ExpectError
|
||||
new Complex128Array( buf, 8, false ); // $ExpectError
|
||||
new Complex128Array( buf, 8, null ); // $ExpectError
|
||||
new Complex128Array( buf, 8, 'abc' ); // $ExpectError
|
||||
new Complex128Array( buf, 8, {} ); // $ExpectError
|
||||
new Complex128Array( buf, 8, ( x: number ): number => x ); // $ExpectError
|
||||
|
||||
Complex128Array( buf, 8, true ); // $ExpectError
|
||||
Complex128Array( buf, 8, false ); // $ExpectError
|
||||
Complex128Array( buf, 8, null ); // $ExpectError
|
||||
Complex128Array( buf, 8, 'abc' ); // $ExpectError
|
||||
Complex128Array( buf, 8, {} ); // $ExpectError
|
||||
Complex128Array( buf, 8, ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The `from` method returns a complex number array...
|
||||
{
|
||||
Complex128Array.from( [ 1.0, 1.0 ] ); // $ExpectType Complex128Array
|
||||
Complex128Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Complex128Array
|
||||
Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk, {} ); // $ExpectType Complex128Array
|
||||
}
|
||||
|
||||
// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable...
|
||||
{
|
||||
Complex128Array.from( true ); // $ExpectError
|
||||
Complex128Array.from( false ); // $ExpectError
|
||||
Complex128Array.from( 123 ); // $ExpectError
|
||||
Complex128Array.from( null ); // $ExpectError
|
||||
Complex128Array.from( {} ); // $ExpectError
|
||||
|
||||
Complex128Array.from( true, clbk ); // $ExpectError
|
||||
Complex128Array.from( false, clbk ); // $ExpectError
|
||||
Complex128Array.from( 123, clbk ); // $ExpectError
|
||||
Complex128Array.from( null, clbk ); // $ExpectError
|
||||
Complex128Array.from( {}, clbk ); // $ExpectError
|
||||
|
||||
Complex128Array.from( true, clbk, {} ); // $ExpectError
|
||||
Complex128Array.from( false, clbk, {} ); // $ExpectError
|
||||
Complex128Array.from( 123, clbk, {} ); // $ExpectError
|
||||
Complex128Array.from( null, clbk, {} ); // $ExpectError
|
||||
Complex128Array.from( {}, clbk, {} ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature...
|
||||
{
|
||||
Complex128Array.from( [ 1, 1 ], true ); // $ExpectError
|
||||
Complex128Array.from( [ 1, 1 ], false ); // $ExpectError
|
||||
Complex128Array.from( [ 1, 1 ], 123 ); // $ExpectError
|
||||
Complex128Array.from( [ 1, 1 ], null ); // $ExpectError
|
||||
Complex128Array.from( [ 1, 1 ], {} ); // $ExpectError
|
||||
}
|
||||
|
||||
// The `of` method returns a complex number array...
|
||||
{
|
||||
Complex128Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Complex128Array
|
||||
}
|
||||
|
||||
// The compiler throws an error if the `of` method is provided arguments that are not numbers...
|
||||
{
|
||||
Complex128Array.of( 'abc', 'def' ); // $ExpectError
|
||||
Complex128Array.of( true, false ); // $ExpectError
|
||||
Complex128Array.of( {}, [] ); // $ExpectError
|
||||
Complex128Array.of( null, null ); // $ExpectError
|
||||
}
|
61
js/node_modules/@stdlib/array/complex128/lib/from_array.js
generated
vendored
Normal file
61
js/node_modules/@stdlib/array/complex128/lib/from_array.js
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Returns a strided array of real and imaginary components.
|
||||
*
|
||||
* @private
|
||||
* @param {Float64Array} buf - output array
|
||||
* @param {Array} arr - array containing complex numbers
|
||||
* @returns {(Float64Array|null)} output array or null
|
||||
*/
|
||||
function fromArray( buf, arr ) {
|
||||
var len;
|
||||
var v;
|
||||
var i;
|
||||
var j;
|
||||
|
||||
len = arr.length;
|
||||
j = 0;
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
v = arr[ i ];
|
||||
if ( !isComplexLike( v ) ) {
|
||||
return null;
|
||||
}
|
||||
buf[ j ] = real( v );
|
||||
buf[ j+1 ] = imag( v );
|
||||
j += 2; // stride
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = fromArray;
|
64
js/node_modules/@stdlib/array/complex128/lib/from_iterator.js
generated
vendored
Normal file
64
js/node_modules/@stdlib/array/complex128/lib/from_iterator.js
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' );
|
||||
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Returns an array of iterated values.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} it - iterator
|
||||
* @returns {(Array|TypeError)} array or an error
|
||||
*/
|
||||
function fromIterator( it ) {
|
||||
var out;
|
||||
var v;
|
||||
|
||||
out = [];
|
||||
while ( true ) {
|
||||
v = it.next();
|
||||
if ( v.value ) {
|
||||
if ( isArrayLikeObject( v.value ) ) {
|
||||
out.push( v.value[0], v.value[1] );
|
||||
} else if ( isComplexLike( v.value ) ) {
|
||||
out.push( real( v.value ), imag( v.value ) );
|
||||
} else {
|
||||
return new TypeError( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `'+v.value+'`.' );
|
||||
}
|
||||
}
|
||||
if ( v.done ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = fromIterator;
|
70
js/node_modules/@stdlib/array/complex128/lib/from_iterator_map.js
generated
vendored
Normal file
70
js/node_modules/@stdlib/array/complex128/lib/from_iterator_map.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' );
|
||||
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Returns an array of iterated values.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} it - iterator
|
||||
* @param {Function} clbk - callback to invoke for each iterated value
|
||||
* @param {*} thisArg - invocation context
|
||||
* @returns {(Array|TypeError)} array or an error
|
||||
*/
|
||||
function fromIteratorMap( it, clbk, thisArg ) {
|
||||
var out;
|
||||
var v;
|
||||
var i;
|
||||
|
||||
out = [];
|
||||
i = 0;
|
||||
while ( true ) {
|
||||
v = it.next();
|
||||
i += 1;
|
||||
if ( v.value ) {
|
||||
v = clbk.call( thisArg, v.value, i );
|
||||
if ( isArrayLikeObject( v ) ) {
|
||||
out.push( v[ 0 ], v[ 1 ] );
|
||||
} else if ( isComplexLike( v ) ) {
|
||||
out.push( real( v ), imag( v ) );
|
||||
} else {
|
||||
return new TypeError( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `'+v+'`.' );
|
||||
}
|
||||
}
|
||||
if ( v.done ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = fromIteratorMap;
|
94
js/node_modules/@stdlib/array/complex128/lib/index.js
generated
vendored
Normal file
94
js/node_modules/@stdlib/array/complex128/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 128-bit complex number array.
|
||||
*
|
||||
* @module @stdlib/array/complex128
|
||||
*
|
||||
* @example
|
||||
* var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
*
|
||||
* var arr = new Complex128Array();
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
*
|
||||
* var arr = new Complex128Array( 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
*
|
||||
* var arr = new Complex128Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
* var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
* var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf, 16 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
* var Complex128Array = require( '@stdlib/array/complex128' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 64 );
|
||||
* var arr = new Complex128Array( buf, 16, 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
|
||||
// MODULES //
|
||||
|
||||
var Complex128Array = require( './main.js' );
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = Complex128Array;
|
883
js/node_modules/@stdlib/array/complex128/lib/main.js
generated
vendored
Normal file
883
js/node_modules/@stdlib/array/complex128/lib/main.js
generated
vendored
Normal file
|
@ -0,0 +1,883 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
|
||||
var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' );
|
||||
var isCollection = require( '@stdlib/assert/is-collection' );
|
||||
var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' );
|
||||
var isObject = require( '@stdlib/assert/is-object' );
|
||||
var isArray = require( '@stdlib/assert/is-array' );
|
||||
var isFunction = require( '@stdlib/assert/is-function' );
|
||||
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
||||
var isEven = require( '@stdlib/math/base/assert/is-even' );
|
||||
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
|
||||
var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' );
|
||||
var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' );
|
||||
var defineProperty = require( '@stdlib/utils/define-property' );
|
||||
var Float64Array = require( './../../float64' );
|
||||
var Complex128 = require( '@stdlib/complex/float64' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
var fromIterator = require( './from_iterator.js' );
|
||||
var fromIteratorMap = require( './from_iterator_map.js' );
|
||||
var fromArray = require( './from_array.js' );
|
||||
|
||||
|
||||
// VARIABLES //
|
||||
|
||||
var BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT * 2;
|
||||
var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();
|
||||
|
||||
|
||||
// FUNCTIONS //
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating if a value is a complex typed array.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value - value to test
|
||||
* @returns {boolean} boolean indicating if a value is a complex typed array
|
||||
*/
|
||||
function isComplexArray( value ) {
|
||||
return (
|
||||
value instanceof Complex128Array ||
|
||||
(
|
||||
typeof value === 'object' &&
|
||||
value !== null &&
|
||||
(
|
||||
value.constructor.name === 'Complex64Array' ||
|
||||
value.constructor.name === 'Complex128Array'
|
||||
) &&
|
||||
typeof value._length === 'number' && // eslint-disable-line no-underscore-dangle
|
||||
|
||||
// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...
|
||||
typeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating if a value is a complex typed array constructor.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value - value to test
|
||||
* @returns {boolean} boolean indicating if a value is a complex typed array constructor
|
||||
*/
|
||||
function isComplexArrayConstructor( value ) {
|
||||
return (
|
||||
value === Complex128Array ||
|
||||
|
||||
// NOTE: weaker test in order to avoid a circular dependency with Complex64Array...
|
||||
value.name === 'Complex64Array'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* 128-bit complex number array constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, or buffer
|
||||
* @param {NonNegativeInteger} [byteOffset=0] - byte offset
|
||||
* @param {NonNegativeInteger} [length] - view length
|
||||
* @throws {RangeError} ArrayBuffer byte length must be a multiple of `16`
|
||||
* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws {TypeError} if provided only a single argument, must provide a valid argument
|
||||
* @throws {TypeError} byte offset must be a nonnegative integer
|
||||
* @throws {RangeError} byte offset must be a multiple of `16`
|
||||
* @throws {TypeError} view length must be a positive multiple of `16`
|
||||
* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns {Complex128Array} complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array();
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex128Array( buf, 16 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 64 );
|
||||
* var arr = new Complex128Array( buf, 16, 2 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
function Complex128Array() {
|
||||
var byteOffset;
|
||||
var nargs;
|
||||
var buf;
|
||||
var len;
|
||||
|
||||
nargs = arguments.length;
|
||||
if ( !(this instanceof Complex128Array) ) {
|
||||
if ( nargs === 0 ) {
|
||||
return new Complex128Array();
|
||||
}
|
||||
if ( nargs === 1 ) {
|
||||
return new Complex128Array( arguments[0] );
|
||||
}
|
||||
if ( nargs === 2 ) {
|
||||
return new Complex128Array( arguments[0], arguments[1] );
|
||||
}
|
||||
return new Complex128Array( arguments[0], arguments[1], arguments[2] );
|
||||
}
|
||||
// Create the underlying data buffer...
|
||||
if ( nargs === 0 ) {
|
||||
buf = new Float64Array( 0 ); // backward-compatibility
|
||||
} else if ( nargs === 1 ) {
|
||||
if ( isNonNegativeInteger( arguments[0] ) ) {
|
||||
buf = new Float64Array( arguments[0]*2 );
|
||||
} else if ( isCollection( arguments[0] ) ) {
|
||||
buf = arguments[ 0 ];
|
||||
len = buf.length;
|
||||
|
||||
// If provided a "generic" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to "normal" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...
|
||||
if ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {
|
||||
buf = fromArray( new Float64Array( len*2 ), buf );
|
||||
if ( buf === null ) {
|
||||
// We failed and we are now forced to allocate a new array :-(
|
||||
if ( !isEven( len ) ) {
|
||||
throw new RangeError( 'invalid argument. Array-like object input arguments must have a length which is a multiple of two. Length: `'+len+'`.' );
|
||||
}
|
||||
// We failed, so fall back to directly setting values...
|
||||
buf = new Float64Array( arguments[0] );
|
||||
}
|
||||
} else {
|
||||
if ( !isEven( len ) ) {
|
||||
throw new RangeError( 'invalid argument. Array-like object and typed array input arguments must have a length which is a multiple of two. Length: `'+len+'`.' );
|
||||
}
|
||||
buf = new Float64Array( buf );
|
||||
}
|
||||
} else if ( isArrayBuffer( arguments[0] ) ) {
|
||||
buf = arguments[ 0 ];
|
||||
if ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {
|
||||
throw new RangeError( 'invalid argument. ArrayBuffer byte length must be a multiple of '+BYTES_PER_ELEMENT+'. Byte length: `'+buf.byteLength+'`.' );
|
||||
}
|
||||
buf = new Float64Array( buf );
|
||||
} else if ( isObject( arguments[0] ) ) {
|
||||
buf = arguments[ 0 ];
|
||||
if ( HAS_ITERATOR_SYMBOL === false ) {
|
||||
throw new TypeError( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `'+buf+'`.' );
|
||||
}
|
||||
if ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {
|
||||
throw new TypeError( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `'+buf+'`.' );
|
||||
}
|
||||
buf = buf[ ITERATOR_SYMBOL ]();
|
||||
if ( !isFunction( buf.next ) ) {
|
||||
throw new TypeError( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable.' );
|
||||
}
|
||||
buf = fromIterator( buf );
|
||||
if ( buf instanceof Error ) {
|
||||
throw buf;
|
||||
}
|
||||
buf = new Float64Array( buf );
|
||||
} else {
|
||||
throw new TypeError( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `'+arguments[0]+'`.' );
|
||||
}
|
||||
} else {
|
||||
buf = arguments[ 0 ];
|
||||
if ( !isArrayBuffer( buf ) ) {
|
||||
throw new TypeError( 'invalid argument. First argument must be an array buffer. Value: `'+buf+'`.' );
|
||||
}
|
||||
byteOffset = arguments[ 1 ];
|
||||
if ( !isNonNegativeInteger( byteOffset ) ) {
|
||||
throw new TypeError( 'invalid argument. Byte offset must be a nonnegative integer. Value: `'+byteOffset+'`.' );
|
||||
}
|
||||
if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {
|
||||
throw new RangeError( 'invalid argument. Byte offset must be a multiple of '+BYTES_PER_ELEMENT+'. Value: `'+byteOffset+'`.' );
|
||||
}
|
||||
if ( nargs === 2 ) {
|
||||
len = buf.byteLength - byteOffset;
|
||||
if ( !isInteger( len/BYTES_PER_ELEMENT ) ) {
|
||||
throw new RangeError( 'invalid arguments. ArrayBuffer view byte length must be a multiple of '+BYTES_PER_ELEMENT+'. View byte length: `'+len+'`.' );
|
||||
}
|
||||
buf = new Float64Array( buf, byteOffset );
|
||||
} else {
|
||||
len = arguments[ 2 ];
|
||||
if ( !isNonNegativeInteger( len ) ) {
|
||||
throw new TypeError( 'invalid argument. Length must be a nonnegative integer. Value: `'+len+'`.' );
|
||||
}
|
||||
if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {
|
||||
throw new RangeError( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `'+(len*BYTES_PER_ELEMENT)+'`.' );
|
||||
}
|
||||
buf = new Float64Array( buf, byteOffset, len*2 );
|
||||
}
|
||||
}
|
||||
defineProperty( this, '_buffer', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': buf
|
||||
});
|
||||
defineProperty( this, '_length', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': buf.length / 2
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Size (in bytes) of each array element.
|
||||
*
|
||||
* @name BYTES_PER_ELEMENT
|
||||
* @memberof Complex128Array
|
||||
* @type {PositiveInteger}
|
||||
* @default 16
|
||||
*
|
||||
* @example
|
||||
* var nbytes = Complex128Array.BYTES_PER_ELEMENT;
|
||||
* // returns 16
|
||||
*/
|
||||
defineProperty( Complex128Array, 'BYTES_PER_ELEMENT', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': BYTES_PER_ELEMENT
|
||||
});
|
||||
|
||||
/**
|
||||
* Constructor name.
|
||||
*
|
||||
* @name name
|
||||
* @memberof Complex128Array
|
||||
* @type {string}
|
||||
* @default 'Complex128Array'
|
||||
*
|
||||
* @example
|
||||
* var name = Complex128Array.name;
|
||||
* // returns 'Complex128Array'
|
||||
*/
|
||||
defineProperty( Complex128Array, 'name', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': 'Complex128Array'
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a new 128-bit complex number array from an array-like object or an iterable.
|
||||
*
|
||||
* @name from
|
||||
* @memberof Complex128Array
|
||||
* @type {Function}
|
||||
* @param {(ArrayLikeObject|Object)} src - array-like object or iterable
|
||||
* @param {Function} [clbk] - callback to invoke for each source element
|
||||
* @param {*} [thisArg] - context
|
||||
* @throws {TypeError} `this` context must be a constructor
|
||||
* @throws {TypeError} `this` must be a complex number array
|
||||
* @throws {TypeError} first argument must be an array-like object or an iterable
|
||||
* @throws {TypeError} second argument must be a function
|
||||
* @throws {RangeError} array-like objects must have a length which is a multiple of two
|
||||
* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns {Complex128Array} 128-bit complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = Complex128Array.from( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var Complex128 = require( '@stdlib/complex/float64' );
|
||||
*
|
||||
* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var Complex128 = require( '@stdlib/complex/float64' );
|
||||
* var real = require( '@stdlib/complex/real' );
|
||||
* var imag = require( '@stdlib/complex/imag' );
|
||||
*
|
||||
* function clbk( v ) {
|
||||
* return new Complex128( real(v)*2.0, imag(v)*2.0 );
|
||||
* }
|
||||
*
|
||||
* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*/
|
||||
defineProperty( Complex128Array, 'from', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': function from( src ) {
|
||||
var thisArg;
|
||||
var nargs;
|
||||
var clbk;
|
||||
var out;
|
||||
var buf;
|
||||
var tmp;
|
||||
var len;
|
||||
var flg;
|
||||
var v;
|
||||
var i;
|
||||
var j;
|
||||
if ( !isFunction( this ) ) {
|
||||
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
|
||||
}
|
||||
if ( !isComplexArrayConstructor( this ) ) {
|
||||
throw new TypeError( 'invalid invocation. `this` is not a complex number array.' );
|
||||
}
|
||||
nargs = arguments.length;
|
||||
if ( nargs > 1 ) {
|
||||
clbk = arguments[ 1 ];
|
||||
if ( !isFunction( clbk ) ) {
|
||||
throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+clbk+'`.' );
|
||||
}
|
||||
if ( nargs > 2 ) {
|
||||
thisArg = arguments[ 2 ];
|
||||
}
|
||||
}
|
||||
if ( isCollection( src ) ) {
|
||||
if ( clbk ) {
|
||||
// Note: array contents affect how we iterate over a provided data source. If only complex numbers, we can extract real and imaginary components. Otherwise, we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.
|
||||
|
||||
// Detect whether we've been provided an array of complex numbers...
|
||||
len = src.length;
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
if ( !isComplexLike( src[ i ] ) ) {
|
||||
flg = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...
|
||||
if ( flg ) {
|
||||
if ( !isEven( len ) ) {
|
||||
throw new RangeError( 'invalid argument. First argument must have a length which is a multiple of two. Length: `'+len+'`.' );
|
||||
}
|
||||
out = new this( len/2 );
|
||||
buf = out._buffer; // eslint-disable-line no-underscore-dangle
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
buf[ i ] = clbk.call( thisArg, src[ i ], i );
|
||||
}
|
||||
}
|
||||
// If an array contains only complex numbers, then we need to extract real and imaginary components...
|
||||
else {
|
||||
out = new this( len );
|
||||
buf = out._buffer; // eslint-disable-line no-underscore-dangle
|
||||
j = 0;
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
v = clbk.call( thisArg, src[ i ], i );
|
||||
if ( isComplexLike( v ) ) {
|
||||
buf[ j ] = real( v );
|
||||
buf[ j+1 ] = imag( v );
|
||||
} else if ( isArrayLikeObject( v ) ) {
|
||||
buf[ j ] = v[ 0 ];
|
||||
buf[ j+1 ] = v[ 1 ];
|
||||
} else {
|
||||
throw new TypeError( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `'+v+'`.' );
|
||||
}
|
||||
j += 2; // stride
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out = new this( src );
|
||||
}
|
||||
} else if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len
|
||||
buf = src[ ITERATOR_SYMBOL ]();
|
||||
if ( !isFunction( buf.next ) ) {
|
||||
throw new TypeError( 'invalid argument. First argument must be an array-like object or an iterable.' );
|
||||
}
|
||||
if ( clbk ) {
|
||||
tmp = fromIteratorMap( buf, clbk, thisArg );
|
||||
} else {
|
||||
tmp = fromIterator( buf );
|
||||
}
|
||||
if ( tmp instanceof Error ) {
|
||||
throw tmp;
|
||||
}
|
||||
len = tmp.length / 2;
|
||||
out = new this( len );
|
||||
buf = out._buffer; // eslint-disable-line no-underscore-dangle
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
buf[ i ] = tmp[ i ];
|
||||
}
|
||||
} else {
|
||||
throw new TypeError( 'invalid argument. First argument must be an array-like object or an iterable. Value: `'+src+'`.' );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a new 128-bit complex number array from a variable number of arguments.
|
||||
*
|
||||
* @name of
|
||||
* @memberof Complex128Array
|
||||
* @type {Function}
|
||||
* @param {...*} element - array elements
|
||||
* @throws {TypeError} `this` context must be a constructor
|
||||
* @throws {TypeError} `this` must be a complex number array
|
||||
* @returns {Complex128Array} 128-bit complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 );
|
||||
* // returns <Complex128Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
defineProperty( Complex128Array, 'of', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': function of() {
|
||||
var args;
|
||||
var i;
|
||||
if ( !isFunction( this ) ) {
|
||||
throw new TypeError( 'invalid invocation. `this` context must be a constructor.' );
|
||||
}
|
||||
if ( !isComplexArrayConstructor( this ) ) {
|
||||
throw new TypeError( 'invalid invocation. `this` is not a complex number array.' );
|
||||
}
|
||||
args = [];
|
||||
for ( i = 0; i < arguments.length; i++ ) {
|
||||
args.push( arguments[ i ] );
|
||||
}
|
||||
return new this( args );
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Pointer to the underlying data buffer.
|
||||
*
|
||||
* @name buffer
|
||||
* @memberof Complex128Array.prototype
|
||||
* @type {ArrayBuffer}
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var buf = arr.buffer;
|
||||
* // returns <ArrayBuffer>
|
||||
*/
|
||||
defineProperty( Complex128Array.prototype, 'buffer', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'get': function get() {
|
||||
return this._buffer.buffer;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Size (in bytes) of the array.
|
||||
*
|
||||
* @name byteLength
|
||||
* @memberof Complex128Array.prototype
|
||||
* @type {NonNegativeInteger}
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var byteLength = arr.byteLength;
|
||||
* // returns 160
|
||||
*/
|
||||
defineProperty( Complex128Array.prototype, 'byteLength', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'get': function get() {
|
||||
return this._buffer.byteLength;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.
|
||||
*
|
||||
* @name byteOffset
|
||||
* @memberof Complex128Array.prototype
|
||||
* @type {NonNegativeInteger}
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var byteOffset = arr.byteOffset;
|
||||
* // returns 0
|
||||
*/
|
||||
defineProperty( Complex128Array.prototype, 'byteOffset', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'get': function get() {
|
||||
return this._buffer.byteOffset;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Size (in bytes) of each array element.
|
||||
*
|
||||
* @name BYTES_PER_ELEMENT
|
||||
* @memberof Complex128Array.prototype
|
||||
* @type {PositiveInteger}
|
||||
* @default 16
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var nbytes = arr.BYTES_PER_ELEMENT;
|
||||
* // returns 16
|
||||
*/
|
||||
defineProperty( Complex128Array.prototype, 'BYTES_PER_ELEMENT', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': Complex128Array.BYTES_PER_ELEMENT
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns an array element.
|
||||
*
|
||||
* @name get
|
||||
* @memberof Complex128Array.prototype
|
||||
* @type {Function}
|
||||
* @param {ArrayLikeObject} [out] - output array
|
||||
* @param {NonNegativeInteger} i - element index
|
||||
* @throws {TypeError} `this` must be a complex number array
|
||||
* @throws {TypeError} index argument must be a nonnegative integer
|
||||
* @throws {TypeError} output argument must be an array-like object
|
||||
* @returns {(Complex128|ArrayLikeObject|void)} array element
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex128>
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( [ 0.0, 0.0 ], 0 );
|
||||
* // returns [ 1.0, -1.0 ]
|
||||
*
|
||||
* z = arr.get( 100 );
|
||||
* // returns undefined
|
||||
*/
|
||||
defineProperty( Complex128Array.prototype, 'get', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': function get( i ) {
|
||||
var idx;
|
||||
var out;
|
||||
var buf;
|
||||
|
||||
if ( !isComplexArray( this ) ) {
|
||||
throw new TypeError( 'invalid invocation. `this` is not a complex number array.' );
|
||||
}
|
||||
buf = this._buffer;
|
||||
if ( arguments.length > 1 ) {
|
||||
idx = arguments[ 1 ];
|
||||
out = i;
|
||||
if ( !isArrayLikeObject( out ) || out.length < 2 ) {
|
||||
throw new TypeError( 'invalid argument. Output argument must be an array-like object. Value: `'+out+'`.' );
|
||||
}
|
||||
} else {
|
||||
idx = i;
|
||||
}
|
||||
if ( !isNonNegativeInteger( idx ) ) {
|
||||
throw new TypeError( 'invalid argument. Index argument must be a nonnegative integer. Value: `'+idx+'`.' );
|
||||
}
|
||||
if ( idx >= this._length ) {
|
||||
return;
|
||||
}
|
||||
idx *= 2;
|
||||
if ( out ) {
|
||||
out[ 0 ] = buf[ idx ];
|
||||
out[ 1 ] = buf[ idx+1 ];
|
||||
return out;
|
||||
}
|
||||
return new Complex128( buf[ idx ], buf[ idx+1 ] );
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Number of array elements.
|
||||
*
|
||||
* @name length
|
||||
* @memberof Complex128Array.prototype
|
||||
* @type {NonNegativeInteger}
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 10
|
||||
*/
|
||||
defineProperty( Complex128Array.prototype, 'length', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'get': function get() {
|
||||
return this._length;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Sets an array element.
|
||||
*
|
||||
* ## Notes
|
||||
*
|
||||
* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:
|
||||
*
|
||||
* ```text
|
||||
* buf: ---------------------
|
||||
* src: ---------------------
|
||||
* ```
|
||||
*
|
||||
* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.
|
||||
*
|
||||
* In the other overlapping scenario,
|
||||
*
|
||||
* ```text
|
||||
* buf: ---------------------
|
||||
* src: ---------------------
|
||||
* ```
|
||||
*
|
||||
* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended.
|
||||
*
|
||||
*
|
||||
* @name set
|
||||
* @memberof Complex128Array.prototype
|
||||
* @type {Function}
|
||||
* @param {(Collection|Complex|ComplexArray)} value - value(s)
|
||||
* @param {NonNegativeInteger} [i=0] - element index at which to start writing values
|
||||
* @throws {TypeError} `this` must be a complex number array
|
||||
* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array
|
||||
* @throws {TypeError} index argument must be a nonnegative integer
|
||||
* @throws {RangeError} array-like objects must have a length which is a multiple of two
|
||||
* @throws {RangeError} index argument is out-of-bounds
|
||||
* @throws {RangeError} target array lacks sufficient storage to accommodate source values
|
||||
* @returns {void}
|
||||
*
|
||||
* @example
|
||||
* var real = require( '@stdlib/complex/real' );
|
||||
* var imag = require( '@stdlib/complex/imag' );
|
||||
*
|
||||
* var arr = new Complex128Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex128>
|
||||
*
|
||||
* var re = real( z );
|
||||
* // returns 0.0
|
||||
*
|
||||
* var im = imag( z );
|
||||
* // returns 0.0
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( 0 );
|
||||
* // returns <Complex128>
|
||||
*
|
||||
* re = real( z );
|
||||
* // returns 1.0
|
||||
*
|
||||
* im = imag( z );
|
||||
* // returns -1.0
|
||||
*/
|
||||
defineProperty( Complex128Array.prototype, 'set', {
|
||||
'configurable': false,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': function set( value ) {
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
var dbuf;
|
||||
var idx;
|
||||
var buf;
|
||||
var tmp;
|
||||
var flg;
|
||||
var N;
|
||||
var v;
|
||||
var i;
|
||||
var j;
|
||||
if ( !isComplexArray( this ) ) {
|
||||
throw new TypeError( 'invalid invocation. `this` is not a complex number array.' );
|
||||
}
|
||||
buf = this._buffer;
|
||||
if ( arguments.length > 1 ) {
|
||||
idx = arguments[ 1 ];
|
||||
if ( !isNonNegativeInteger( idx ) ) {
|
||||
throw new TypeError( 'invalid argument. Index argument must be a nonnegative integer. Value: `'+idx+'`.' );
|
||||
}
|
||||
} else {
|
||||
idx = 0;
|
||||
}
|
||||
if ( isComplexLike( value ) ) {
|
||||
if ( idx >= this._length ) {
|
||||
throw new RangeError( 'invalid argument. Index argument is out-of-bounds. Value: `'+idx+'`.' );
|
||||
}
|
||||
idx *= 2;
|
||||
buf[ idx ] = real( value );
|
||||
buf[ idx+1 ] = imag( value );
|
||||
return;
|
||||
}
|
||||
if ( isComplexArray( value ) ) {
|
||||
N = value._length;
|
||||
if ( idx+N > this._length ) {
|
||||
throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );
|
||||
}
|
||||
dbuf = value._buffer;
|
||||
|
||||
// Check for overlapping memory...
|
||||
j = buf.byteOffset + (idx*BYTES_PER_ELEMENT);
|
||||
if (
|
||||
dbuf.buffer === buf.buffer &&
|
||||
(
|
||||
dbuf.byteOffset < j &&
|
||||
dbuf.byteOffset+dbuf.byteLength > j
|
||||
)
|
||||
) {
|
||||
// We need to copy source values...
|
||||
tmp = new Float64Array( dbuf.length );
|
||||
for ( i = 0; i < dbuf.length; i++ ) {
|
||||
tmp[ i ] = dbuf[ i ];
|
||||
}
|
||||
dbuf = tmp;
|
||||
}
|
||||
idx *= 2;
|
||||
j = 0;
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
buf[ idx ] = dbuf[ j ];
|
||||
buf[ idx+1 ] = dbuf[ j+1 ];
|
||||
idx += 2; // stride
|
||||
j += 2; // stride
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( isCollection( value ) ) {
|
||||
// Detect whether we've been provided an array of complex numbers...
|
||||
N = value.length;
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
if ( !isComplexLike( value[ i ] ) ) {
|
||||
flg = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...
|
||||
if ( flg ) {
|
||||
if ( !isEven( N ) ) {
|
||||
throw new RangeError( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `'+N+'`.' );
|
||||
}
|
||||
if ( idx+(N/2) > this._length ) {
|
||||
throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );
|
||||
}
|
||||
dbuf = value;
|
||||
|
||||
// Check for overlapping memory...
|
||||
j = buf.byteOffset + (idx*BYTES_PER_ELEMENT);
|
||||
if (
|
||||
dbuf.buffer === buf.buffer &&
|
||||
(
|
||||
dbuf.byteOffset < j &&
|
||||
dbuf.byteOffset+dbuf.byteLength > j
|
||||
)
|
||||
) {
|
||||
// We need to copy source values...
|
||||
tmp = new Float64Array( N );
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
tmp[ i ] = dbuf[ i ];
|
||||
}
|
||||
dbuf = tmp;
|
||||
}
|
||||
idx *= 2;
|
||||
N /= 2;
|
||||
j = 0;
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
buf[ idx ] = dbuf[ j ];
|
||||
buf[ idx+1 ] = dbuf[ j+1 ];
|
||||
idx += 2; // stride
|
||||
j += 2; // stride
|
||||
}
|
||||
return;
|
||||
}
|
||||
// If an array contains only complex numbers, then we need to extract real and imaginary components...
|
||||
if ( idx+N > this._length ) {
|
||||
throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );
|
||||
}
|
||||
idx *= 2;
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
v = value[ i ];
|
||||
buf[ idx ] = real( v );
|
||||
buf[ idx+1 ] = imag( v );
|
||||
idx += 2; // stride
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new TypeError( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `'+value+'`.' );
|
||||
|
||||
/* eslint-enable no-underscore-dangle */
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = Complex128Array;
|
72
js/node_modules/@stdlib/array/complex128/package.json
generated
vendored
Normal file
72
js/node_modules/@stdlib/array/complex128/package.json
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "@stdlib/array/complex128",
|
||||
"version": "0.0.0",
|
||||
"description": "Complex128Array.",
|
||||
"license": "Apache-2.0",
|
||||
"author": {
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"directories": {
|
||||
"doc": "./docs",
|
||||
"example": "./examples",
|
||||
"lib": "./lib",
|
||||
"test": "./test"
|
||||
},
|
||||
"types": "./docs/types",
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/stdlib-js/stdlib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stdlib-js/stdlib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stdlib-js/stdlib/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.10.0",
|
||||
"npm": ">2.7.0"
|
||||
},
|
||||
"os": [
|
||||
"aix",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"macos",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32",
|
||||
"windows"
|
||||
],
|
||||
"keywords": [
|
||||
"stdlib",
|
||||
"stdtypes",
|
||||
"types",
|
||||
"data",
|
||||
"structure",
|
||||
"array",
|
||||
"typed",
|
||||
"typed array",
|
||||
"typed-array",
|
||||
"complex128array",
|
||||
"complex128",
|
||||
"complex",
|
||||
"cmplx",
|
||||
"real",
|
||||
"imaginary",
|
||||
"imag",
|
||||
"double",
|
||||
"float64",
|
||||
"double-precision",
|
||||
"ieee754"
|
||||
]
|
||||
}
|
902
js/node_modules/@stdlib/array/complex64/README.md
generated
vendored
Normal file
902
js/node_modules/@stdlib/array/complex64/README.md
generated
vendored
Normal file
|
@ -0,0 +1,902 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2018 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# Complex64Array
|
||||
|
||||
> 64-bit complex number array.
|
||||
|
||||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="intro">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.intro -->
|
||||
|
||||
<!-- Package usage documentation. -->
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
```
|
||||
|
||||
<a name="constructor"></a>
|
||||
|
||||
#### Complex64Array()
|
||||
|
||||
Creates a 64-bit complex number array.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array();
|
||||
// returns <Complex64Array>
|
||||
```
|
||||
|
||||
#### Complex64Array( length )
|
||||
|
||||
Creates a 64-bit complex number array having a specified `length`.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array( 10 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 10
|
||||
```
|
||||
|
||||
#### Complex64Array( typedarray )
|
||||
|
||||
Creates a 64-bit complex number array from a [typed array][@stdlib/array/typed] containing interleaves real and imaginary components.
|
||||
|
||||
```javascript
|
||||
var Float32Array = require( '@stdlib/array/float32' );
|
||||
|
||||
var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ]
|
||||
// returns <Float32Array>[ 1.0, -1.0, 2.0, -2.0 ]
|
||||
|
||||
var arr = new Complex64Array( buf );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 2
|
||||
```
|
||||
|
||||
#### Complex64Array( obj )
|
||||
|
||||
Creates a 64-bit complex number array from an array-like `object` or iterable.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
// From an array of interleaved real and imaginary components:
|
||||
var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr1.length;
|
||||
// returns 2
|
||||
|
||||
// From an array containing complex numbers:
|
||||
var buf = [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ];
|
||||
var arr2 = new Complex64Array( buf );
|
||||
|
||||
len = arr2.length;
|
||||
// returns 2
|
||||
```
|
||||
|
||||
#### Complex64Array( buffer\[, byteOffset\[, length]] )
|
||||
|
||||
Returns a 64-bit complex number array view of an [`ArrayBuffer`][@stdlib/array/buffer].
|
||||
|
||||
```javascript
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
var buf = new ArrayBuffer( 240 );
|
||||
|
||||
var arr1 = new Complex64Array( buf );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr1.length;
|
||||
// returns 30
|
||||
|
||||
var arr2 = new Complex64Array( buf, 8 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
len = arr2.length;
|
||||
// returns 29
|
||||
|
||||
var arr3 = new Complex64Array( buf, 8, 20 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
len = arr3.length;
|
||||
// returns 20
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
### Properties
|
||||
|
||||
<a name="static-prop-bytes-per-element"></a>
|
||||
|
||||
#### Complex64Array.BYTES_PER_ELEMENT
|
||||
|
||||
Static property returning the size (in bytes) of each array element.
|
||||
|
||||
```javascript
|
||||
var nbytes = Complex64Array.BYTES_PER_ELEMENT;
|
||||
// returns 8
|
||||
```
|
||||
|
||||
<a name="static-prop-name"></a>
|
||||
|
||||
#### Complex64Array.name
|
||||
|
||||
Static property returning the constructor name.
|
||||
|
||||
```javascript
|
||||
var str = Complex64Array.name;
|
||||
// returns 'Complex64Array'
|
||||
```
|
||||
|
||||
<a name="prop-buffer"></a>
|
||||
|
||||
#### Complex64Array.prototype.buffer
|
||||
|
||||
Pointer to the underlying data buffer.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array( 2 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var buf = arr.buffer;
|
||||
// returns <ArrayBuffer>
|
||||
```
|
||||
|
||||
<a name="prop-byte-length"></a>
|
||||
|
||||
#### Complex64Array.prototype.byteLength
|
||||
|
||||
Size (in bytes) of the array.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array( 10 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var nbytes = arr.byteLength;
|
||||
// returns 80
|
||||
```
|
||||
|
||||
<a name="prop-byte-offset"></a>
|
||||
|
||||
#### Complex64Array.prototype.byteOffset
|
||||
|
||||
Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.
|
||||
|
||||
```javascript
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
|
||||
var arr = new Complex64Array( 10 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var offset = arr.byteOffset;
|
||||
// returns 0
|
||||
|
||||
var buf = new ArrayBuffer( 240 );
|
||||
arr = new Complex64Array( buf, 64 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
offset = arr.byteOffset;
|
||||
// returns 64
|
||||
```
|
||||
|
||||
<a name="prop-bytes-per-element"></a>
|
||||
|
||||
#### Complex64Array.prototype.BYTES_PER_ELEMENT
|
||||
|
||||
Size (in bytes) of each array element.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array( 10 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var nbytes = arr.BYTES_PER_ELEMENT;
|
||||
// returns 8
|
||||
```
|
||||
|
||||
<a name="prop-length"></a>
|
||||
|
||||
#### Complex64Array.prototype.length
|
||||
|
||||
Number of array elements.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array( 10 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 10
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
### Methods
|
||||
|
||||
<a name="static-method-from"></a>
|
||||
|
||||
#### Complex64Array.from( src\[, clbk\[, thisArg]] )
|
||||
|
||||
Creates a new 64-bit complex number array from an array-like `object` or an iterable.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
// Create an array from interleaved real and imaginary components:
|
||||
var arr = Complex64Array.from( [ 1.0, -1.0 ] );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 1
|
||||
|
||||
// Create an array from an array of complex numbers:
|
||||
arr = Complex64Array.from( [ new Complex64( 1.0, -1.0 ) ] );
|
||||
// returns <Complex64Array>
|
||||
|
||||
len = arr.length;
|
||||
// returns 1
|
||||
```
|
||||
|
||||
The iterator returned by an iterable must return either a complex number or an array-like `object` containing a real and imaginary component.
|
||||
|
||||
```javascript
|
||||
var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' );
|
||||
var Float32Array = require( '@stdlib/array/float32' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
var iter;
|
||||
var arr;
|
||||
var len;
|
||||
var re;
|
||||
var im;
|
||||
var z;
|
||||
|
||||
// Define a function which returns an iterator protocol-compliant object...
|
||||
function iterable() {
|
||||
var buf = new Float32Array( 2 );
|
||||
var i = 0;
|
||||
return {
|
||||
'next': next
|
||||
};
|
||||
|
||||
function next() {
|
||||
i += 1;
|
||||
if ( i < 3 ) {
|
||||
// Reuse allocated memory...
|
||||
buf[ 0 ] = i;
|
||||
buf[ 1 ] = -i;
|
||||
return {
|
||||
'value': buf
|
||||
};
|
||||
}
|
||||
return {
|
||||
'done': true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if ( ITERATOR_SYMBOL === null ) {
|
||||
console.error( 'Environment does not support iterables.' );
|
||||
} else {
|
||||
// Create an iterable:
|
||||
iter = {};
|
||||
iter[ ITERATOR_SYMBOL ] = iterable;
|
||||
|
||||
// Generate a complex number array:
|
||||
arr = Complex64Array.from( iter );
|
||||
// returns <Complex64Array>
|
||||
|
||||
len = arr.length;
|
||||
// returns 2
|
||||
|
||||
z = arr.get( 0 );
|
||||
// returns <Complex64>
|
||||
|
||||
re = real( z );
|
||||
// returns 1.0
|
||||
|
||||
im = imag( z );
|
||||
// returns -1.0
|
||||
}
|
||||
```
|
||||
|
||||
To invoke a function for each `src` value, provide a callback function. If `src` is an iterable or an array-like `object` containing complex numbers, the callback must return either a complex number
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
function map( z ) {
|
||||
return new Complex64( real(z)*2.0, imag(z)*2.0 );
|
||||
}
|
||||
|
||||
// Create a source array:
|
||||
var src = [ new Complex64( 1.0, -1.0 ) ];
|
||||
|
||||
// Create a new complex number array by scaling the source array:
|
||||
var arr = Complex64Array.from( src, map );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 1
|
||||
|
||||
var z = arr.get( 0 );
|
||||
// returns <Complex64>
|
||||
|
||||
var re = real( z );
|
||||
// returns 2.0
|
||||
|
||||
var im = imag( z );
|
||||
// returns -2.0
|
||||
```
|
||||
|
||||
or an array-like `object` containing real and imaginary components
|
||||
|
||||
```javascript
|
||||
var Float32Array = require( '@stdlib/array/float32' );
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
// Return a callback which reuses allocated memory...
|
||||
function mapFcn() {
|
||||
var buf = new Float32Array( 2 );
|
||||
return map;
|
||||
|
||||
function map( z ) {
|
||||
buf[ 0 ] = real( z ) * 2.0;
|
||||
buf[ 1 ] = imag( z ) * 2.0;
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a source array:
|
||||
var src = [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ];
|
||||
|
||||
// Create a new complex number array by scaling the source array:
|
||||
var arr = Complex64Array.from( src, mapFcn() );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 2
|
||||
|
||||
var z = arr.get( 0 );
|
||||
// returns <Complex64>
|
||||
|
||||
var re = real( z );
|
||||
// returns 2.0
|
||||
|
||||
var im = imag( z );
|
||||
// returns -2.0
|
||||
|
||||
z = arr.get( 1 );
|
||||
// returns <Complex64>
|
||||
|
||||
re = real( z );
|
||||
// returns 4.0
|
||||
|
||||
im = imag( z );
|
||||
// returns -4.0
|
||||
```
|
||||
|
||||
If `src` is an array-like `object` containing interleaved real and imaginary components, the callback is invoked for each component and should return the transformed component value.
|
||||
|
||||
```javascript
|
||||
var Float32Array = require( '@stdlib/array/float32' );
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
function map( v ) {
|
||||
return v * 2.0;
|
||||
}
|
||||
|
||||
// Create a source array:
|
||||
var src = new Float32Array( [ 1.0, -1.0 ] );
|
||||
|
||||
// Create a new complex number array by scaling the source array:
|
||||
var arr = Complex64Array.from( src, map );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 1
|
||||
|
||||
var z = arr.get( 0 );
|
||||
// returns <Complex64>
|
||||
|
||||
var re = real( z );
|
||||
// returns 2.0
|
||||
|
||||
var im = imag( z );
|
||||
// returns -2.0
|
||||
```
|
||||
|
||||
A callback function is provided two arguments:
|
||||
|
||||
- `value`: source value
|
||||
- `index`: source index
|
||||
|
||||
To set the callback execution context, provide a `thisArg`.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
function map( z ) {
|
||||
this.count += 1;
|
||||
return new Complex64( real(z)*2.0, imag(z)*2.0 );
|
||||
}
|
||||
|
||||
// Create a source array:
|
||||
var src = [ new Complex64( 1.0, -1.0 ), new Complex64( 1.0, -1.0 ) ];
|
||||
|
||||
// Define an execution context:
|
||||
var ctx = {
|
||||
'count': 0
|
||||
};
|
||||
|
||||
// Create a new complex number array by scaling the source array:
|
||||
var arr = Complex64Array.from( src, map, ctx );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 2
|
||||
|
||||
var n = ctx.count;
|
||||
// returns 2
|
||||
```
|
||||
|
||||
<a name="static-method-of"></a>
|
||||
|
||||
#### Complex64Array.of( element0\[, element1\[, ...elementN]] )
|
||||
|
||||
Creates a new 64-bit complex number array from a variable number of arguments.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
var arr = Complex64Array.of( 1.0, -1.0, 2.0, -2.0 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
var len = arr.length;
|
||||
// returns 2
|
||||
|
||||
var z1 = new Complex64( 1.0, -1.0 );
|
||||
var z2 = new Complex64( 2.0, -2.0 );
|
||||
|
||||
arr = Complex64Array.of( z1, z2 );
|
||||
// returns <Complex64Array>
|
||||
|
||||
len = arr.length;
|
||||
// returns 2
|
||||
```
|
||||
|
||||
<a name="method-copy-within"></a>
|
||||
|
||||
#### Complex64Array.prototype.copyWithin( target, start\[, end] )
|
||||
|
||||
Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
var arr = new Complex64Array( 4 );
|
||||
|
||||
// Set the array elements:
|
||||
arr.set( new Complex64( 1.0, -1.0 ), 0 );
|
||||
arr.set( new Complex64( 2.0, -2.0 ), 1 );
|
||||
arr.set( new Complex64( 3.0, -3.0 ), 2 );
|
||||
arr.set( new Complex64( 4.0, -4.0 ), 3 );
|
||||
|
||||
// Get the first array element:
|
||||
var z = arr.get( [ 0.0, 0.0 ], 0 );
|
||||
// returns [ 1.0, -1.0 ]
|
||||
|
||||
// Get the second array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 1 );
|
||||
// returns [ 2.0, -2.0 ]
|
||||
|
||||
// Copy the last two elements to the first two elements:
|
||||
arr.copyWithin( 0, 2 );
|
||||
|
||||
// Get the first array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 0 );
|
||||
// returns [ 3.0, -3.0 ]
|
||||
|
||||
// Get the second array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 1 );
|
||||
// returns [ 4.0, -4.0 ]
|
||||
```
|
||||
|
||||
By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
var arr = new Complex64Array( 4 );
|
||||
|
||||
// Set the array elements:
|
||||
arr.set( new Complex64( 1.0, -1.0 ), 0 );
|
||||
arr.set( new Complex64( 2.0, -2.0 ), 1 );
|
||||
arr.set( new Complex64( 3.0, -3.0 ), 2 );
|
||||
arr.set( new Complex64( 4.0, -4.0 ), 3 );
|
||||
|
||||
// Get the third array element:
|
||||
var z = arr.get( [ 0.0, 0.0 ], 2 );
|
||||
// returns [ 3.0, -3.0 ]
|
||||
|
||||
// Get the last array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 3 );
|
||||
// returns [ 4.0, -4.0 ]
|
||||
|
||||
// Copy the first two elements to the last two elements:
|
||||
arr.copyWithin( 2, 0, 2 );
|
||||
|
||||
// Get the third array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 2 );
|
||||
// returns [ 1.0, -1.0 ]
|
||||
|
||||
// Get the last array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 3 );
|
||||
// returns [ 2.0, -2.0 ]
|
||||
```
|
||||
|
||||
When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example:
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
var arr = new Complex64Array( 4 );
|
||||
|
||||
// Set the array elements:
|
||||
arr.set( new Complex64( 1.0, -1.0 ), 0 );
|
||||
arr.set( new Complex64( 2.0, -2.0 ), 1 );
|
||||
arr.set( new Complex64( 3.0, -3.0 ), 2 );
|
||||
arr.set( new Complex64( 4.0, -4.0 ), 3 );
|
||||
|
||||
// Get the third array element:
|
||||
var z = arr.get( [ 0.0, 0.0 ], 2 );
|
||||
// returns [ 3.0, -3.0 ]
|
||||
|
||||
// Get the last array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 3 );
|
||||
// returns [ 4.0, -4.0 ]
|
||||
|
||||
// Copy the first two elements to the last two elements using negative indices:
|
||||
arr.copyWithin( -2, -4, -2 );
|
||||
|
||||
// Get the third array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 2 );
|
||||
// returns [ 1.0, -1.0 ]
|
||||
|
||||
// Get the last array element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 3 );
|
||||
// returns [ 2.0, -2.0 ]
|
||||
```
|
||||
|
||||
<a name="method-entries"></a>
|
||||
|
||||
#### Complex64Array.prototype.entries()
|
||||
|
||||
Returns an iterator for iterating over array key-value pairs.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
var arr = [
|
||||
new Complex64( 1.0, -1.0 ),
|
||||
new Complex64( 2.0, -2.0 ),
|
||||
new Complex64( 3.0, -3.0 )
|
||||
];
|
||||
arr = new Complex64Array( arr );
|
||||
|
||||
// Create an iterator:
|
||||
var it = arr.entries();
|
||||
|
||||
// Iterate over the key-value pairs...
|
||||
var v = it.next().value;
|
||||
// returns [ 0, <Complex64> ]
|
||||
|
||||
var re = real( v[ 1 ] );
|
||||
// returns 1.0
|
||||
|
||||
var im = imag( v[ 1 ] );
|
||||
// returns -1.0
|
||||
|
||||
v = it.next().value;
|
||||
// returns [ 1, <Complex64> ]
|
||||
|
||||
re = real( v[ 1 ] );
|
||||
// returns 2.0
|
||||
|
||||
im = imag( v[ 1 ] );
|
||||
// returns -2.0
|
||||
|
||||
v = it.next().value;
|
||||
// returns [ 2, <Complex64> ]
|
||||
|
||||
re = real( v[ 1 ] );
|
||||
// returns 3.0
|
||||
|
||||
im = imag( v[ 1 ] );
|
||||
// returns -3.0
|
||||
|
||||
var bool = it.next().done;
|
||||
// returns true
|
||||
```
|
||||
|
||||
<a name="method-get"></a>
|
||||
|
||||
#### Complex64Array.prototype.get( \[out,] i )
|
||||
|
||||
Returns an array element located at position (index) `i`.
|
||||
|
||||
```javascript
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
var arr = new Complex64Array( 10 );
|
||||
|
||||
// Set the first element:
|
||||
arr.set( [ 1.0, -1.0 ], 0 );
|
||||
|
||||
// Get the first element:
|
||||
var z = arr.get( 0 );
|
||||
// returns <Complex64>
|
||||
|
||||
var re = real( z );
|
||||
// returns 1.0
|
||||
|
||||
var im = imag( z );
|
||||
// returns -1.0
|
||||
```
|
||||
|
||||
By default, the method returns a [64-bit complex number][@stdlib/complex/float32]. To return real and imaginary components separately, provide an array-like `object` as the first argument.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array( 10 );
|
||||
|
||||
// Set the first element:
|
||||
arr.set( [ 1.0, -1.0 ], 0 );
|
||||
|
||||
// Define an output array:
|
||||
var out = [ 0.0, 0.0 ];
|
||||
|
||||
// Get the first element:
|
||||
var z = arr.get( out, 0 );
|
||||
// returns [ 1.0, -1.0 ]
|
||||
|
||||
var bool = ( out === z );
|
||||
// returns true
|
||||
```
|
||||
|
||||
If provided an out-of-bounds index, the method returns `undefined`.
|
||||
|
||||
```javascript
|
||||
var arr = new Complex64Array( 10 );
|
||||
|
||||
var z = arr.get( 100 );
|
||||
// returns undefined
|
||||
|
||||
var out = [ 0.0, 0.0 ];
|
||||
|
||||
z = arr.get( out, 100 );
|
||||
// returns undefined
|
||||
|
||||
var bool = ( out === z );
|
||||
// returns false
|
||||
```
|
||||
|
||||
<a name="method-set"></a>
|
||||
|
||||
#### Complex64Array.prototype.set( z\[, i] )
|
||||
|
||||
Sets one or more array elements.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
var arr = new Complex64Array( 10 );
|
||||
|
||||
// Get the first element:
|
||||
var z = arr.get( [ 0.0, 0.0 ], 0 );
|
||||
// returns [ 0.0, 0.0 ]
|
||||
|
||||
// Set the first element:
|
||||
arr.set( new Complex64( 1.0, -1.0 ) );
|
||||
|
||||
// Get the first element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 0 );
|
||||
// returns [ 1.0, -1.0 ]
|
||||
```
|
||||
|
||||
By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`.
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
var arr = new Complex64Array( 10 );
|
||||
|
||||
// Get the fifth element:
|
||||
var z = arr.get( [ 0.0, 0.0 ], 4 );
|
||||
// returns [ 0.0, 0.0 ]
|
||||
|
||||
// Set the fifth element:
|
||||
arr.set( new Complex64( 1.0, -1.0 ), 4 );
|
||||
|
||||
// Get the fifth element:
|
||||
z = arr.get( [ 0.0, 0.0 ], 4 );
|
||||
// returns [ 1.0, -1.0 ]
|
||||
```
|
||||
|
||||
In addition to providing a complex number, to set one or more array elements, provide an array-like `object` containing either complex numbers
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
var arr = new Complex64Array( 10 );
|
||||
|
||||
// Define an array of complex numbers:
|
||||
var buf = [
|
||||
new Complex64( 1.0, -1.0 ),
|
||||
new Complex64( 2.0, -2.0 ),
|
||||
new Complex64( 3.0, -3.0 )
|
||||
];
|
||||
|
||||
// Set the fifth, sixth, and seventh elements:
|
||||
arr.set( buf, 4 );
|
||||
|
||||
// Get the sixth element:
|
||||
var z = arr.get( [ 0.0, 0.0 ], 5 );
|
||||
// returns [ 2.0, -2.0 ]
|
||||
```
|
||||
|
||||
or interleaved real and imaginary components
|
||||
|
||||
```javascript
|
||||
var Float32Array = require( '@stdlib/array/float32' );
|
||||
|
||||
var arr = new Complex64Array( 10 );
|
||||
|
||||
// Define an interleaved array of real and imaginary components:
|
||||
var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] );
|
||||
|
||||
// Set the fifth, sixth, and seventh elements:
|
||||
arr.set( buf, 4 );
|
||||
|
||||
// Get the sixth element:
|
||||
var z = arr.get( [ 0.0, 0.0 ], 5 );
|
||||
// returns [ 2.0, -2.0 ]
|
||||
```
|
||||
|
||||
A few notes:
|
||||
|
||||
- If `i` is out-of-bounds, the method throws an error.
|
||||
- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error.
|
||||
- If provided a [typed array][@stdlib/array/typed] which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range.
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
* * *
|
||||
|
||||
## Notes
|
||||
|
||||
- While a `Complex64Array` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows:
|
||||
|
||||
- The constructor does **not** require the `new` operator.
|
||||
- The constructor and associated methods support a broader variety of input argument types in order to better accommodate complex number input.
|
||||
- Accessing array elements using bracket syntax (e.g., `Z[i]`) is **not** supported. Instead, one **must** use the `.get()` method which returns a value compatible with complex number output.
|
||||
- The `set` method has extended behavior in order to support complex numbers.
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<!-- Package usage examples. -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
* * *
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var Complex64 = require( '@stdlib/complex/float32' );
|
||||
var Float32Array = require( '@stdlib/array/float32' );
|
||||
var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
|
||||
var arr;
|
||||
var out;
|
||||
|
||||
// Create a complex array by specifying a length:
|
||||
out = new Complex64Array( 3 );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an array of complex numbers:
|
||||
arr = [
|
||||
new Complex64( 1.0, -1.0 ),
|
||||
new Complex64( -3.14, 3.14 ),
|
||||
new Complex64( 0.5, 0.5 )
|
||||
];
|
||||
out = new Complex64Array( arr );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an interleaved typed array:
|
||||
arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
|
||||
out = new Complex64Array( arr );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an array buffer:
|
||||
arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
|
||||
out = new Complex64Array( arr.buffer );
|
||||
console.log( out );
|
||||
|
||||
// Create a complex array from an array buffer view:
|
||||
arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
|
||||
out = new Complex64Array( arr.buffer, 8, 2 );
|
||||
console.log( out );
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="references">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.references -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
[@stdlib/array/typed]: https://www.npmjs.com/package/@stdlib/array/tree/main/typed
|
||||
|
||||
[@stdlib/array/buffer]: https://www.npmjs.com/package/@stdlib/array/tree/main/buffer
|
||||
|
||||
[@stdlib/complex/float32]: https://www.npmjs.com/package/@stdlib/complex-float32
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
610
js/node_modules/@stdlib/array/complex64/docs/types/index.d.ts
generated
vendored
Normal file
610
js/node_modules/@stdlib/array/complex64/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,610 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
/// <reference types="@stdlib/types"/>
|
||||
|
||||
import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter';
|
||||
import { ArrayLike, TypedArray } from '@stdlib/types/array';
|
||||
import { ComplexLike } from '@stdlib/types/object';
|
||||
import ArrayBuffer = require( './../../../buffer' );
|
||||
import Complex64 = require( '@stdlib/complex/float32' );
|
||||
|
||||
// Define a union type representing both iterable and non-iterable iterators:
|
||||
type Iterator = Iter | IterableIterator;
|
||||
|
||||
/**
|
||||
* Class for creating a 64-bit complex number array.
|
||||
*/
|
||||
declare class Complex64Array {
|
||||
/**
|
||||
* 64-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array();
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf, 8 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex64Array( buf, 8, 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
constructor( arg?: number | TypedArray | ArrayLike<number | ComplexLike> | ArrayBuffer | Iterable<number | ComplexLike>, byteOffset?: number, length?: number ); // tslint:disable-line:max-line-length
|
||||
|
||||
/**
|
||||
* Length (in bytes) of the array.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 10 );
|
||||
*
|
||||
* var byteLength = arr.byteLength;
|
||||
* // returns 80
|
||||
*/
|
||||
readonly byteLength: number;
|
||||
|
||||
/**
|
||||
* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 10 );
|
||||
*
|
||||
* var byteOffset = arr.byteOffset;
|
||||
* // returns 0
|
||||
*/
|
||||
readonly byteOffset: number;
|
||||
|
||||
/**
|
||||
* Size (in bytes) of each array element.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 10 );
|
||||
*
|
||||
* var nbytes = arr.BYTES_PER_ELEMENT;
|
||||
* // returns 8
|
||||
*/
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/**
|
||||
* Number of array elements.
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 10 );
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 10
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Copies a sequence of elements within the array to the position starting at `target`.
|
||||
*
|
||||
* @param target - index at which to start copying elements
|
||||
* @param start - source index at which to copy elements from
|
||||
* @param end - source index at which to stop copying elements from
|
||||
* @returns modified array
|
||||
*
|
||||
* @example
|
||||
* var Complex64 = require( `@stdlib/complex/float32` );
|
||||
* var real = require( `@stdlib/complex/real` );
|
||||
* var imag = require( `@stdlib/complex/imag` );
|
||||
*
|
||||
* var arr = new Complex64Array( 4 );
|
||||
*
|
||||
* // Set the array elements:
|
||||
* arr.set( new Complex64( 1.0, 1.0 ), 0 );
|
||||
* arr.set( new Complex64( 2.0, 2.0 ), 1 );
|
||||
* arr.set( new Complex64( 3.0, 3.0 ), 2 );
|
||||
* arr.set( new Complex64( 4.0, 4.0 ), 3 );
|
||||
*
|
||||
* // Copy the first two elements to the last two elements:
|
||||
* arr.copyWithin( 2, 0, 2 );
|
||||
*
|
||||
* // Get the last array element:
|
||||
* var z = arr.get( 3 );
|
||||
*
|
||||
* var re = real( z );
|
||||
* // returns 2.0
|
||||
*
|
||||
* var im = imag( z );
|
||||
* // returns 2.0
|
||||
*/
|
||||
copyWithin( target: number, start: number, end?: number ): Complex64Array;
|
||||
|
||||
/**
|
||||
* Returns an iterator for iterating over array key-value pairs.
|
||||
*
|
||||
* @returns iterator
|
||||
*
|
||||
* @example
|
||||
* var Complex64 = require( `@stdlib/complex/float32` );
|
||||
*
|
||||
* var arr = [
|
||||
* new Complex64( 1.0, 1.0 ),
|
||||
* new Complex64( 2.0, 2.0 ),
|
||||
* new Complex64( 3.0, 3.0 )
|
||||
* ];
|
||||
* arr = new Complex64Array( arr );
|
||||
*
|
||||
* // Create an iterator:
|
||||
* var it = arr.entries();
|
||||
*
|
||||
* // Iterate over the key-value pairs...
|
||||
* var v = it.next().value;
|
||||
* // returns [ 0, <Complex64> ]
|
||||
*
|
||||
* v = it.next().value;
|
||||
* // returns [ 1, <Complex64> ]
|
||||
*
|
||||
* v = it.next().value;
|
||||
* // returns [ 2, <Complex64> ]
|
||||
*
|
||||
* var bool = it.next().done;
|
||||
* // returns true
|
||||
*/
|
||||
entries(): Iterator;
|
||||
|
||||
/**
|
||||
* Returns an array element.
|
||||
*
|
||||
* @param i - element index
|
||||
* @throws index argument must be a nonnegative integer
|
||||
* @returns array element
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex64>
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( 100 );
|
||||
* // returns undefined
|
||||
*/
|
||||
get( i: number ): Complex64 | void;
|
||||
|
||||
/**
|
||||
* Returns an array element.
|
||||
*
|
||||
* @param out - output array
|
||||
* @param i - element index
|
||||
* @throws index argument must be a nonnegative integer
|
||||
* @returns array element
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex64>
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( [ 0.0, 0.0 ], 0 );
|
||||
* // returns [ 1.0, -1.0 ]
|
||||
*/
|
||||
get( out: ArrayLike<number>, i: number ): ArrayLike<number> | void;
|
||||
|
||||
/**
|
||||
* Sets an array element.
|
||||
*
|
||||
* ## Notes
|
||||
*
|
||||
* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:
|
||||
*
|
||||
* ```text
|
||||
* buf: ---------------------
|
||||
* src: ---------------------
|
||||
* ```
|
||||
*
|
||||
* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.
|
||||
*
|
||||
* In the other overlapping scenario,
|
||||
*
|
||||
* ```text
|
||||
* buf: ---------------------
|
||||
* src: ---------------------
|
||||
* ```
|
||||
*
|
||||
* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended.
|
||||
*
|
||||
*
|
||||
* @param value - value(s)
|
||||
* @param i - element index at which to start writing values (default: 0)
|
||||
* @throws index argument must be a nonnegative integer
|
||||
* @throws array-like objects must have a length which is a multiple of two
|
||||
* @throws index argument is out-of-bounds
|
||||
* @throws target array lacks sufficient storage to accommodate source values
|
||||
*
|
||||
* @example
|
||||
* var real = require( `@stdlib/complex/real` );
|
||||
* var imag = require( `@stdlib/complex/imag` );
|
||||
*
|
||||
* var arr = new Complex64Array( 10 );
|
||||
*
|
||||
* var z = arr.get( 0 );
|
||||
* // returns <Complex64>
|
||||
*
|
||||
* var re = real( z );
|
||||
* // returns 0.0
|
||||
*
|
||||
* var im = imag( z );
|
||||
* // returns 0.0
|
||||
*
|
||||
* arr.set( [ 1.0, -1.0 ], 0 );
|
||||
*
|
||||
* z = arr.get( 0 );
|
||||
* // returns <Complex64>
|
||||
*
|
||||
* re = real( z );
|
||||
* // returns 1.0
|
||||
*
|
||||
* im = imag( z );
|
||||
* // returns -1.0
|
||||
*/
|
||||
set( value: ArrayLike<number | ComplexLike> | Complex64Array | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface defining a 64-bit complex number array constructor which is both "newable" and "callable".
|
||||
*/
|
||||
interface Constructor {
|
||||
/**
|
||||
* 64-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array();
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf, 8 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex64Array( buf, 8, 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
new( arg?: number | TypedArray | ArrayLike<number | ComplexLike> | ArrayBuffer | Iterable<number | ComplexLike>, byteOffset?: number, length?: number ): Complex64Array; // tslint-disable-line max-line-length
|
||||
|
||||
/**
|
||||
* 64-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array();
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf, 8 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex64Array( buf, 8, 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
( arg?: number | TypedArray | ArrayLike<number | ComplexLike> | ArrayBuffer | Iterable<number | ComplexLike>, byteOffset?: number, length?: number ): Complex64Array; // tslint-disable-line max-line-length
|
||||
|
||||
/**
|
||||
* Constructor name.
|
||||
*
|
||||
* @example
|
||||
* var str = Complex64Array.name;
|
||||
* // returns 'Complex64Array'
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* Size (in bytes) of each array element.
|
||||
*
|
||||
* @example
|
||||
* var nbytes = Complex64Array.BYTES_PER_ELEMENT;
|
||||
* // returns 8
|
||||
*/
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/**
|
||||
* Creates a new 64-bit complex number array from an array-like object or an iterable.
|
||||
*
|
||||
* @param src - array-like object or iterable
|
||||
* @param clbk - callback to invoke for each source element
|
||||
* @param thisArg - context
|
||||
* @throws array-like objects must have a length which is a multiple of two
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @throws when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns 64-bit complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = Complex64Array.from( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var Complex64 = require( `@stdlib/complex/float32` );
|
||||
*
|
||||
* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var Complex64 = require( `@stdlib/complex/float32` );
|
||||
* var real = require( `@stdlib/complex/real` );
|
||||
* var imag = require( `@stdlib/complex/imag` );
|
||||
*
|
||||
* function clbk( v ) {
|
||||
* return new Complex64( real(v)*2.0, imag(v)*2.0 );
|
||||
* }
|
||||
*
|
||||
* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*/
|
||||
from( src: ArrayLike<number | ComplexLike> | Iterable<number | ComplexLike>, clbk?: Function, thisArg?: any ): Complex64Array; // tslint:disable-line:max-line-length
|
||||
|
||||
/**
|
||||
* Creates a new 64-bit complex number array from a variable number of arguments.
|
||||
*
|
||||
* @param element - array elements
|
||||
* @returns 64-bit complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
of( ...elements: Array<number> ): Complex64Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* 64-bit complex number array constructor.
|
||||
*
|
||||
* @param arg - length, typed array, array-like object, or buffer
|
||||
* @param byteOffset - byte offset (default: 0)
|
||||
* @param length - view length
|
||||
* @throws ArrayBuffer byte length must be a multiple of `8`
|
||||
* @throws array-like object and typed array input arguments must have a length which is a multiple of two
|
||||
* @throws if provided only a single argument, must provide a valid argument
|
||||
* @throws byte offset must be a nonnegative integer
|
||||
* @throws byte offset must be a multiple of `8`
|
||||
* @throws view length must be a positive multiple of `8`
|
||||
* @throws must provide sufficient memory to accommodate byte offset and view length requirements
|
||||
* @throws an iterator must return either a two element array containing real and imaginary components or a complex number
|
||||
* @returns complex number array
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array();
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var arr = new Complex64Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf, 8 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( `@stdlib/array/buffer` );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex64Array( buf, 8, 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
declare var ctor: Constructor;
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
export = ctor;
|
153
js/node_modules/@stdlib/array/complex64/docs/types/test.ts
generated
vendored
Normal file
153
js/node_modules/@stdlib/array/complex64/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// tslint:disable:no-unused-expression
|
||||
|
||||
import Complex64Array = require( './index' );
|
||||
import Complex64 = require( '@stdlib/complex/float32' );
|
||||
import ArrayBuffer = require( './../../../buffer' );
|
||||
import real = require( '@stdlib/complex/real' );
|
||||
import imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
const clbk = ( v: Complex64 ) => {
|
||||
return new Complex64( real( v ) * 2.0, imag( v ) * 2.0 );
|
||||
};
|
||||
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns a complex number array...
|
||||
{
|
||||
new Complex64Array(); // $ExpectType Complex64Array
|
||||
Complex64Array(); // $ExpectType Complex64Array
|
||||
new Complex64Array( 2 ); // $ExpectType Complex64Array
|
||||
Complex64Array( 2 ); // $ExpectType Complex64Array
|
||||
new Complex64Array( [ 1.0, -1.0 ] ); // $ExpectType Complex64Array
|
||||
Complex64Array( [ 1.0, -1.0 ] ); // $ExpectType Complex64Array
|
||||
|
||||
const buf = new ArrayBuffer( 16 );
|
||||
new Complex64Array( buf ); // $ExpectType Complex64Array
|
||||
Complex64Array( buf ); // $ExpectType Complex64Array
|
||||
new Complex64Array( buf, 8 ); // $ExpectType Complex64Array
|
||||
Complex64Array( buf, 8 ); // $ExpectType Complex64Array
|
||||
new Complex64Array( buf, 8, 2 ); // $ExpectType Complex64Array
|
||||
Complex64Array( buf, 8, 2 ); // $ExpectType Complex64Array
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer...
|
||||
{
|
||||
new Complex64Array( true ); // $ExpectError
|
||||
new Complex64Array( false ); // $ExpectError
|
||||
new Complex64Array( null ); // $ExpectError
|
||||
new Complex64Array( 'abc' ); // $ExpectError
|
||||
new Complex64Array( {} ); // $ExpectError
|
||||
new Complex64Array( ( x: number ): number => x ); // $ExpectError
|
||||
|
||||
Complex64Array( true ); // $ExpectError
|
||||
Complex64Array( false ); // $ExpectError
|
||||
Complex64Array( null ); // $ExpectError
|
||||
Complex64Array( 'abc' ); // $ExpectError
|
||||
Complex64Array( {} ); // $ExpectError
|
||||
Complex64Array( ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a second argument that is not a number...
|
||||
{
|
||||
const buf = new ArrayBuffer( 16 );
|
||||
new Complex64Array( buf, true ); // $ExpectError
|
||||
new Complex64Array( buf, false ); // $ExpectError
|
||||
new Complex64Array( buf, null ); // $ExpectError
|
||||
new Complex64Array( buf, 'abc' ); // $ExpectError
|
||||
new Complex64Array( buf, {} ); // $ExpectError
|
||||
new Complex64Array( buf, ( x: number ): number => x ); // $ExpectError
|
||||
|
||||
Complex64Array( buf, true ); // $ExpectError
|
||||
Complex64Array( buf, false ); // $ExpectError
|
||||
Complex64Array( buf, null ); // $ExpectError
|
||||
Complex64Array( buf, 'abc' ); // $ExpectError
|
||||
Complex64Array( buf, {} ); // $ExpectError
|
||||
Complex64Array( buf, ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a third argument that is not a number...
|
||||
{
|
||||
const buf = new ArrayBuffer( 16 );
|
||||
new Complex64Array( buf, 8, true ); // $ExpectError
|
||||
new Complex64Array( buf, 8, false ); // $ExpectError
|
||||
new Complex64Array( buf, 8, null ); // $ExpectError
|
||||
new Complex64Array( buf, 8, 'abc' ); // $ExpectError
|
||||
new Complex64Array( buf, 8, {} ); // $ExpectError
|
||||
new Complex64Array( buf, 8, ( x: number ): number => x ); // $ExpectError
|
||||
|
||||
Complex64Array( buf, 8, true ); // $ExpectError
|
||||
Complex64Array( buf, 8, false ); // $ExpectError
|
||||
Complex64Array( buf, 8, null ); // $ExpectError
|
||||
Complex64Array( buf, 8, 'abc' ); // $ExpectError
|
||||
Complex64Array( buf, 8, {} ); // $ExpectError
|
||||
Complex64Array( buf, 8, ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The `from` method returns a complex number array...
|
||||
{
|
||||
Complex64Array.from( [ 1.0, 1.0 ] ); // $ExpectType Complex64Array
|
||||
Complex64Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Complex64Array
|
||||
Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk, {} ); // $ExpectType Complex64Array
|
||||
}
|
||||
|
||||
// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable...
|
||||
{
|
||||
Complex64Array.from( true ); // $ExpectError
|
||||
Complex64Array.from( false ); // $ExpectError
|
||||
Complex64Array.from( 123 ); // $ExpectError
|
||||
Complex64Array.from( null ); // $ExpectError
|
||||
Complex64Array.from( {} ); // $ExpectError
|
||||
|
||||
Complex64Array.from( true, clbk ); // $ExpectError
|
||||
Complex64Array.from( false, clbk ); // $ExpectError
|
||||
Complex64Array.from( 123, clbk ); // $ExpectError
|
||||
Complex64Array.from( null, clbk ); // $ExpectError
|
||||
Complex64Array.from( {}, clbk ); // $ExpectError
|
||||
|
||||
Complex64Array.from( true, clbk, {} ); // $ExpectError
|
||||
Complex64Array.from( false, clbk, {} ); // $ExpectError
|
||||
Complex64Array.from( 123, clbk, {} ); // $ExpectError
|
||||
Complex64Array.from( null, clbk, {} ); // $ExpectError
|
||||
Complex64Array.from( {}, clbk, {} ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature...
|
||||
{
|
||||
Complex64Array.from( [ 1, 1 ], true ); // $ExpectError
|
||||
Complex64Array.from( [ 1, 1 ], false ); // $ExpectError
|
||||
Complex64Array.from( [ 1, 1 ], 123 ); // $ExpectError
|
||||
Complex64Array.from( [ 1, 1 ], null ); // $ExpectError
|
||||
Complex64Array.from( [ 1, 1 ], {} ); // $ExpectError
|
||||
}
|
||||
|
||||
// The `of` method returns a complex number array...
|
||||
{
|
||||
Complex64Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Complex64Array
|
||||
}
|
||||
|
||||
// The compiler throws an error if the `of` method is provided arguments that are not numbers...
|
||||
{
|
||||
Complex64Array.of( 'abc', 'def' ); // $ExpectError
|
||||
Complex64Array.of( true, false ); // $ExpectError
|
||||
Complex64Array.of( {}, [] ); // $ExpectError
|
||||
Complex64Array.of( null, null ); // $ExpectError
|
||||
}
|
61
js/node_modules/@stdlib/array/complex64/lib/from_array.js
generated
vendored
Normal file
61
js/node_modules/@stdlib/array/complex64/lib/from_array.js
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Returns a strided array of real and imaginary components.
|
||||
*
|
||||
* @private
|
||||
* @param {Float32Array} buf - output array
|
||||
* @param {Array} arr - array containing complex numbers
|
||||
* @returns {(Float32Array|null)} output array or null
|
||||
*/
|
||||
function fromArray( buf, arr ) {
|
||||
var len;
|
||||
var v;
|
||||
var i;
|
||||
var j;
|
||||
|
||||
len = arr.length;
|
||||
j = 0;
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
v = arr[ i ];
|
||||
if ( !isComplexLike( v ) ) {
|
||||
return null;
|
||||
}
|
||||
buf[ j ] = real( v );
|
||||
buf[ j+1 ] = imag( v );
|
||||
j += 2; // stride
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = fromArray;
|
66
js/node_modules/@stdlib/array/complex64/lib/from_iterator.js
generated
vendored
Normal file
66
js/node_modules/@stdlib/array/complex64/lib/from_iterator.js
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' );
|
||||
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Returns an array of iterated values.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} it - iterator
|
||||
* @returns {(Array|TypeError)} array or an error
|
||||
*/
|
||||
function fromIterator( it ) {
|
||||
var out;
|
||||
var v;
|
||||
var z;
|
||||
|
||||
out = [];
|
||||
while ( true ) {
|
||||
v = it.next();
|
||||
z = v.value;
|
||||
if ( z ) {
|
||||
if ( isArrayLikeObject( z ) && z.length >= 2 ) {
|
||||
out.push( z[ 0 ], z[ 1 ] );
|
||||
} else if ( isComplexLike( z ) ) {
|
||||
out.push( real( z ), imag( z ) );
|
||||
} else {
|
||||
return new TypeError( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `'+z+'`.' );
|
||||
}
|
||||
}
|
||||
if ( v.done ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = fromIterator;
|
72
js/node_modules/@stdlib/array/complex64/lib/from_iterator_map.js
generated
vendored
Normal file
72
js/node_modules/@stdlib/array/complex64/lib/from_iterator_map.js
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' );
|
||||
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
|
||||
var real = require( '@stdlib/complex/real' );
|
||||
var imag = require( '@stdlib/complex/imag' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Returns an array of iterated values.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} it - iterator
|
||||
* @param {Function} clbk - callback to invoke for each iterated value
|
||||
* @param {*} thisArg - invocation context
|
||||
* @returns {(Array|TypeError)} array or an error
|
||||
*/
|
||||
function fromIteratorMap( it, clbk, thisArg ) {
|
||||
var out;
|
||||
var v;
|
||||
var z;
|
||||
var i;
|
||||
|
||||
out = [];
|
||||
i = -1;
|
||||
while ( true ) {
|
||||
i += 1;
|
||||
v = it.next();
|
||||
z = v.value;
|
||||
if ( z ) {
|
||||
z = clbk.call( thisArg, z, i );
|
||||
if ( isArrayLikeObject( z ) && z.length >= 2 ) {
|
||||
out.push( z[ 0 ], z[ 1 ] );
|
||||
} else if ( isComplexLike( z ) ) {
|
||||
out.push( real( z ), imag( z ) );
|
||||
} else {
|
||||
return new TypeError( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `'+z+'`.' );
|
||||
}
|
||||
}
|
||||
if ( v.done ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = fromIteratorMap;
|
94
js/node_modules/@stdlib/array/complex64/lib/index.js
generated
vendored
Normal file
94
js/node_modules/@stdlib/array/complex64/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 64-bit complex number array.
|
||||
*
|
||||
* @module @stdlib/array/complex64
|
||||
*
|
||||
* @example
|
||||
* var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
*
|
||||
* var arr = new Complex64Array();
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 0
|
||||
*
|
||||
* @example
|
||||
* var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
*
|
||||
* var arr = new Complex64Array( 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
*
|
||||
* var arr = new Complex64Array( [ 1.0, -1.0 ] );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 1
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
* var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
* var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 16 );
|
||||
* var arr = new Complex64Array( buf, 8 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
* var Complex64Array = require( '@stdlib/array/complex64' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 32 );
|
||||
* var arr = new Complex64Array( buf, 8, 2 );
|
||||
* // returns <Complex64Array>
|
||||
*
|
||||
* var len = arr.length;
|
||||
* // returns 2
|
||||
*/
|
||||
|
||||
// MODULES //
|
||||
|
||||
var Complex64Array = require( './main.js' );
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = Complex64Array;
|
1074
js/node_modules/@stdlib/array/complex64/lib/main.js
generated
vendored
Normal file
1074
js/node_modules/@stdlib/array/complex64/lib/main.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
72
js/node_modules/@stdlib/array/complex64/package.json
generated
vendored
Normal file
72
js/node_modules/@stdlib/array/complex64/package.json
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "@stdlib/array/complex64",
|
||||
"version": "0.0.0",
|
||||
"description": "Complex64Array.",
|
||||
"license": "Apache-2.0",
|
||||
"author": {
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"directories": {
|
||||
"benchmark": "./benchmark",
|
||||
"doc": "./docs",
|
||||
"example": "./examples",
|
||||
"lib": "./lib",
|
||||
"test": "./test"
|
||||
},
|
||||
"types": "./docs/types",
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/stdlib-js/stdlib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stdlib-js/stdlib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stdlib-js/stdlib/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.10.0",
|
||||
"npm": ">2.7.0"
|
||||
},
|
||||
"os": [
|
||||
"aix",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"macos",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32",
|
||||
"windows"
|
||||
],
|
||||
"keywords": [
|
||||
"stdlib",
|
||||
"stdtypes",
|
||||
"types",
|
||||
"data",
|
||||
"structure",
|
||||
"array",
|
||||
"typed",
|
||||
"typed array",
|
||||
"typed-array",
|
||||
"complex64array",
|
||||
"complex64",
|
||||
"complex",
|
||||
"cmplx",
|
||||
"real",
|
||||
"imaginary",
|
||||
"imag",
|
||||
"float",
|
||||
"single-precision",
|
||||
"ieee754"
|
||||
]
|
||||
}
|
139
js/node_modules/@stdlib/array/convert-same/README.md
generated
vendored
Normal file
139
js/node_modules/@stdlib/array/convert-same/README.md
generated
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2018 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# Convert
|
||||
|
||||
> Convert an array to the same data type as a second input array.
|
||||
|
||||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="intro">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.intro -->
|
||||
|
||||
<!-- Package usage documentation. -->
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var convertArraySame = require( '@stdlib/array/convert-same' );
|
||||
```
|
||||
|
||||
#### convertArraySame( x, y )
|
||||
|
||||
Converts an `array` to the same data type as a second input `array`.
|
||||
|
||||
```javascript
|
||||
var Float32Array = require( '@stdlib/array/float32' );
|
||||
|
||||
var y = new Float32Array( 0 );
|
||||
|
||||
var x = [ 1.0, 2.0, 3.0 ];
|
||||
var out = convertArraySame( x, y );
|
||||
// returns <Float32Array>[ 1.0, 2.0, 3.0 ]
|
||||
```
|
||||
|
||||
The function supports input arrays having the following data types:
|
||||
|
||||
- `float32`: single-precision floating-point numbers.
|
||||
- `float64`: double-precision floating-point numbers.
|
||||
- `generic`: values of any type.
|
||||
- `int16`: signed 16-bit integers.
|
||||
- `int32`: signed 32-bit integers.
|
||||
- `int8`: signed 8-bit integers.
|
||||
- `uint16`: unsigned 16-bit integers.
|
||||
- `uint32`: unsigned 32-bit integers.
|
||||
- `uint8`: unsigned 8-bit integers.
|
||||
- `uint8c`: unsigned clamped 8-bit integers.
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<!-- Package usage examples. -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- eslint-disable stdlib/new-cap-error -->
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var dtypes = require( '@stdlib/array/dtypes' );
|
||||
var ctors = require( '@stdlib/array/ctors' );
|
||||
var randu = require( '@stdlib/random/base/randu' );
|
||||
var floor = require( '@stdlib/math/base/special/floor' );
|
||||
var convertArraySame = require( '@stdlib/array/convert-same' );
|
||||
|
||||
// Create a generic array:
|
||||
var x = [];
|
||||
var i;
|
||||
for ( i = 0; i < 5; i++ ) {
|
||||
x.push( floor( randu()*1.0e25 ) - 5.0e24 );
|
||||
}
|
||||
|
||||
// Get a list of array data types:
|
||||
var DTYPES = dtypes();
|
||||
|
||||
// Convert the generic array to each array data type:
|
||||
var ctor;
|
||||
var out;
|
||||
var y;
|
||||
for ( i = 0; i < DTYPES.length; i++ ) {
|
||||
ctor = ctors( DTYPES[ i ] );
|
||||
y = new ctor( 0 );
|
||||
out = convertArraySame( x, y );
|
||||
console.log( out );
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="references">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.references -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
40
js/node_modules/@stdlib/array/convert-same/docs/repl.txt
generated
vendored
Normal file
40
js/node_modules/@stdlib/array/convert-same/docs/repl.txt
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
|
||||
{{alias}}( x, y )
|
||||
Converts an input array to the same data type as a second input array.
|
||||
|
||||
The function supports input arrays having the following data types:
|
||||
|
||||
- float32: single-precision floating-point numbers.
|
||||
- float64: double-precision floating-point numbers.
|
||||
- generic: values of any type.
|
||||
- int16: signed 16-bit integers.
|
||||
- int32: signed 32-bit integers.
|
||||
- int8: signed 8-bit integers.
|
||||
- uint16: unsigned 16-bit integers.
|
||||
- uint32: unsigned 32-bit integers.
|
||||
- uint8: unsigned 8-bit integers.
|
||||
- uint8c: unsigned clamped 8-bit integers.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
x: Array|TypedArray
|
||||
Array to convert.
|
||||
|
||||
y: Array|TypedArray
|
||||
Array having desired output data type.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out: Array|TypedArray
|
||||
Output array.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var x = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
> var y = new {{alias:@stdlib/array/float32}}( 0 );
|
||||
> var out = {{alias}}( x, y )
|
||||
<Float32Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
53
js/node_modules/@stdlib/array/convert-same/docs/types/index.d.ts
generated
vendored
Normal file
53
js/node_modules/@stdlib/array/convert-same/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
/// <reference types="@stdlib/types"/>
|
||||
|
||||
import { TypedArray } from '@stdlib/types/array';
|
||||
import { Collection } from '@stdlib/types/object';
|
||||
|
||||
|
||||
/**
|
||||
* Array or typed array.
|
||||
*/
|
||||
type ArrayOrTypedArray = Array<any> | TypedArray;
|
||||
|
||||
/**
|
||||
* Converts an array to the same data type as a second input array.
|
||||
*
|
||||
* @param x - array to convert
|
||||
* @param y - array having the desired output data type
|
||||
* @returns output array
|
||||
*
|
||||
* @example
|
||||
* var Float64Array = require( `@stdlib/array/float64` );
|
||||
*
|
||||
* var y = new Float64Array( 0 );
|
||||
*
|
||||
* var x = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
* var out = convertSame( x, y );
|
||||
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
*/
|
||||
declare function convertSame( x: Collection, y: ArrayOrTypedArray ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
export = convertSame;
|
64
js/node_modules/@stdlib/array/convert-same/docs/types/test.ts
generated
vendored
Normal file
64
js/node_modules/@stdlib/array/convert-same/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import convertSame = require( './index' );
|
||||
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns an array or typed array...
|
||||
{
|
||||
const y = new Float64Array( 0 );
|
||||
|
||||
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], y ); // $ExpectType ArrayOrTypedArray
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a first argument which is not array-like...
|
||||
{
|
||||
const y = new Float64Array( 0 );
|
||||
|
||||
convertSame( 123, y ); // $ExpectError
|
||||
convertSame( true, y ); // $ExpectError
|
||||
convertSame( false, y ); // $ExpectError
|
||||
convertSame( {}, y ); // $ExpectError
|
||||
convertSame( null, y ); // $ExpectError
|
||||
convertSame( undefined, y ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a second argument which is not an array or typed array...
|
||||
{
|
||||
const x = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
|
||||
convertSame( x, 'abc' ); // $ExpectError
|
||||
convertSame( x, 123 ); // $ExpectError
|
||||
convertSame( x, true ); // $ExpectError
|
||||
convertSame( x, false ); // $ExpectError
|
||||
convertSame( x, {} ); // $ExpectError
|
||||
convertSame( x, null ); // $ExpectError
|
||||
convertSame( x, undefined ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
||||
{
|
||||
const x = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
const y = new Float64Array( 0 );
|
||||
|
||||
convertSame(); // $ExpectError
|
||||
convertSame( x ); // $ExpectError
|
||||
convertSame( x, y, 2 ); // $ExpectError
|
||||
}
|
44
js/node_modules/@stdlib/array/convert-same/lib/index.js
generated
vendored
Normal file
44
js/node_modules/@stdlib/array/convert-same/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Convert an array to the same data type as a second input array.
|
||||
*
|
||||
* @module @stdlib/array/convert-same
|
||||
*
|
||||
* @example
|
||||
* var convertSame = require( '@stdlib/array/convert-same' );
|
||||
* var Float64Array = require( '@stdlib/array/float64' );
|
||||
*
|
||||
* var y = new Float64Array( 0 );
|
||||
*
|
||||
* var x = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
* var out = convertSame( x, y );
|
||||
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
*/
|
||||
|
||||
// MODULES //
|
||||
|
||||
var convertSame = require( './main.js' );
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = convertSame;
|
80
js/node_modules/@stdlib/array/convert-same/lib/main.js
generated
vendored
Normal file
80
js/node_modules/@stdlib/array/convert-same/lib/main.js
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isCollection = require( '@stdlib/assert/is-collection' );
|
||||
var getType = require( './../../dtype' );
|
||||
var ctors = require( './../../ctors' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Converts an array to the same data type as a second input array.
|
||||
*
|
||||
* @param {Collection} x - array to convert
|
||||
* @param {(Array|TypedArray)} y - array having the desired output data type
|
||||
* @throws {TypeError} first argument must be an array-like object
|
||||
* @throws {TypeError} second argument must have a recognized data type
|
||||
* @returns {(Array|TypedArray)} output array
|
||||
*
|
||||
* @example
|
||||
* var Float64Array = require( '@stdlib/array/float64' );
|
||||
*
|
||||
* var y = new Float64Array( 0 );
|
||||
*
|
||||
* var x = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
* var out = convertSame( x, y );
|
||||
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
*/
|
||||
function convertSame( x, y ) {
|
||||
var dtype;
|
||||
var ctor;
|
||||
var out;
|
||||
var len;
|
||||
var i;
|
||||
if ( !isCollection( x ) ) {
|
||||
throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + x + '`.' );
|
||||
}
|
||||
dtype = getType( y );
|
||||
ctor = ctors( dtype );
|
||||
if ( ctor === null ) {
|
||||
throw new TypeError( 'invalid argument. Second argument must have a recognized data type. Value: `' + dtype + '`.' );
|
||||
}
|
||||
len = x.length;
|
||||
if ( dtype === 'generic' ) {
|
||||
out = [];
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
out.push( x[ i ] ); // ensure "fast" elements
|
||||
}
|
||||
return out;
|
||||
}
|
||||
out = new ctor( len );
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
out[ i ] = x[ i ];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = convertSame;
|
67
js/node_modules/@stdlib/array/convert-same/package.json
generated
vendored
Normal file
67
js/node_modules/@stdlib/array/convert-same/package.json
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"name": "@stdlib/array/convert-same",
|
||||
"version": "0.0.0",
|
||||
"description": "Convert an array to the same data type as a second input array.",
|
||||
"license": "Apache-2.0",
|
||||
"author": {
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"directories": {
|
||||
"benchmark": "./benchmark",
|
||||
"doc": "./docs",
|
||||
"example": "./examples",
|
||||
"lib": "./lib",
|
||||
"test": "./test"
|
||||
},
|
||||
"types": "./docs/types",
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/stdlib-js/stdlib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stdlib-js/stdlib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stdlib-js/stdlib/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.10.0",
|
||||
"npm": ">2.7.0"
|
||||
},
|
||||
"os": [
|
||||
"aix",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"macos",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32",
|
||||
"windows"
|
||||
],
|
||||
"keywords": [
|
||||
"stdlib",
|
||||
"stdtypes",
|
||||
"types",
|
||||
"data",
|
||||
"structure",
|
||||
"array",
|
||||
"typed",
|
||||
"typed array",
|
||||
"typed-array",
|
||||
"convert",
|
||||
"cast",
|
||||
"transform",
|
||||
"copy",
|
||||
"duplicate"
|
||||
]
|
||||
}
|
128
js/node_modules/@stdlib/array/convert/README.md
generated
vendored
Normal file
128
js/node_modules/@stdlib/array/convert/README.md
generated
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2018 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# Convert
|
||||
|
||||
> Convert an array to an array of a different data type.
|
||||
|
||||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="intro">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.intro -->
|
||||
|
||||
<!-- Package usage documentation. -->
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var convertArray = require( '@stdlib/array/convert' );
|
||||
```
|
||||
|
||||
#### convertArray( arr, dtype )
|
||||
|
||||
Converts an `array` to an array of a different data type.
|
||||
|
||||
```javascript
|
||||
var arr = [ 1.0, 2.0, 3.0 ];
|
||||
var out = convertArray( arr, 'float32' );
|
||||
// returns <Float32Array>[ 1.0, 2.0, 3.0 ]
|
||||
```
|
||||
|
||||
The function supports the following data types:
|
||||
|
||||
- `float32`: single-precision floating-point numbers.
|
||||
- `float64`: double-precision floating-point numbers.
|
||||
- `generic`: values of any type.
|
||||
- `int16`: signed 16-bit integers.
|
||||
- `int32`: signed 32-bit integers.
|
||||
- `int8`: signed 8-bit integers.
|
||||
- `uint16`: unsigned 16-bit integers.
|
||||
- `uint32`: unsigned 32-bit integers.
|
||||
- `uint8`: unsigned 8-bit integers.
|
||||
- `uint8c`: unsigned clamped 8-bit integers.
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<!-- Package usage examples. -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var dtypes = require( '@stdlib/array/dtypes' );
|
||||
var randu = require( '@stdlib/random/base/randu' );
|
||||
var floor = require( '@stdlib/math/base/special/floor' );
|
||||
var convertArray = require( '@stdlib/array/convert' );
|
||||
|
||||
// Create a generic array:
|
||||
var arr = [];
|
||||
var i;
|
||||
for ( i = 0; i < 5; i++ ) {
|
||||
arr.push( floor( randu()*1.0e25 ) - 5.0e24 );
|
||||
}
|
||||
|
||||
// Get a list of array data types:
|
||||
var DTYPES = dtypes();
|
||||
|
||||
// Convert the generic array to each array data type:
|
||||
var out;
|
||||
for ( i = 0; i < DTYPES.length; i++ ) {
|
||||
out = convertArray( arr, DTYPES[ i ] );
|
||||
console.log( out );
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="references">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.references -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
39
js/node_modules/@stdlib/array/convert/docs/repl.txt
generated
vendored
Normal file
39
js/node_modules/@stdlib/array/convert/docs/repl.txt
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
{{alias}}( arr, dtype )
|
||||
Converts an input array to an array of a different data type.
|
||||
|
||||
The function supports the following data types:
|
||||
|
||||
- float32: single-precision floating-point numbers.
|
||||
- float64: double-precision floating-point numbers.
|
||||
- generic: values of any type.
|
||||
- int16: signed 16-bit integers.
|
||||
- int32: signed 32-bit integers.
|
||||
- int8: signed 8-bit integers.
|
||||
- uint16: unsigned 16-bit integers.
|
||||
- uint32: unsigned 32-bit integers.
|
||||
- uint8: unsigned 8-bit integers.
|
||||
- uint8c: unsigned clamped 8-bit integers.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
arr: Array|TypedArray
|
||||
Array to convert.
|
||||
|
||||
dtype: string
|
||||
Output data type.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out: Array|TypedArray
|
||||
Output array.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var arr = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
> var out = {{alias}}( arr, 'float32' )
|
||||
<Float32Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
53
js/node_modules/@stdlib/array/convert/docs/types/index.d.ts
generated
vendored
Normal file
53
js/node_modules/@stdlib/array/convert/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
/// <reference types="@stdlib/types"/>
|
||||
|
||||
import { TypedArray } from '@stdlib/types/array';
|
||||
import { Collection } from '@stdlib/types/object';
|
||||
|
||||
/**
|
||||
* Array data type.
|
||||
*/
|
||||
type DataType = 'float32' | 'float64' | 'generic' | 'int16' | 'int32' | 'int8' | 'uint16' | 'uint32' | 'uint8' | 'uint8c'; // tslint:disable-line:max-line-length unified-signatures
|
||||
|
||||
/**
|
||||
* Array or typed array.
|
||||
*/
|
||||
type ArrayOrTypedArray = Array<any> | TypedArray;
|
||||
|
||||
/**
|
||||
* Converts an array to an array of a different data type.
|
||||
*
|
||||
* @param x - array to convert
|
||||
* @param dtype - output data type
|
||||
* @returns output array
|
||||
*
|
||||
* @example
|
||||
* var arr = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
* var out = convert( arr, 'float64' );
|
||||
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
*/
|
||||
declare function convert( x: Collection, dtype: DataType ): ArrayOrTypedArray;
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
export = convert;
|
56
js/node_modules/@stdlib/array/convert/docs/types/test.ts
generated
vendored
Normal file
56
js/node_modules/@stdlib/array/convert/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import convert = require( './index' );
|
||||
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns an array or typed array...
|
||||
{
|
||||
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int32' ); // $ExpectType ArrayOrTypedArray
|
||||
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float32' ); // $ExpectType ArrayOrTypedArray
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a first argument which is not array-like...
|
||||
{
|
||||
convert( 123, 'float64' ); // $ExpectError
|
||||
convert( true, 'float64' ); // $ExpectError
|
||||
convert( false, 'float64' ); // $ExpectError
|
||||
convert( {}, 'float64' ); // $ExpectError
|
||||
convert( null, 'float64' ); // $ExpectError
|
||||
convert( undefined, 'float64' ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a second argument which is not a known data type...
|
||||
{
|
||||
convert( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError
|
||||
convert( [ 1, 2, 3, 4 ], 123 ); // $ExpectError
|
||||
convert( [ 1, 2, 3, 4 ], [] ); // $ExpectError
|
||||
convert( [ 1, 2, 3, 4 ], {} ); // $ExpectError
|
||||
convert( [ 1, 2, 3, 4 ], true ); // $ExpectError
|
||||
convert( [ 1, 2, 3, 4 ], false ); // $ExpectError
|
||||
convert( [ 1, 2, 3, 4 ], null ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
||||
{
|
||||
convert(); // $ExpectError
|
||||
convert( [ 1.0, 2.0, 3.0, 4.0 ] ); // $ExpectError
|
||||
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float64', 2 ); // $ExpectError
|
||||
}
|
41
js/node_modules/@stdlib/array/convert/lib/index.js
generated
vendored
Normal file
41
js/node_modules/@stdlib/array/convert/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Convert an array to an array of a different data type.
|
||||
*
|
||||
* @module @stdlib/array/convert
|
||||
*
|
||||
* @example
|
||||
* var convert = require( '@stdlib/array/convert' );
|
||||
*
|
||||
* var arr = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
* var out = convert( arr, 'float64' );
|
||||
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
*/
|
||||
|
||||
// MODULES //
|
||||
|
||||
var convert = require( './main.js' );
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = convert;
|
73
js/node_modules/@stdlib/array/convert/lib/main.js
generated
vendored
Normal file
73
js/node_modules/@stdlib/array/convert/lib/main.js
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var isCollection = require( '@stdlib/assert/is-collection' );
|
||||
var ctors = require( './../../ctors' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Converts an array to an array of a different data type.
|
||||
*
|
||||
* @param {Collection} x - array to convert
|
||||
* @param {string} dtype - output data type
|
||||
* @throws {TypeError} first argument must be an array-like object
|
||||
* @throws {TypeError} second argument must be a recognized array data type
|
||||
* @returns {(Array|TypedArray)} output array
|
||||
*
|
||||
* @example
|
||||
* var arr = [ 1.0, 2.0, 3.0, 4.0 ];
|
||||
* var out = convert( arr, 'float64' );
|
||||
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
|
||||
*/
|
||||
function convert( x, dtype ) {
|
||||
var ctor;
|
||||
var out;
|
||||
var len;
|
||||
var i;
|
||||
if ( !isCollection( x ) ) {
|
||||
throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + x + '`.' );
|
||||
}
|
||||
len = x.length;
|
||||
ctor = ctors( dtype );
|
||||
if ( ctor === null ) {
|
||||
throw new TypeError( 'invalid argument. Second argument must be a recognized array data type. Value: `' + dtype + '`.' );
|
||||
}
|
||||
if ( dtype === 'generic' ) {
|
||||
out = [];
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
out.push( x[ i ] ); // ensure "fast" elements
|
||||
}
|
||||
return out;
|
||||
}
|
||||
out = new ctor( len );
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
out[ i ] = x[ i ];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = convert;
|
67
js/node_modules/@stdlib/array/convert/package.json
generated
vendored
Normal file
67
js/node_modules/@stdlib/array/convert/package.json
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"name": "@stdlib/array/convert",
|
||||
"version": "0.0.0",
|
||||
"description": "Convert an array to an array of a different data type.",
|
||||
"license": "Apache-2.0",
|
||||
"author": {
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"directories": {
|
||||
"benchmark": "./benchmark",
|
||||
"doc": "./docs",
|
||||
"example": "./examples",
|
||||
"lib": "./lib",
|
||||
"test": "./test"
|
||||
},
|
||||
"types": "./docs/types",
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/stdlib-js/stdlib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stdlib-js/stdlib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stdlib-js/stdlib/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.10.0",
|
||||
"npm": ">2.7.0"
|
||||
},
|
||||
"os": [
|
||||
"aix",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"macos",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32",
|
||||
"windows"
|
||||
],
|
||||
"keywords": [
|
||||
"stdlib",
|
||||
"stdtypes",
|
||||
"types",
|
||||
"data",
|
||||
"structure",
|
||||
"array",
|
||||
"typed",
|
||||
"typed array",
|
||||
"typed-array",
|
||||
"convert",
|
||||
"cast",
|
||||
"transform",
|
||||
"copy",
|
||||
"duplicate"
|
||||
]
|
||||
}
|
124
js/node_modules/@stdlib/array/ctors/README.md
generated
vendored
Normal file
124
js/node_modules/@stdlib/array/ctors/README.md
generated
vendored
Normal file
|
@ -0,0 +1,124 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2018 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# Constructors
|
||||
|
||||
> Array constructors.
|
||||
|
||||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="intro">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.intro -->
|
||||
|
||||
<!-- Package usage documentation. -->
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var ctors = require( '@stdlib/array/ctors' );
|
||||
```
|
||||
|
||||
#### ctors( dtype )
|
||||
|
||||
Returns an array constructor for a specified data type.
|
||||
|
||||
```javascript
|
||||
var ctor = ctors( 'float64' );
|
||||
// returns <Function>
|
||||
```
|
||||
|
||||
The function returns constructors for the following data types:
|
||||
|
||||
- `float32`: single-precision floating-point numbers.
|
||||
- `float64`: double-precision floating-point numbers.
|
||||
- `generic`: values of any type.
|
||||
- `int16`: signed 16-bit integers.
|
||||
- `int32`: signed 32-bit integers.
|
||||
- `int8`: signed 8-bit integers.
|
||||
- `uint16`: unsigned 16-bit integers.
|
||||
- `uint32`: unsigned 32-bit integers.
|
||||
- `uint8`: unsigned 8-bit integers.
|
||||
- `uint8c`: unsigned clamped 8-bit integers.
|
||||
|
||||
If provided an unknown or unsupported data type, the function returns `null`.
|
||||
|
||||
```javascript
|
||||
var ctor = ctors( 'float' );
|
||||
// returns null
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<!-- Package usage examples. -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var dtypes = require( '@stdlib/array/dtypes' );
|
||||
var ctors = require( '@stdlib/array/ctors' );
|
||||
|
||||
var DTYPES = dtypes();
|
||||
var ctor;
|
||||
var i;
|
||||
|
||||
for ( i = 0; i < DTYPES.length; i++ ) {
|
||||
ctor = ctors( DTYPES[ i ] );
|
||||
console.log( ctor );
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="references">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.references -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
37
js/node_modules/@stdlib/array/ctors/docs/repl.txt
generated
vendored
Normal file
37
js/node_modules/@stdlib/array/ctors/docs/repl.txt
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
{{alias}}( dtype )
|
||||
Returns an array constructor.
|
||||
|
||||
The function returns constructors for the following data types:
|
||||
|
||||
- float32: single-precision floating-point numbers.
|
||||
- float64: double-precision floating-point numbers.
|
||||
- generic: values of any type.
|
||||
- int16: signed 16-bit integers.
|
||||
- int32: signed 32-bit integers.
|
||||
- int8: signed 8-bit integers.
|
||||
- uint16: unsigned 16-bit integers.
|
||||
- uint32: unsigned 32-bit integers.
|
||||
- uint8: unsigned 8-bit integers.
|
||||
- uint8c: unsigned clamped 8-bit integers.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
dtype: string
|
||||
Data type.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out: Function|null
|
||||
Constructor.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var ctor = {{alias}}( 'float64' )
|
||||
<Function>
|
||||
> ctor = {{alias}}( 'float' )
|
||||
null
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
40
js/node_modules/@stdlib/array/ctors/docs/types/index.d.ts
generated
vendored
Normal file
40
js/node_modules/@stdlib/array/ctors/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
/**
|
||||
* Returns an array constructor.
|
||||
*
|
||||
* @param dtype - data type
|
||||
* @returns constructor or null
|
||||
*
|
||||
* @example
|
||||
* var ctor = ctors( 'float64' );
|
||||
* // returns <Function>
|
||||
*
|
||||
* @example
|
||||
* var ctor = ctors( 'float' );
|
||||
* // returns null
|
||||
*/
|
||||
declare function ctors( dtype: string ): Function | null;
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
export = ctors;
|
33
js/node_modules/@stdlib/array/ctors/docs/types/test.ts
generated
vendored
Normal file
33
js/node_modules/@stdlib/array/ctors/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import ctors = require( './index' );
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns a function or null..
|
||||
{
|
||||
ctors( 'float64' ); // $ExpectType Function | null
|
||||
ctors( 'float' ); // $ExpectType Function | null
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
||||
{
|
||||
ctors(); // $ExpectError
|
||||
ctors( 'int32', 3 ); // $ExpectError
|
||||
}
|
53
js/node_modules/@stdlib/array/ctors/lib/ctors.js
generated
vendored
Normal file
53
js/node_modules/@stdlib/array/ctors/lib/ctors.js
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var Float64Array = require( './../../float64' );
|
||||
var Float32Array = require( './../../float32' );
|
||||
var Int16Array = require( './../../int16' );
|
||||
var Int32Array = require( './../../int32' );
|
||||
var Int8Array = require( './../../int8' );
|
||||
var Uint16Array = require( './../../uint16' );
|
||||
var Uint32Array = require( './../../uint32' );
|
||||
var Uint8Array = require( './../../uint8' );
|
||||
var Uint8ClampedArray = require( './../../uint8c' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
// Mapping from data types to constructors...
|
||||
var ctors = {
|
||||
'float64': Float64Array,
|
||||
'float32': Float32Array,
|
||||
'generic': Array, // TODO: replace with `stdlib` pkg
|
||||
'int16': Int16Array,
|
||||
'int32': Int32Array,
|
||||
'int8': Int8Array,
|
||||
'uint16': Uint16Array,
|
||||
'uint32': Uint32Array,
|
||||
'uint8': Uint8Array,
|
||||
'uint8c': Uint8ClampedArray
|
||||
};
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = ctors;
|
43
js/node_modules/@stdlib/array/ctors/lib/index.js
generated
vendored
Normal file
43
js/node_modules/@stdlib/array/ctors/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Array constructors.
|
||||
*
|
||||
* @module @stdlib/array/ctors
|
||||
*
|
||||
* @example
|
||||
* var ctors = require( '@stdlib/array/ctors' );
|
||||
*
|
||||
* var ctor = ctors( 'float64' );
|
||||
* // returns <Function>
|
||||
*
|
||||
* ctor = ctors( 'int' );
|
||||
* // returns null
|
||||
*/
|
||||
|
||||
// MODULES //
|
||||
|
||||
var ctors = require( './main.js' );
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = ctors;
|
49
js/node_modules/@stdlib/array/ctors/lib/main.js
generated
vendored
Normal file
49
js/node_modules/@stdlib/array/ctors/lib/main.js
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2018 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MODULES //
|
||||
|
||||
var table = require( './ctors.js' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Returns an array constructor.
|
||||
*
|
||||
* @param {string} dtype - data type
|
||||
* @returns {(Function|null)} constructor or null
|
||||
*
|
||||
* @example
|
||||
* var ctor = ctors( 'float64' );
|
||||
* // returns <Function>
|
||||
*
|
||||
* @example
|
||||
* var ctor = ctors( 'float' );
|
||||
* // returns null
|
||||
*/
|
||||
function ctors( dtype ) {
|
||||
return table[ dtype ] || null;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = ctors;
|
71
js/node_modules/@stdlib/array/ctors/package.json
generated
vendored
Normal file
71
js/node_modules/@stdlib/array/ctors/package.json
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"name": "@stdlib/array/ctors",
|
||||
"version": "0.0.0",
|
||||
"description": "Array constructors.",
|
||||
"license": "Apache-2.0",
|
||||
"author": {
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"directories": {
|
||||
"benchmark": "./benchmark",
|
||||
"doc": "./docs",
|
||||
"example": "./examples",
|
||||
"lib": "./lib",
|
||||
"test": "./test"
|
||||
},
|
||||
"types": "./docs/types",
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/stdlib-js/stdlib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stdlib-js/stdlib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stdlib-js/stdlib/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.10.0",
|
||||
"npm": ">2.7.0"
|
||||
},
|
||||
"os": [
|
||||
"aix",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"macos",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32",
|
||||
"windows"
|
||||
],
|
||||
"keywords": [
|
||||
"stdlib",
|
||||
"stdtypes",
|
||||
"types",
|
||||
"array",
|
||||
"list",
|
||||
"dtypes",
|
||||
"dtype",
|
||||
"data",
|
||||
"structure",
|
||||
"constructors",
|
||||
"constructor",
|
||||
"ctors",
|
||||
"ctor",
|
||||
"utilities",
|
||||
"utility",
|
||||
"utils",
|
||||
"util"
|
||||
],
|
||||
"__stdlib__": {}
|
||||
}
|
191
js/node_modules/@stdlib/array/dataview/README.md
generated
vendored
Normal file
191
js/node_modules/@stdlib/array/dataview/README.md
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2021 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# DataView
|
||||
|
||||
> [Constructor][mdn-dataview] which returns a data view representing a provided array buffer.
|
||||
|
||||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="intro">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.intro -->
|
||||
|
||||
<!-- Package usage documentation. -->
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var DataView = require( '@stdlib/array/dataview' );
|
||||
```
|
||||
|
||||
#### DataView( buffer\[, byteOffset\[, byteLength]] )
|
||||
|
||||
Returns a [`DataView`][mdn-dataview] representing a provided array buffer.
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
|
||||
var buf = new ArrayBuffer( 5 );
|
||||
// returns <ArrayBuffer>
|
||||
|
||||
var dv = new DataView( buf );
|
||||
// returns <DataView>
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
### Properties
|
||||
|
||||
#### DataView.prototype.buffer
|
||||
|
||||
**Read-only** property which returns the underlying array buffer.
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
|
||||
var buf1 = new ArrayBuffer( 5 );
|
||||
var dv = new DataView( buf1 );
|
||||
|
||||
var buf2 = dv.buffer;
|
||||
// returns <ArrayBuffer>
|
||||
|
||||
var bool = ( buf1 === buf2 );
|
||||
// returns true
|
||||
```
|
||||
|
||||
#### DataView.prototype.byteLength
|
||||
|
||||
**Read-only** property which returns the length (in bytes) of the [`DataView`][mdn-dataview].
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
|
||||
var buf = new ArrayBuffer( 5 );
|
||||
var dv = new DataView( buf );
|
||||
|
||||
var byteLength = dv.byteLength;
|
||||
// returns 5
|
||||
```
|
||||
|
||||
#### DataView.prototype.byteOffset
|
||||
|
||||
**Read-only** property which returns the number of bytes from the [`DataView`][mdn-dataview] to the start of the underlying array buffer.
|
||||
|
||||
<!-- eslint-disable stdlib/require-globals -->
|
||||
|
||||
```javascript
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
|
||||
var buf = new ArrayBuffer( 5 );
|
||||
var dv = new DataView( buf, 3 );
|
||||
|
||||
var byteOffset = dv.byteOffset;
|
||||
// returns 3
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
### Methods
|
||||
|
||||
TODO: document methods
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
* * *
|
||||
|
||||
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<!-- Package usage examples. -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- eslint no-undef: "error" -->
|
||||
|
||||
```javascript
|
||||
var IS_LITTLE_ENDIAN = require( '@stdlib/assert/is-little-endian' );
|
||||
var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' );
|
||||
var randu = require( '@stdlib/random/base/randu' );
|
||||
var Uint8Array = require( '@stdlib/array/uint8' );
|
||||
var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
var DataView = require( '@stdlib/array/dataview' );
|
||||
|
||||
// Create a new ArrayBuffer:
|
||||
var buf = new ArrayBuffer( 64 );
|
||||
|
||||
// Create a new DataView:
|
||||
var dv = new DataView( buf );
|
||||
|
||||
// Set values in the view:
|
||||
var i;
|
||||
for ( i = 0; i < dv.byteLength/8; i++ ) {
|
||||
dv.setFloat64( i*8, randu()*100.0, IS_LITTLE_ENDIAN );
|
||||
}
|
||||
|
||||
// Create a "bytes" view of the underlying array buffer:
|
||||
var bytes = new Uint8Array( dv.buffer );
|
||||
|
||||
// Print the bytes:
|
||||
for ( i = 0; i < bytes.length; i++ ) {
|
||||
console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) );
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="references">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.references -->
|
||||
|
||||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
[mdn-dataview]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
74
js/node_modules/@stdlib/array/dataview/docs/repl.txt
generated
vendored
Normal file
74
js/node_modules/@stdlib/array/dataview/docs/repl.txt
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
|
||||
{{alias}}( buffer[, byteOffset[, byteLength]] )
|
||||
Returns a data view representing a provided array buffer.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
buffer: ArrayBuffer|SharedArrayBuffer
|
||||
Array buffer.
|
||||
|
||||
byteOffset: integer (optional)
|
||||
Offset (in bytes) to the first byte in the array buffer for the new view
|
||||
to reference. Default: 0.
|
||||
|
||||
byteLength: integer (optional)
|
||||
Number of elements in the byte array. If not provided, the view's length
|
||||
will equal the buffer's length.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out: DataView
|
||||
A data view.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var buf = new {{alias:@stdlib/array/buffer}}( 5 )
|
||||
<ArrayBuffer>
|
||||
> var dv = new {{alias}}( buf )
|
||||
<DataView>
|
||||
|
||||
|
||||
{{alias}}.prototype.buffer
|
||||
Read-only property which returns the underyling array buffer.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var buf1 = new {{alias:@stdlib/array/buffer}}( 5 );
|
||||
> var dv = new {{alias}}( buf1 );
|
||||
> var buf2 = dv.buffer
|
||||
<ArrayBuffer>
|
||||
> var b = ( buf1 === buf2 )
|
||||
true
|
||||
|
||||
|
||||
{{alias}}.prototype.byteLength
|
||||
Read-only property which returns the length (in bytes) of the view.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var buf = new {{alias:@stdlib/array/buffer}}( 5 );
|
||||
> var dv = new {{alias}}( buf );
|
||||
> dv.byteLength
|
||||
5
|
||||
|
||||
|
||||
{{alias}}.prototype.byteOffset
|
||||
Read-only property which returns the offset (in bytes) of the view to the
|
||||
start of the underlying array buffer.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var buf = new {{alias:@stdlib/array/buffer}}( 5 );
|
||||
> var dv = new {{alias}}( buf, 2 );
|
||||
> dv.byteLength
|
||||
3
|
||||
> dv.byteOffset
|
||||
2
|
||||
|
||||
|
||||
TODO: document properties/methods
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
26
js/node_modules/@stdlib/array/dataview/docs/types/index.d.ts
generated
vendored
Normal file
26
js/node_modules/@stdlib/array/dataview/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
/**
|
||||
* Constructor which returns a data view representing a provided array buffer.
|
||||
*/
|
||||
export = DataView;
|
38
js/node_modules/@stdlib/array/dataview/docs/types/test.ts
generated
vendored
Normal file
38
js/node_modules/@stdlib/array/dataview/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// tslint:disable: no-construct
|
||||
// tslint:disable: no-unused-expression
|
||||
|
||||
import ArrayBuffer = require( './../../../buffer' );
|
||||
import DataView = require( './index' );
|
||||
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns a data view instance...
|
||||
{
|
||||
const buf = new ArrayBuffer( 5 );
|
||||
new DataView( buf ); // $ExpectType DataView
|
||||
}
|
||||
|
||||
// The constructor function has to be invoked with `new`...
|
||||
{
|
||||
const buf = new ArrayBuffer( 5 );
|
||||
DataView( buf ); // $ExpectError
|
||||
}
|
56
js/node_modules/@stdlib/array/dataview/lib/index.js
generated
vendored
Normal file
56
js/node_modules/@stdlib/array/dataview/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Constructor which returns a data view representing a provided array buffer.
|
||||
*
|
||||
* @module @stdlib/array/dataview
|
||||
*
|
||||
* @example
|
||||
* var ArrayBuffer = require( '@stdlib/array/buffer' );
|
||||
* var DataView = require( '@stdlib/array/dataview' );
|
||||
*
|
||||
* var buf = new ArrayBuffer( 10 );
|
||||
* // returns <ArrayBuffer>
|
||||
*
|
||||
* var dv = new DataView( buf );
|
||||
* // returns <DataView>
|
||||
*/
|
||||
|
||||
// MODULES //
|
||||
|
||||
var hasDataViewSupport = require( '@stdlib/assert/has-dataview-support' );
|
||||
var builtin = require( './main.js' );
|
||||
var polyfill = require( './polyfill.js' );
|
||||
|
||||
|
||||
// MAIN //
|
||||
|
||||
var ctor;
|
||||
if ( hasDataViewSupport() ) {
|
||||
ctor = builtin;
|
||||
} else {
|
||||
ctor = polyfill;
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = ctor;
|
28
js/node_modules/@stdlib/array/dataview/lib/main.js
generated
vendored
Normal file
28
js/node_modules/@stdlib/array/dataview/lib/main.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// MAIN //
|
||||
|
||||
var ctor = ( typeof DataView === 'function' ) ? DataView : void 0; // eslint-disable-line stdlib/require-globals
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = ctor;
|
37
js/node_modules/@stdlib/array/dataview/lib/polyfill.js
generated
vendored
Normal file
37
js/node_modules/@stdlib/array/dataview/lib/polyfill.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// TODO: write polyfill
|
||||
|
||||
// MAIN //
|
||||
|
||||
/**
|
||||
* Constructor which returns a data view representing a provided array buffer.
|
||||
*
|
||||
* @throws {Error} not implemented
|
||||
*/
|
||||
function polyfill() {
|
||||
throw new Error( 'not implemented' );
|
||||
}
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
module.exports = polyfill;
|
67
js/node_modules/@stdlib/array/dataview/package.json
generated
vendored
Normal file
67
js/node_modules/@stdlib/array/dataview/package.json
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"name": "@stdlib/array/dataview",
|
||||
"version": "0.0.0",
|
||||
"description": "DataView.",
|
||||
"license": "Apache-2.0",
|
||||
"author": {
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "The Stdlib Authors",
|
||||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"directories": {
|
||||
"benchmark": "./benchmark",
|
||||
"doc": "./docs",
|
||||
"example": "./examples",
|
||||
"lib": "./lib",
|
||||
"test": "./test"
|
||||
},
|
||||
"types": "./docs/types",
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/stdlib-js/stdlib",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stdlib-js/stdlib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stdlib-js/stdlib/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.10.0",
|
||||
"npm": ">2.7.0"
|
||||
},
|
||||
"os": [
|
||||
"aix",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"macos",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32",
|
||||
"windows"
|
||||
],
|
||||
"keywords": [
|
||||
"stdlib",
|
||||
"stdtypes",
|
||||
"types",
|
||||
"data",
|
||||
"structure",
|
||||
"array",
|
||||
"typed",
|
||||
"typed array",
|
||||
"typed-array",
|
||||
"arraybuffer",
|
||||
"dataview",
|
||||
"buffer",
|
||||
"buf",
|
||||
"binary"
|
||||
]
|
||||
}
|
161
js/node_modules/@stdlib/array/datespace/README.md
generated
vendored
Normal file
161
js/node_modules/@stdlib/array/datespace/README.md
generated
vendored
Normal file
|
@ -0,0 +1,161 @@
|
|||
<!--
|
||||
|
||||
@license Apache-2.0
|
||||
|
||||
Copyright (c) 2021 The Stdlib Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
# Datespace
|
||||
|
||||
> Generate an array of linearly spaced [dates][mdn-date-object].
|
||||
|
||||
<section class="usage">
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var datespace = require( '@stdlib/array/datespace' );
|
||||
```
|
||||
|
||||
#### datespace( start, stop\[, length]\[, opts] )
|
||||
|
||||
Generates an `array` of linearly spaced [`Date`][mdn-date-object] objects. If a `length` is not provided, the default output `array` length is `100`.
|
||||
|
||||
```javascript
|
||||
var end = '2014-12-02T07:00:54.973Z';
|
||||
var start = new Date( end ) - 60000;
|
||||
|
||||
var arr = datespace( start, end, 6 );
|
||||
/* returns [
|
||||
'Mon Dec 01 2014 22:59:54 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:06 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:18 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:30 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:42 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:54 GMT-0800 (PST)'
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
The `start` and `stop` times may be either [`Date`][mdn-date-object] objects, date strings, Unix timestamps, or JavaScript timestamps.
|
||||
|
||||
```javascript
|
||||
// JavaScript timestamps:
|
||||
var end = 1417503654973;
|
||||
var start = new Date( end - 60000 );
|
||||
|
||||
var arr = datespace( start, end, 6 );
|
||||
/* returns [
|
||||
'Mon Dec 01 2014 22:59:54 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:06 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:18 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:30 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:42 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:54 GMT-0800 (PST)'
|
||||
]
|
||||
*/
|
||||
|
||||
// Unix timestamps:
|
||||
end = 1417503655;
|
||||
start = end - 60;
|
||||
|
||||
arr = datespace( start, end, 6 );
|
||||
/* returns [
|
||||
'Mon Dec 01 2014 22:59:54 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:06 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:18 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:30 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:42 GMT-0800 (PST)',
|
||||
'Mon Dec 01 2014 23:00:54 GMT-0800 (PST)'
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
The output `array` is guaranteed to include the `start` and `end` times. Beware, however, that values between the `start` and `end` are subject to rounding errors. For example,
|
||||
|
||||
```javascript
|
||||
var arr = datespace( 1417503655000, 1417503655001, 3 );
|
||||
// returns [ 1417503655000, 1417503655000, 1417503655001 ]
|
||||
```
|
||||
|
||||
where sub-millisecond values are truncated by the [`Date`][mdn-date-object] constructor. Duplicate values should only be a problem when the interval separating consecutive times is less than a millisecond. As the interval separating consecutive dates goes to infinity, the quantization noise introduced by millisecond resolution is negligible.
|
||||
|
||||
By default, fractional timestamps are floored. To specify that timestamps always be rounded up or to the nearest millisecond **when converted to [`Date`][mdn-date-object] objects**, set the `round` option (default: `floor`).
|
||||
|
||||
```javascript
|
||||
// Equivalent of Math.ceil():
|
||||
var arr = datespace( 1417503655000, 1417503655001, 3, {
|
||||
'round': 'ceil'
|
||||
});
|
||||
// returns [ 1417503655000, 1417503655001, 1417503655001 ]
|
||||
|
||||
// Equivalent of Math.round():
|
||||
arr = datespace( 1417503655000, 1417503655001, 3, {
|
||||
'round': 'round'
|
||||
});
|
||||
// returns [ 1417503655000, 1417503655001, 1417503655001 ]
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.usage -->
|
||||
|
||||
<section class="notes">
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.notes -->
|
||||
|
||||
<section class="examples">
|
||||
|
||||
## Examples
|
||||
|
||||
```javascript
|
||||
var datespace = require( '@stdlib/array/datespace' );
|
||||
var start;
|
||||
var arr;
|
||||
var end;
|
||||
|
||||
end = '2014-12-02T07:00:54.973Z';
|
||||
start = new Date( end ) - 100000;
|
||||
|
||||
// Default behavior:
|
||||
arr = datespace( start, end );
|
||||
console.log( arr.join( '\n' ) );
|
||||
|
||||
// Specify length:
|
||||
arr = datespace( start, end, 10 );
|
||||
console.log( arr.join( '\n' ) );
|
||||
|
||||
arr = datespace( start, end, 11 );
|
||||
console.log( arr.join( '\n' ) );
|
||||
|
||||
// Create an array with decremented values:
|
||||
arr = datespace( end, start, 11 );
|
||||
console.log( arr.join( '\n' ) );
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.examples -->
|
||||
|
||||
<section class="links">
|
||||
|
||||
[mdn-date-object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
|
||||
|
||||
</section>
|
||||
|
||||
<!-- /.links -->
|
44
js/node_modules/@stdlib/array/datespace/docs/repl.txt
generated
vendored
Normal file
44
js/node_modules/@stdlib/array/datespace/docs/repl.txt
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
{{alias}}( start, stop[, length][ , options] )
|
||||
Generates an array of linearly spaced dates.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start: number
|
||||
Start time as either a `Date` object, Unix timestamp, JavaScript
|
||||
timestamp, or date string.
|
||||
|
||||
stop: number
|
||||
Stop time as either a `Date` object, Unix timestamp, JavaScript
|
||||
timestamp, or date string.
|
||||
|
||||
length: integer (optional)
|
||||
Length of output array. Default: `100`.
|
||||
|
||||
options: Object (optional)
|
||||
Options.
|
||||
|
||||
options.round: string (optional)
|
||||
Specifies how sub-millisecond times should be rounded:
|
||||
[ 'floor', 'ceil', 'round' ]. Default: 'floor'.
|
||||
|
||||
Returns
|
||||
-------
|
||||
arr: Array
|
||||
Array of dates.
|
||||
|
||||
Examples
|
||||
--------
|
||||
> var stop = '2014-12-02T07:00:54.973Z';
|
||||
> var start = new Date( stop ) - 60000;
|
||||
> var arr = {{alias}}( start, stop, 6 )
|
||||
[...]
|
||||
|
||||
// Equivalent of Math.ceil():
|
||||
> var opts = { 'round': 'ceil' };
|
||||
> arr = {{alias}}( 1417503655000, 1417503655001, 3, opts )
|
||||
[...]
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
92
js/node_modules/@stdlib/array/datespace/docs/types/index.d.ts
generated
vendored
Normal file
92
js/node_modules/@stdlib/array/datespace/docs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
/**
|
||||
* Interface defining function options.
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* Specifies how sub-millisecond times should be rounded (default: 'floor' ).
|
||||
*/
|
||||
round?: 'floor' | 'round' | 'ceil';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an array of linearly spaced dates.
|
||||
*
|
||||
* @param start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string
|
||||
* @param stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string
|
||||
* @param options - function options
|
||||
* @param options.round - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' )
|
||||
* @throws must provide valid options
|
||||
* @returns array of dates
|
||||
*
|
||||
* @example
|
||||
* var stop = '2014-12-02T07:00:54.973Z';
|
||||
* var start = new Date( stop ) - 60000;
|
||||
*
|
||||
* var arr = datespace( start, stop, 6 );
|
||||
* // returns [...]
|
||||
*
|
||||
* @example
|
||||
* // Equivalent of Math.ceil():
|
||||
* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } );
|
||||
* // returns [...]
|
||||
*
|
||||
* // Equivalent of Math.round():
|
||||
* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } );
|
||||
* // returns [...]
|
||||
*/
|
||||
declare function datespace( start: Date | number | string, stop: Date | number | string, options?: Options ): Array<Date>; // tslint-disable-line max-line-length
|
||||
|
||||
/**
|
||||
* Generates an array of linearly spaced dates.
|
||||
*
|
||||
* @param start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string
|
||||
* @param stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string
|
||||
* @param length - output array length (default: 100)
|
||||
* @param options - function options
|
||||
* @param options.round - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' )
|
||||
* @throws length argument must a positive integer
|
||||
* @throws must provide valid options
|
||||
* @returns array of dates
|
||||
*
|
||||
* @example
|
||||
* var stop = '2014-12-02T07:00:54.973Z';
|
||||
* var start = new Date( stop ) - 60000;
|
||||
*
|
||||
* var arr = datespace( start, stop, 6 );
|
||||
* // returns [...]
|
||||
*
|
||||
* @example
|
||||
* // Equivalent of Math.ceil():
|
||||
* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } );
|
||||
* // returns [...]
|
||||
*
|
||||
* // Equivalent of Math.round():
|
||||
* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } );
|
||||
* // returns [...]
|
||||
*/
|
||||
declare function datespace( start: Date | number | string, stop: Date | number | string, length: number, options?: Options ): Array<Date>; // tslint-disable-line max-line-length
|
||||
|
||||
|
||||
// EXPORTS //
|
||||
|
||||
export = datespace;
|
86
js/node_modules/@stdlib/array/datespace/docs/types/test.ts
generated
vendored
Normal file
86
js/node_modules/@stdlib/array/datespace/docs/types/test.ts
generated
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import datespace = require( './index' );
|
||||
|
||||
|
||||
// TESTS //
|
||||
|
||||
// The function returns an array of dates...
|
||||
{
|
||||
const stop = '2014-12-02T07:00:54.973Z';
|
||||
const start = new Date( stop ).getTime() - 60000;
|
||||
datespace( start, stop ); // $ExpectType Date[]
|
||||
datespace( start, stop, 30 ); // $ExpectType Date[]
|
||||
datespace( start, stop, { 'round': 'floor' } ); // $ExpectType Date[]
|
||||
datespace( start, stop, 30, { 'round': 'floor' } ); // $ExpectType Date[]
|
||||
}
|
||||
|
||||
// The function does not compile if provided values other `Date` objects, Unix timestamps, JavaScript timestamps, or date strings for the first two parameters...
|
||||
{
|
||||
const stop = '2014-12-02T07:00:54.973Z';
|
||||
const start = new Date( stop ).getTime() - 60000;
|
||||
datespace( true, stop ); // $ExpectError
|
||||
datespace( false, stop ); // $ExpectError
|
||||
datespace( null, stop ); // $ExpectError
|
||||
datespace( [], stop ); // $ExpectError
|
||||
datespace( {}, stop ); // $ExpectError
|
||||
datespace( ( x: number ): number => x, stop ); // $ExpectError
|
||||
|
||||
datespace( start, true ); // $ExpectError
|
||||
datespace( start, false ); // $ExpectError
|
||||
datespace( start, [] ); // $ExpectError
|
||||
datespace( start, {} ); // $ExpectError
|
||||
datespace( start, ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The function does not compile if provided a value other than a number or object for the third parameter...
|
||||
{
|
||||
const stop = '2014-12-02T07:00:54.973Z';
|
||||
const start = new Date( stop ).getTime() - 60000;
|
||||
datespace( start, stop, true ); // $ExpectError
|
||||
datespace( start, stop, false ); // $ExpectError
|
||||
datespace( start, stop, '5' ); // $ExpectError
|
||||
datespace( start, stop, [] ); // $ExpectError
|
||||
datespace( start, stop, ( x: number ): number => x ); // $ExpectError
|
||||
}
|
||||
|
||||
// The compiler throws an error if the function is provided a `round` option which is not a recognized rounding procedure...
|
||||
{
|
||||
const stop = '2014-12-02T07:00:54.973Z';
|
||||
const start = new Date( stop ).getTime() - 60000;
|
||||
datespace( start, stop, { 'round': 'abc' } ); // $ExpectError
|
||||
datespace( start, stop, { 'round': 123 } ); // $ExpectError
|
||||
datespace( start, stop, { 'round': null } ); // $ExpectError
|
||||
datespace( start, stop, { 'round': [] } ); // $ExpectError
|
||||
datespace( start, stop, { 'round': {} } ); // $ExpectError
|
||||
datespace( start, stop, { 'round': ( x: number ): number => x } ); // $ExpectError
|
||||
|
||||
datespace( start, stop, 10, { 'round': 'abc' } ); // $ExpectError
|
||||
datespace( start, stop, 10, { 'round': 123 } ); // $ExpectError
|
||||
datespace( start, stop, 10, { 'round': null } ); // $ExpectError
|
||||
datespace( start, stop, 10, { 'round': [] } ); // $ExpectError
|
||||
datespace( start, stop, 10, { 'round': {} } ); // $ExpectError
|
||||
datespace( start, stop, 10, { 'round': ( x: number ): number => x } ); // $ExpectError
|
||||
}
|
||||
|
||||
// The function does not compile if provided insufficient arguments...
|
||||
{
|
||||
datespace(); // $ExpectError
|
||||
datespace( new Date() ); // $ExpectError
|
||||
}
|
43
js/node_modules/@stdlib/array/datespace/lib/index.js
generated
vendored
Normal file
43
js/node_modules/@stdlib/array/datespace/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 The Stdlib Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||